1.1 --- a/conf/landfall-examples/mips-letux400-keypad-driver.cfg Fri May 18 17:19:28 2018 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,145 +0,0 @@
1.4 --- vim: ft=lua ts=2 et sw=2
1.5 -
1.6 --- Start Mag to multiplex the framebuffer showing only a single program.
1.7 --- This example shows the key values produced by the keypad input driver.
1.8 --- The target platform is the Letux 400 notebook computer.
1.9 -
1.10 -local L4 = require("L4");
1.11 -
1.12 -local l = L4.default_loader;
1.13 -
1.14 --- Define general access to peripherals.
1.15 -
1.16 -local io_buses = {
1.17 - cpm = l:new_channel();
1.18 - gpio = l:new_channel();
1.19 - lcd = l:new_channel();
1.20 - pwm = l:new_channel(); -- exposes GPIO, PWM
1.21 - };
1.22 -
1.23 -l:start({
1.24 - caps = {
1.25 - cpm = io_buses.cpm:svr(),
1.26 - gpio = io_buses.gpio:svr(),
1.27 - lcd = io_buses.lcd:svr(),
1.28 - pwm = io_buses.pwm:svr(),
1.29 -
1.30 - icu = L4.Env.icu,
1.31 - sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0),
1.32 - },
1.33 - },
1.34 - "rom/io rom/hw_devices.io rom/mips-letux400-keypad-driver.io");
1.35 -
1.36 --- Expose a PWM peripheral as a device.
1.37 -
1.38 -local pwm = l:new_channel();
1.39 -
1.40 -l:startv({
1.41 - caps = {
1.42 - vbus = io_buses.pwm,
1.43 - pwm = pwm:svr(),
1.44 - },
1.45 - },
1.46 - "rom/dev_pwm_jz4730", "0", "250", "299", "47"); -- specifying peripheral number, parameters
1.47 -
1.48 --- Expose a PWM backlight device.
1.49 -
1.50 -local backlight = l:new_channel(); -- exposes backlight device
1.51 -
1.52 -l:startv({
1.53 - caps = {
1.54 - pwm = pwm,
1.55 - backlight = backlight:svr(),
1.56 - },
1.57 - },
1.58 - "rom/dev_backlight_pwm", "0", "300"); -- specifying limits
1.59 -
1.60 --- Expose a display device for the Letux.
1.61 -
1.62 -local display = l:new_channel(); -- exposes display device
1.63 -
1.64 -l:start({
1.65 - caps = {
1.66 - backlight = backlight,
1.67 - display = display:svr(),
1.68 - vbus = io_buses.gpio,
1.69 - },
1.70 - },
1.71 - "rom/dev_display_letux400");
1.72 -
1.73 --- Expose a panel definition for the Letux.
1.74 -
1.75 -local panel = l:new_channel(); -- exposes panel
1.76 -
1.77 -l:start({
1.78 - caps = {
1.79 - panel = panel:svr(),
1.80 - },
1.81 - },
1.82 - "rom/dev_panel_letux400");
1.83 -
1.84 --- Expose the CPM peripheral.
1.85 -
1.86 -local cpm = l:new_channel();
1.87 -
1.88 -l:start({
1.89 - caps = {
1.90 - vbus = io_buses.cpm,
1.91 - cpm = cpm:svr(),
1.92 - },
1.93 - },
1.94 - "rom/dev_cpm_jz4730");
1.95 -
1.96 --- Expose a framebuffer device.
1.97 -
1.98 -local fbdrv_fb = l:new_channel();
1.99 -
1.100 -l:start({
1.101 - caps = {
1.102 - vbus = io_buses.lcd,
1.103 - fb = fbdrv_fb:svr(),
1.104 - cpm = cpm,
1.105 - display = display, -- needed by LCD driver
1.106 - panel = panel,
1.107 - },
1.108 - },
1.109 - "rom/fb-drv");
1.110 -
1.111 --- Multiplex the framebuffer.
1.112 -
1.113 -local mag_caps = {
1.114 - mag = l:new_channel(),
1.115 - svc = l:new_channel(),
1.116 - };
1.117 -
1.118 -l:start({
1.119 - caps = {
1.120 - vbus = io_buses.gpio, -- needed by input driver
1.121 - fb = fbdrv_fb,
1.122 - mag = mag_caps.mag:svr(),
1.123 - svc = mag_caps.svc:svr(),
1.124 - },
1.125 - },
1.126 - "rom/mag");
1.127 -
1.128 --- Expose the keypad matrix.
1.129 -
1.130 -local keypad = l:new_channel();
1.131 -
1.132 -l:start({
1.133 - caps = {
1.134 - vbus = io_buses.gpio,
1.135 - keypad = keypad:svr(),
1.136 - },
1.137 - },
1.138 - "rom/dev_keypad_letux400");
1.139 -
1.140 --- Show key event values.
1.141 -
1.142 -l:start({
1.143 - caps = {
1.144 - fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"),
1.145 - keypad = keypad,
1.146 - },
1.147 - },
1.148 - "rom/ex_letux400_keypad_driver");
2.1 --- a/conf/landfall-examples/mips-letux400-keypad-driver.io Fri May 18 17:19:28 2018 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,26 +0,0 @@
2.4 --- vim: ft=lua ts=2 et sw=2
2.5 -
2.6 --- Configuration file for Io.
2.7 -
2.8 -local hw = Io.system_bus()
2.9 -
2.10 -Io.add_vbus("cpm", Io.Vi.System_bus
2.11 -{
2.12 - CPM = wrap(hw:match("jz4730-cpm"));
2.13 -})
2.14 -
2.15 -Io.add_vbus("gpio", Io.Vi.System_bus
2.16 -{
2.17 - GPIO = wrap(hw:match("jz4730-gpio"));
2.18 -})
2.19 -
2.20 -Io.add_vbus("lcd", Io.Vi.System_bus
2.21 -{
2.22 - LCD = wrap(hw:match("jz4740-lcd"));
2.23 -})
2.24 -
2.25 -Io.add_vbus("pwm", Io.Vi.System_bus
2.26 -{
2.27 - GPIO = wrap(hw:match("jz4730-gpio"));
2.28 - PWM = wrap(hw:match("jz4730-pwm"));
2.29 -})
3.1 --- a/conf/landfall-examples/mips-letux400-keypad-driver.list Fri May 18 17:19:28 2018 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,22 +0,0 @@
3.4 -
3.5 -modaddr 0x1100000
3.6 -
3.7 -entry mips-letux400-keypad-driver-example
3.8 -bootstrap bootstrap -serial
3.9 -kernel fiasco -serial_esc
3.10 -roottask moe rom/mips-letux400-keypad-driver.cfg
3.11 -module mips-letux400-keypad-driver.cfg
3.12 -module mips-letux400-keypad-driver.io
3.13 -module plat-letux400/hw_devices.io
3.14 -module l4re
3.15 -module io
3.16 -module ned
3.17 -module fb-drv
3.18 -module mag
3.19 -module dev_pwm_jz4730
3.20 -module dev_backlight_pwm
3.21 -module dev_display_letux400
3.22 -module dev_panel_letux400
3.23 -module dev_cpm_jz4730
3.24 -module dev_keypad_letux400
3.25 -module ex_letux400_keypad_driver
4.1 --- a/conf/landfall-examples/mips-qi_lb60-keypad-driver.cfg Fri May 18 17:19:28 2018 +0200
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,143 +0,0 @@
4.4 --- vim: ft=lua ts=2 et sw=2
4.5 -
4.6 --- Start Mag to multiplex the framebuffer showing only a single program.
4.7 --- This example shows the key values produced by the keypad input driver.
4.8 --- The target platform is the Ben NanoNote.
4.9 -
4.10 -local L4 = require("L4");
4.11 -
4.12 -local l = L4.default_loader;
4.13 -
4.14 --- Define general access to peripherals.
4.15 -
4.16 -local io_buses = {
4.17 - cpm = l:new_channel();
4.18 - gpio = l:new_channel();
4.19 - lcd = l:new_channel();
4.20 - };
4.21 -
4.22 -l:start({
4.23 - caps = {
4.24 - cpm = io_buses.cpm:svr(),
4.25 - gpio = io_buses.gpio:svr(),
4.26 - lcd = io_buses.lcd:svr(),
4.27 -
4.28 - icu = L4.Env.icu,
4.29 - sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0),
4.30 - },
4.31 - },
4.32 - "rom/io rom/hw_devices.io rom/mips-qi_lb60-keypad-driver.io");
4.33 -
4.34 --- Expose a SPI peripheral as a device.
4.35 -
4.36 -local spi = l:new_channel();
4.37 -
4.38 -l:startv({
4.39 - caps = {
4.40 - vbus = io_buses.gpio,
4.41 - spi = spi:svr(),
4.42 - },
4.43 - },
4.44 - "rom/dev_spi_jz4740", "C23", "C22", "C21"); -- specifying clock, data, enable pin details
4.45 -
4.46 --- Expose a SPI backlight device for the Ben.
4.47 -
4.48 -local backlight = l:new_channel(); -- exposes backlight device
4.49 -
4.50 -l:start({
4.51 - caps = {
4.52 - spi = spi,
4.53 - backlight = backlight:svr(),
4.54 - },
4.55 - },
4.56 - "rom/dev_backlight_spi_qi_lb60");
4.57 -
4.58 --- Expose a display device for the Ben.
4.59 -
4.60 -local display = l:new_channel(); -- exposes display device
4.61 -
4.62 -l:start({
4.63 - caps = {
4.64 - backlight = backlight,
4.65 - display = display:svr(),
4.66 - vbus = io_buses.gpio,
4.67 - },
4.68 - },
4.69 - "rom/dev_display_qi_lb60");
4.70 -
4.71 --- Expose a panel definition for the Ben.
4.72 -
4.73 -local panel = l:new_channel(); -- exposes panel
4.74 -
4.75 -l:start({
4.76 - caps = {
4.77 - panel = panel:svr(),
4.78 - },
4.79 - },
4.80 - "rom/dev_panel_qi_lb60");
4.81 -
4.82 --- Expose the CPM peripheral.
4.83 -
4.84 -local cpm = l:new_channel();
4.85 -
4.86 -l:start({
4.87 - caps = {
4.88 - vbus = io_buses.cpm,
4.89 - cpm = cpm:svr(),
4.90 - },
4.91 - },
4.92 - "rom/dev_cpm_jz4740");
4.93 -
4.94 --- Expose a framebuffer device.
4.95 -
4.96 -local fbdrv_fb = l:new_channel();
4.97 -
4.98 -l:start({
4.99 - caps = {
4.100 - vbus = io_buses.lcd,
4.101 - fb = fbdrv_fb:svr(),
4.102 - cpm = cpm,
4.103 - display = display, -- needed by LCD driver
4.104 - panel = panel,
4.105 - },
4.106 - },
4.107 - "rom/fb-drv");
4.108 -
4.109 --- Multiplex the framebuffer.
4.110 -
4.111 -local mag_caps = {
4.112 - mag = l:new_channel(),
4.113 - svc = l:new_channel(),
4.114 - };
4.115 -
4.116 -l:start({
4.117 - caps = {
4.118 - vbus = io_buses.gpio, -- needed by input driver
4.119 - fb = fbdrv_fb,
4.120 - mag = mag_caps.mag:svr(),
4.121 - svc = mag_caps.svc:svr(),
4.122 - },
4.123 - },
4.124 - "rom/mag");
4.125 -
4.126 --- Expose the keypad matrix.
4.127 -
4.128 -local keypad = l:new_channel();
4.129 -
4.130 -l:start({
4.131 - caps = {
4.132 - vbus = io_buses.gpio,
4.133 - keypad = keypad:svr(),
4.134 - },
4.135 - },
4.136 - "rom/dev_keypad_qi_lb60");
4.137 -
4.138 --- Show key event values.
4.139 -
4.140 -l:startv({
4.141 - caps = {
4.142 - fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"),
4.143 - keypad = keypad,
4.144 - },
4.145 - },
4.146 - "rom/ex_qi_lb60_keypad_driver");
5.1 --- a/conf/landfall-examples/mips-qi_lb60-keypad-driver.io Fri May 18 17:19:28 2018 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,20 +0,0 @@
5.4 --- vim: ft=lua ts=2 et sw=2
5.5 -
5.6 --- Configuration file for Io.
5.7 -
5.8 -local hw = Io.system_bus()
5.9 -
5.10 -Io.add_vbus("cpm", Io.Vi.System_bus
5.11 -{
5.12 - CPM = wrap(hw:match("jz4740-cpm"));
5.13 -})
5.14 -
5.15 -Io.add_vbus("gpio", Io.Vi.System_bus
5.16 -{
5.17 - GPIO = wrap(hw:match("jz4740-gpio"));
5.18 -})
5.19 -
5.20 -Io.add_vbus("lcd", Io.Vi.System_bus
5.21 -{
5.22 - LCD = wrap(hw:match("jz4740-lcd"));
5.23 -})
6.1 --- a/conf/landfall-examples/mips-qi_lb60-keypad-driver.list Fri May 18 17:19:28 2018 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,22 +0,0 @@
6.4 -
6.5 -modaddr 0x1100000
6.6 -
6.7 -entry mips-qi_lb60-keypad-driver-example
6.8 -bootstrap bootstrap -serial
6.9 -kernel fiasco -serial_esc
6.10 -roottask moe rom/mips-qi_lb60-keypad-driver.cfg
6.11 -module mips-qi_lb60-keypad-driver.cfg
6.12 -module mips-qi_lb60-keypad-driver.io
6.13 -module plat-qi_lb60/hw_devices.io
6.14 -module l4re
6.15 -module io
6.16 -module ned
6.17 -module fb-drv
6.18 -module mag
6.19 -module dev_spi_jz4740
6.20 -module dev_backlight_spi_qi_lb60
6.21 -module dev_display_qi_lb60
6.22 -module dev_panel_qi_lb60
6.23 -module dev_cpm_jz4740
6.24 -module dev_keypad_qi_lb60
6.25 -module ex_qi_lb60_keypad_driver
7.1 --- a/pkg/landfall-examples/letux400_keypad_driver/Makefile Fri May 18 17:19:28 2018 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,9 +0,0 @@
7.4 -PKGDIR ?= ..
7.5 -L4DIR ?= $(PKGDIR)/../..
7.6 -
7.7 -TARGET = ex_letux400_keypad_driver
7.8 -SRC_CC = letux400_keypad_driver.cc
7.9 -SRC_DATA = unifont.tff
7.10 -REQUIRES_LIBS = libio l4re_c-util libdevice-input-keypad libdrivers-keypad-letux400 mag-gfx
7.11 -
7.12 -include $(L4DIR)/mk/prog.mk
8.1 --- a/pkg/landfall-examples/letux400_keypad_driver/letux400_keypad_driver.cc Fri May 18 17:19:28 2018 +0200
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,251 +0,0 @@
8.4 -/*
8.5 - * Access the keypad on the configured device using an input driver.
8.6 - *
8.7 - * (c) 2018 Paul Boddie <paul@boddie.org.uk>
8.8 - *
8.9 - * This program is free software; you can redistribute it and/or
8.10 - * modify it under the terms of the GNU General Public License as
8.11 - * published by the Free Software Foundation; either version 2 of
8.12 - * the License, or (at your option) any later version.
8.13 - *
8.14 - * This program is distributed in the hope that it will be useful,
8.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.17 - * GNU General Public License for more details.
8.18 - *
8.19 - * You should have received a copy of the GNU General Public License
8.20 - * along with this program; if not, write to the Free Software
8.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
8.22 - * Boston, MA 02110-1301, USA
8.23 - *
8.24 - *
8.25 - * Font definitions and licence (see unifont.tff for bitmap data derived from
8.26 - * GNU Unifont's unifont.hex file):
8.27 - *
8.28 - * Copyright (C) 1998-2003 Roman Czyborra (http://czyborra.com/)
8.29 - *
8.30 - * All glyphs are released under the GNU General Public License
8.31 - * (GPL) version 2 or (at your option) a later version, with the
8.32 - * GNU font embedding exception:
8.33 - *
8.34 - * ** GPL v2.0 license with font embedding exception:
8.35 - *
8.36 - * As a special exception, if you create a document which
8.37 - * uses this font, and embed this font or unaltered portions
8.38 - * of this font into the document, this font does not by
8.39 - * itself cause the resulting document to be covered by
8.40 - * the GNU General Public License. This exception does not
8.41 - * however invalidate any other reasons why the document
8.42 - * might be covered by the GNU General Public License.
8.43 - * If you modify this font, you may extend this exception
8.44 - * to your version of the font, but you are not obligated
8.45 - * to do so. If you do not wish to do so, delete this
8.46 - * exception statement from your version.
8.47 - */
8.48 -
8.49 -#include <l4/devices/input-keypad-client.h>
8.50 -
8.51 -#include <l4/re/c/util/video/goos_fb.h>
8.52 -#include <l4/re/c/video/view.h>
8.53 -#include <l4/util/util.h>
8.54 -
8.55 -#include <l4/mag-gfx/canvas>
8.56 -#include <l4/mag-gfx/font>
8.57 -#include <l4/mag-gfx/geometry>
8.58 -#include <l4/mag-gfx/gfx_colors>
8.59 -#include <l4/mag-gfx/mem_factory>
8.60 -
8.61 -#include <stdint.h>
8.62 -#include <string.h>
8.63 -
8.64 -/* Video abstractions. */
8.65 -
8.66 -static l4re_util_video_goos_fb_t gfb;
8.67 -static l4re_video_view_info_t view_info;
8.68 -static void *fb = 0;
8.69 -
8.70 -/* Bundled font data. */
8.71 -
8.72 -extern char const _binary_unifont_tff_start[];
8.73 -
8.74 -/* Screen abstractions. */
8.75 -
8.76 -using namespace Mag_gfx;
8.77 -
8.78 -static Font *_font = 0;
8.79 -static Canvas *_screen = 0;
8.80 -
8.81 -
8.82 -
8.83 -/* Factories for certain pixel formats. */
8.84 -
8.85 -static Mem::Factory<Rgb16> _rgb16;
8.86 -static Mem::Factory<Rgb32> _rgb32;
8.87 -
8.88 -
8.89 -
8.90 -/* Key to character conversion function. */
8.91 -
8.92 -static const char *keys_to_strings[] = {
8.93 -
8.94 - 0, "Escape", "1", "2", "3", "4", "5", "6", "7", "8",
8.95 -
8.96 - "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R",
8.97 -
8.98 - "T", "Y", "U", "I", "O", "P", "[", "]", "Enter", "Left Ctrl",
8.99 -
8.100 - "A", "S", "D", "F", "G", "H", "J", "K", "L", ";",
8.101 -
8.102 - "'", "`", "Left Shift", "\\", "Z", "X", "C", "V", "B", "N",
8.103 -
8.104 - "M", ",", ".", "/", "Right Shift", "Keypad *", "Left Alt", "Space",
8.105 - "Caps Lock", "F1",
8.106 -
8.107 - "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "Num Lock",
8.108 -
8.109 - "Scroll Lock", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad -", "Keypad 4",
8.110 - "Keypad 5", "Keypad 6", "Keypad +", "Keypad 1",
8.111 -
8.112 - "Keypad 2", "Keypad 3", "Keypad 0", "Keypad .", 0, 0, "#102", "F11", "F12", 0,
8.113 -
8.114 - 0, 0, 0, 0, 0, 0, "Keypad Enter", "Right Ctrl", "Keypad /", "SysRq",
8.115 -
8.116 - "Right Alt", "Line Feed", "Home", "Up", "Page Up", "Left", "Right", "End",
8.117 - "Down", "Page Down",
8.118 -
8.119 - "Insert", "Delete", "Macro", "Mute", "Volume Down", "Volume Up", "Power",
8.120 - "Keypad =", "Keypad +-", "Pause",
8.121 -};
8.122 -
8.123 -static const char null_string[] = "Unknown";
8.124 -
8.125 -const int keys_to_strings_length = 120;
8.126 -
8.127 -static const char *key_to_string(int key)
8.128 -{
8.129 - return key < keys_to_strings_length ? keys_to_strings[key] : 0;
8.130 -}
8.131 -
8.132 -/* Show the keypad event status on the display. */
8.133 -
8.134 -static uint8_t row = 0;
8.135 -static uint32_t text_x = 0, text_y = 0, next_y = 0;
8.136 -
8.137 -static void handler(Input_event event, void *priv)
8.138 -{
8.139 - uint32_t colsize = view_info.width / 10,
8.140 - rowsize = view_info.height / 20;
8.141 - uint8_t column;
8.142 - uint16_t mask;
8.143 -
8.144 - /* Convert the key code into a bit pattern. */
8.145 -
8.146 - if (!priv)
8.147 - {
8.148 - for (column = 0, mask = (1 << 9); column < 10; column++, mask >>= 1)
8.149 - _screen->draw_box(Rect(Point(column * colsize, row * rowsize), Area(colsize, rowsize)),
8.150 - event.code & mask ? event.value ? Rgb32::Color(0, 255, 0) : Rgb32::Color(255, 0, 0)
8.151 - : Rgb32::Color(0, 0, 0));
8.152 -
8.153 - /* Advance to the next row, wrapping around. */
8.154 -
8.155 - row = (row + 1) % 20;
8.156 - }
8.157 -
8.158 - /* Or produce a string. */
8.159 -
8.160 - else if (event.value)
8.161 - {
8.162 - const char *s = ((const char *(*)(int)) priv)(event.code);
8.163 - Rgba32::Color col;
8.164 -
8.165 - if (!s)
8.166 - {
8.167 - s = null_string;
8.168 - col = Rgba32::Color(255, 0, 0, Rgba32::Color::Amax);
8.169 - }
8.170 - else
8.171 - col = Rgba32::Color(255, 255, 255, Rgba32::Color::Amax);
8.172 -
8.173 - Area box = _font->str_sz(s, strlen(s));
8.174 -
8.175 - /* Test for enough space horizontally. */
8.176 -
8.177 - if (text_x + box.w() > view_info.width)
8.178 - {
8.179 - text_x = 0;
8.180 - text_y = next_y;
8.181 - next_y = text_y + box.h();
8.182 - }
8.183 -
8.184 - /* Expand the line height, if appropriate. */
8.185 -
8.186 - else if (text_y + box.h() > next_y)
8.187 - next_y += box.h();
8.188 -
8.189 - /* Test for enough space vertically. */
8.190 -
8.191 - if (next_y > view_info.height)
8.192 - {
8.193 - text_x = 0;
8.194 - text_y = 0;
8.195 - next_y = box.h();
8.196 - }
8.197 -
8.198 - Point p(text_x, text_y);
8.199 -
8.200 - _screen->draw_box(Rect(p, box), Rgb32::Color(0, 0, 0));
8.201 - _screen->draw_string(p, _font, col, s, strlen(s));
8.202 -
8.203 - /* Move to the next position. */
8.204 -
8.205 - text_x += box.w();
8.206 - }
8.207 -
8.208 - /* Refresh the display. */
8.209 -
8.210 - l4re_util_video_goos_fb_refresh(&gfb, 0, 0, view_info.width, view_info.height);
8.211 -}
8.212 -
8.213 -/* Arguments: [ chars ] */
8.214 -
8.215 -int main(int argc, char *argv[])
8.216 -{
8.217 - Keypad *keypad = Keypad::get_keypad();
8.218 - Input_keypad_client client(keypad);
8.219 -
8.220 - if (l4re_util_video_goos_fb_setup_name(&gfb, "fb"))
8.221 - return 1;
8.222 -
8.223 - if (l4re_util_video_goos_fb_view_info(&gfb, &view_info))
8.224 - return 1;
8.225 -
8.226 - if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb)))
8.227 - return 1;
8.228 -
8.229 - /* Obtain a canvas for the framebuffer. */
8.230 -
8.231 - Factory *factory;
8.232 -
8.233 - if (view_info.pixel_info.bytes_per_pixel == 2)
8.234 - factory = &_rgb16;
8.235 - else
8.236 - factory = &_rgb32;
8.237 -
8.238 - Canvas *screen = factory->create_canvas((void *) ((unsigned long) fb + view_info.buffer_offset),
8.239 - Area(view_info.width, view_info.height),
8.240 - view_info.bytes_per_line);
8.241 -
8.242 - Font font(&_binary_unifont_tff_start[0]);
8.243 -
8.244 - _screen = screen;
8.245 - _font = &font;
8.246 -
8.247 - /* Attach the event handler and wait for events. */
8.248 -
8.249 - client.attach(handler, (argc > 1) && (!strcmp(argv[1], "chars")) ? (void *) key_to_string : 0);
8.250 -
8.251 - l4_sleep_forever();
8.252 -
8.253 - return 0;
8.254 -}
9.1 Binary file pkg/landfall-examples/letux400_keypad_driver/unifont.tff has changed
10.1 --- a/pkg/landfall-examples/qi_lb60_keypad_driver/Makefile Fri May 18 17:19:28 2018 +0200
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,9 +0,0 @@
10.4 -PKGDIR ?= ..
10.5 -L4DIR ?= $(PKGDIR)/../..
10.6 -
10.7 -TARGET = ex_qi_lb60_keypad_driver
10.8 -SRC_CC = qi_lb60_keypad_driver.cc
10.9 -SRC_DATA = unifont.tff
10.10 -REQUIRES_LIBS = libio l4re_c-util libdevice-input-keypad libdrivers-keypad-qi_lb60 mag-gfx
10.11 -
10.12 -include $(L4DIR)/mk/prog.mk
11.1 --- a/pkg/landfall-examples/qi_lb60_keypad_driver/qi_lb60_keypad_driver.cc Fri May 18 17:19:28 2018 +0200
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,251 +0,0 @@
11.4 -/*
11.5 - * Access the keypad on the configured device using an input driver.
11.6 - *
11.7 - * (c) 2018 Paul Boddie <paul@boddie.org.uk>
11.8 - *
11.9 - * This program is free software; you can redistribute it and/or
11.10 - * modify it under the terms of the GNU General Public License as
11.11 - * published by the Free Software Foundation; either version 2 of
11.12 - * the License, or (at your option) any later version.
11.13 - *
11.14 - * This program is distributed in the hope that it will be useful,
11.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.17 - * GNU General Public License for more details.
11.18 - *
11.19 - * You should have received a copy of the GNU General Public License
11.20 - * along with this program; if not, write to the Free Software
11.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
11.22 - * Boston, MA 02110-1301, USA
11.23 - *
11.24 - *
11.25 - * Font definitions and licence (see unifont.tff for bitmap data derived from
11.26 - * GNU Unifont's unifont.hex file):
11.27 - *
11.28 - * Copyright (C) 1998-2003 Roman Czyborra (http://czyborra.com/)
11.29 - *
11.30 - * All glyphs are released under the GNU General Public License
11.31 - * (GPL) version 2 or (at your option) a later version, with the
11.32 - * GNU font embedding exception:
11.33 - *
11.34 - * ** GPL v2.0 license with font embedding exception:
11.35 - *
11.36 - * As a special exception, if you create a document which
11.37 - * uses this font, and embed this font or unaltered portions
11.38 - * of this font into the document, this font does not by
11.39 - * itself cause the resulting document to be covered by
11.40 - * the GNU General Public License. This exception does not
11.41 - * however invalidate any other reasons why the document
11.42 - * might be covered by the GNU General Public License.
11.43 - * If you modify this font, you may extend this exception
11.44 - * to your version of the font, but you are not obligated
11.45 - * to do so. If you do not wish to do so, delete this
11.46 - * exception statement from your version.
11.47 - */
11.48 -
11.49 -#include <l4/devices/input-keypad-client.h>
11.50 -
11.51 -#include <l4/re/c/util/video/goos_fb.h>
11.52 -#include <l4/re/c/video/view.h>
11.53 -#include <l4/util/util.h>
11.54 -
11.55 -#include <l4/mag-gfx/canvas>
11.56 -#include <l4/mag-gfx/font>
11.57 -#include <l4/mag-gfx/geometry>
11.58 -#include <l4/mag-gfx/gfx_colors>
11.59 -#include <l4/mag-gfx/mem_factory>
11.60 -
11.61 -#include <stdint.h>
11.62 -#include <string.h>
11.63 -
11.64 -/* Video abstractions. */
11.65 -
11.66 -static l4re_util_video_goos_fb_t gfb;
11.67 -static l4re_video_view_info_t view_info;
11.68 -static void *fb = 0;
11.69 -
11.70 -/* Bundled font data. */
11.71 -
11.72 -extern char const _binary_unifont_tff_start[];
11.73 -
11.74 -/* Screen abstractions. */
11.75 -
11.76 -using namespace Mag_gfx;
11.77 -
11.78 -static Font *_font = 0;
11.79 -static Canvas *_screen = 0;
11.80 -
11.81 -
11.82 -
11.83 -/* Factories for certain pixel formats. */
11.84 -
11.85 -static Mem::Factory<Rgb16> _rgb16;
11.86 -static Mem::Factory<Rgb32> _rgb32;
11.87 -
11.88 -
11.89 -
11.90 -/* Key to character conversion function. */
11.91 -
11.92 -static const char *keys_to_strings[] = {
11.93 -
11.94 - 0, "Escape", "1", "2", "3", "4", "5", "6", "7", "8",
11.95 -
11.96 - "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R",
11.97 -
11.98 - "T", "Y", "U", "I", "O", "P", "[", "]", "Enter", "Left Ctrl",
11.99 -
11.100 - "A", "S", "D", "F", "G", "H", "J", "K", "L", ";",
11.101 -
11.102 - "'", "`", "Left Shift", "\\", "Z", "X", "C", "V", "B", "N",
11.103 -
11.104 - "M", ",", ".", "/", "Right Shift", "Keypad *", "Left Alt", "Space",
11.105 - "Caps Lock", "F1",
11.106 -
11.107 - "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "Num Lock",
11.108 -
11.109 - "Scroll Lock", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad -", "Keypad 4",
11.110 - "Keypad 5", "Keypad 6", "Keypad +", "Keypad 1",
11.111 -
11.112 - "Keypad 2", "Keypad 3", "Keypad 0", "Keypad .", 0, 0, "#102", "F11", "F12", 0,
11.113 -
11.114 - 0, 0, 0, 0, 0, 0, "Keypad Enter", "Right Ctrl", "Keypad /", "SysRq",
11.115 -
11.116 - "Right Alt", "Line Feed", "Home", "Up", "Page Up", "Left", "Right", "End",
11.117 - "Down", "Page Down",
11.118 -
11.119 - "Insert", "Delete", "Macro", "Mute", "Volume Down", "Volume Up", "Power",
11.120 - "Keypad =", "Keypad +-", "Pause",
11.121 -};
11.122 -
11.123 -static const char null_string[] = "Unknown";
11.124 -
11.125 -const int keys_to_strings_length = 120;
11.126 -
11.127 -static const char *key_to_string(int key)
11.128 -{
11.129 - return key < keys_to_strings_length ? keys_to_strings[key] : 0;
11.130 -}
11.131 -
11.132 -/* Show the keypad event status on the display. */
11.133 -
11.134 -static uint8_t row = 0;
11.135 -static uint32_t text_x = 0, text_y = 0, next_y = 0;
11.136 -
11.137 -static void handler(Input_event event, void *priv)
11.138 -{
11.139 - uint32_t colsize = view_info.width / 10,
11.140 - rowsize = view_info.height / 20;
11.141 - uint8_t column;
11.142 - uint16_t mask;
11.143 -
11.144 - /* Convert the key code into a bit pattern. */
11.145 -
11.146 - if (!priv)
11.147 - {
11.148 - for (column = 0, mask = (1 << 9); column < 10; column++, mask >>= 1)
11.149 - _screen->draw_box(Rect(Point(column * colsize, row * rowsize), Area(colsize, rowsize)),
11.150 - event.code & mask ? event.value ? Rgb32::Color(0, 255, 0) : Rgb32::Color(255, 0, 0)
11.151 - : Rgb32::Color(0, 0, 0));
11.152 -
11.153 - /* Advance to the next row, wrapping around. */
11.154 -
11.155 - row = (row + 1) % 20;
11.156 - }
11.157 -
11.158 - /* Or produce a string. */
11.159 -
11.160 - else if (event.value)
11.161 - {
11.162 - const char *s = ((const char *(*)(int)) priv)(event.code);
11.163 - Rgba32::Color col;
11.164 -
11.165 - if (!s)
11.166 - {
11.167 - s = null_string;
11.168 - col = Rgba32::Color(255, 0, 0, Rgba32::Color::Amax);
11.169 - }
11.170 - else
11.171 - col = Rgba32::Color(255, 255, 255, Rgba32::Color::Amax);
11.172 -
11.173 - Area box = _font->str_sz(s, strlen(s));
11.174 -
11.175 - /* Test for enough space horizontally. */
11.176 -
11.177 - if (text_x + box.w() > view_info.width)
11.178 - {
11.179 - text_x = 0;
11.180 - text_y = next_y;
11.181 - next_y = text_y + box.h();
11.182 - }
11.183 -
11.184 - /* Expand the line height, if appropriate. */
11.185 -
11.186 - else if (text_y + box.h() > next_y)
11.187 - next_y += box.h();
11.188 -
11.189 - /* Test for enough space vertically. */
11.190 -
11.191 - if (next_y > view_info.height)
11.192 - {
11.193 - text_x = 0;
11.194 - text_y = 0;
11.195 - next_y = box.h();
11.196 - }
11.197 -
11.198 - Point p(text_x, text_y);
11.199 -
11.200 - _screen->draw_box(Rect(p, box), Rgb32::Color(0, 0, 0));
11.201 - _screen->draw_string(p, _font, col, s, strlen(s));
11.202 -
11.203 - /* Move to the next position. */
11.204 -
11.205 - text_x += box.w();
11.206 - }
11.207 -
11.208 - /* Refresh the display. */
11.209 -
11.210 - l4re_util_video_goos_fb_refresh(&gfb, 0, 0, view_info.width, view_info.height);
11.211 -}
11.212 -
11.213 -/* Arguments: [ chars ] */
11.214 -
11.215 -int main(int argc, char *argv[])
11.216 -{
11.217 - Keypad *keypad = Keypad::get_keypad();
11.218 - Input_keypad_client client(keypad);
11.219 -
11.220 - if (l4re_util_video_goos_fb_setup_name(&gfb, "fb"))
11.221 - return 1;
11.222 -
11.223 - if (l4re_util_video_goos_fb_view_info(&gfb, &view_info))
11.224 - return 1;
11.225 -
11.226 - if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb)))
11.227 - return 1;
11.228 -
11.229 - /* Obtain a canvas for the framebuffer. */
11.230 -
11.231 - Factory *factory;
11.232 -
11.233 - if (view_info.pixel_info.bytes_per_pixel == 2)
11.234 - factory = &_rgb16;
11.235 - else
11.236 - factory = &_rgb32;
11.237 -
11.238 - Canvas *screen = factory->create_canvas((void *) ((unsigned long) fb + view_info.buffer_offset),
11.239 - Area(view_info.width, view_info.height),
11.240 - view_info.bytes_per_line);
11.241 -
11.242 - Font font(&_binary_unifont_tff_start[0]);
11.243 -
11.244 - _screen = screen;
11.245 - _font = &font;
11.246 -
11.247 - /* Attach the event handler and wait for events. */
11.248 -
11.249 - client.attach(handler, (argc > 1) && (!strcmp(argv[1], "chars")) ? (void *) key_to_string : 0);
11.250 -
11.251 - l4_sleep_forever();
11.252 -
11.253 - return 0;
11.254 -}
12.1 Binary file pkg/landfall-examples/qi_lb60_keypad_driver/unifont.tff has changed