# HG changeset patch # User Paul Boddie # Date 1526656907 -7200 # Node ID eb63a4d93293eda22cb996cb85e0e2c6539984e1 # Parent 3c3d4b58b1967cb498733ce3ee1e520ce0409d1e Removed obsolete keypad driver library examples. diff -r 3c3d4b58b196 -r eb63a4d93293 conf/landfall-examples/mips-letux400-keypad-driver.cfg --- a/conf/landfall-examples/mips-letux400-keypad-driver.cfg Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ --- vim: ft=lua ts=2 et sw=2 - --- Start Mag to multiplex the framebuffer showing only a single program. --- This example shows the key values produced by the keypad input driver. --- The target platform is the Letux 400 notebook computer. - -local L4 = require("L4"); - -local l = L4.default_loader; - --- Define general access to peripherals. - -local io_buses = { - cpm = l:new_channel(); - gpio = l:new_channel(); - lcd = l:new_channel(); - pwm = l:new_channel(); -- exposes GPIO, PWM - }; - -l:start({ - caps = { - cpm = io_buses.cpm:svr(), - gpio = io_buses.gpio:svr(), - lcd = io_buses.lcd:svr(), - pwm = io_buses.pwm:svr(), - - icu = L4.Env.icu, - sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), - }, - }, - "rom/io rom/hw_devices.io rom/mips-letux400-keypad-driver.io"); - --- Expose a PWM peripheral as a device. - -local pwm = l:new_channel(); - -l:startv({ - caps = { - vbus = io_buses.pwm, - pwm = pwm:svr(), - }, - }, - "rom/dev_pwm_jz4730", "0", "250", "299", "47"); -- specifying peripheral number, parameters - --- Expose a PWM backlight device. - -local backlight = l:new_channel(); -- exposes backlight device - -l:startv({ - caps = { - pwm = pwm, - backlight = backlight:svr(), - }, - }, - "rom/dev_backlight_pwm", "0", "300"); -- specifying limits - --- Expose a display device for the Letux. - -local display = l:new_channel(); -- exposes display device - -l:start({ - caps = { - backlight = backlight, - display = display:svr(), - vbus = io_buses.gpio, - }, - }, - "rom/dev_display_letux400"); - --- Expose a panel definition for the Letux. - -local panel = l:new_channel(); -- exposes panel - -l:start({ - caps = { - panel = panel:svr(), - }, - }, - "rom/dev_panel_letux400"); - --- Expose the CPM peripheral. - -local cpm = l:new_channel(); - -l:start({ - caps = { - vbus = io_buses.cpm, - cpm = cpm:svr(), - }, - }, - "rom/dev_cpm_jz4730"); - --- Expose a framebuffer device. - -local fbdrv_fb = l:new_channel(); - -l:start({ - caps = { - vbus = io_buses.lcd, - fb = fbdrv_fb:svr(), - cpm = cpm, - display = display, -- needed by LCD driver - panel = panel, - }, - }, - "rom/fb-drv"); - --- Multiplex the framebuffer. - -local mag_caps = { - mag = l:new_channel(), - svc = l:new_channel(), - }; - -l:start({ - caps = { - vbus = io_buses.gpio, -- needed by input driver - fb = fbdrv_fb, - mag = mag_caps.mag:svr(), - svc = mag_caps.svc:svr(), - }, - }, - "rom/mag"); - --- Expose the keypad matrix. - -local keypad = l:new_channel(); - -l:start({ - caps = { - vbus = io_buses.gpio, - keypad = keypad:svr(), - }, - }, - "rom/dev_keypad_letux400"); - --- Show key event values. - -l:start({ - caps = { - fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"), - keypad = keypad, - }, - }, - "rom/ex_letux400_keypad_driver"); diff -r 3c3d4b58b196 -r eb63a4d93293 conf/landfall-examples/mips-letux400-keypad-driver.io --- a/conf/landfall-examples/mips-letux400-keypad-driver.io Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ --- vim: ft=lua ts=2 et sw=2 - --- Configuration file for Io. - -local hw = Io.system_bus() - -Io.add_vbus("cpm", Io.Vi.System_bus -{ - CPM = wrap(hw:match("jz4730-cpm")); -}) - -Io.add_vbus("gpio", Io.Vi.System_bus -{ - GPIO = wrap(hw:match("jz4730-gpio")); -}) - -Io.add_vbus("lcd", Io.Vi.System_bus -{ - LCD = wrap(hw:match("jz4740-lcd")); -}) - -Io.add_vbus("pwm", Io.Vi.System_bus -{ - GPIO = wrap(hw:match("jz4730-gpio")); - PWM = wrap(hw:match("jz4730-pwm")); -}) diff -r 3c3d4b58b196 -r eb63a4d93293 conf/landfall-examples/mips-letux400-keypad-driver.list --- a/conf/landfall-examples/mips-letux400-keypad-driver.list Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - -modaddr 0x1100000 - -entry mips-letux400-keypad-driver-example -bootstrap bootstrap -serial -kernel fiasco -serial_esc -roottask moe rom/mips-letux400-keypad-driver.cfg -module mips-letux400-keypad-driver.cfg -module mips-letux400-keypad-driver.io -module plat-letux400/hw_devices.io -module l4re -module io -module ned -module fb-drv -module mag -module dev_pwm_jz4730 -module dev_backlight_pwm -module dev_display_letux400 -module dev_panel_letux400 -module dev_cpm_jz4730 -module dev_keypad_letux400 -module ex_letux400_keypad_driver diff -r 3c3d4b58b196 -r eb63a4d93293 conf/landfall-examples/mips-qi_lb60-keypad-driver.cfg --- a/conf/landfall-examples/mips-qi_lb60-keypad-driver.cfg Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ --- vim: ft=lua ts=2 et sw=2 - --- Start Mag to multiplex the framebuffer showing only a single program. --- This example shows the key values produced by the keypad input driver. --- The target platform is the Ben NanoNote. - -local L4 = require("L4"); - -local l = L4.default_loader; - --- Define general access to peripherals. - -local io_buses = { - cpm = l:new_channel(); - gpio = l:new_channel(); - lcd = l:new_channel(); - }; - -l:start({ - caps = { - cpm = io_buses.cpm:svr(), - gpio = io_buses.gpio:svr(), - lcd = io_buses.lcd:svr(), - - icu = L4.Env.icu, - sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), - }, - }, - "rom/io rom/hw_devices.io rom/mips-qi_lb60-keypad-driver.io"); - --- Expose a SPI peripheral as a device. - -local spi = l:new_channel(); - -l:startv({ - caps = { - vbus = io_buses.gpio, - spi = spi:svr(), - }, - }, - "rom/dev_spi_jz4740", "C23", "C22", "C21"); -- specifying clock, data, enable pin details - --- Expose a SPI backlight device for the Ben. - -local backlight = l:new_channel(); -- exposes backlight device - -l:start({ - caps = { - spi = spi, - backlight = backlight:svr(), - }, - }, - "rom/dev_backlight_spi_qi_lb60"); - --- Expose a display device for the Ben. - -local display = l:new_channel(); -- exposes display device - -l:start({ - caps = { - backlight = backlight, - display = display:svr(), - vbus = io_buses.gpio, - }, - }, - "rom/dev_display_qi_lb60"); - --- Expose a panel definition for the Ben. - -local panel = l:new_channel(); -- exposes panel - -l:start({ - caps = { - panel = panel:svr(), - }, - }, - "rom/dev_panel_qi_lb60"); - --- Expose the CPM peripheral. - -local cpm = l:new_channel(); - -l:start({ - caps = { - vbus = io_buses.cpm, - cpm = cpm:svr(), - }, - }, - "rom/dev_cpm_jz4740"); - --- Expose a framebuffer device. - -local fbdrv_fb = l:new_channel(); - -l:start({ - caps = { - vbus = io_buses.lcd, - fb = fbdrv_fb:svr(), - cpm = cpm, - display = display, -- needed by LCD driver - panel = panel, - }, - }, - "rom/fb-drv"); - --- Multiplex the framebuffer. - -local mag_caps = { - mag = l:new_channel(), - svc = l:new_channel(), - }; - -l:start({ - caps = { - vbus = io_buses.gpio, -- needed by input driver - fb = fbdrv_fb, - mag = mag_caps.mag:svr(), - svc = mag_caps.svc:svr(), - }, - }, - "rom/mag"); - --- Expose the keypad matrix. - -local keypad = l:new_channel(); - -l:start({ - caps = { - vbus = io_buses.gpio, - keypad = keypad:svr(), - }, - }, - "rom/dev_keypad_qi_lb60"); - --- Show key event values. - -l:startv({ - caps = { - fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"), - keypad = keypad, - }, - }, - "rom/ex_qi_lb60_keypad_driver"); diff -r 3c3d4b58b196 -r eb63a4d93293 conf/landfall-examples/mips-qi_lb60-keypad-driver.io --- a/conf/landfall-examples/mips-qi_lb60-keypad-driver.io Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ --- vim: ft=lua ts=2 et sw=2 - --- Configuration file for Io. - -local hw = Io.system_bus() - -Io.add_vbus("cpm", Io.Vi.System_bus -{ - CPM = wrap(hw:match("jz4740-cpm")); -}) - -Io.add_vbus("gpio", Io.Vi.System_bus -{ - GPIO = wrap(hw:match("jz4740-gpio")); -}) - -Io.add_vbus("lcd", Io.Vi.System_bus -{ - LCD = wrap(hw:match("jz4740-lcd")); -}) diff -r 3c3d4b58b196 -r eb63a4d93293 conf/landfall-examples/mips-qi_lb60-keypad-driver.list --- a/conf/landfall-examples/mips-qi_lb60-keypad-driver.list Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - -modaddr 0x1100000 - -entry mips-qi_lb60-keypad-driver-example -bootstrap bootstrap -serial -kernel fiasco -serial_esc -roottask moe rom/mips-qi_lb60-keypad-driver.cfg -module mips-qi_lb60-keypad-driver.cfg -module mips-qi_lb60-keypad-driver.io -module plat-qi_lb60/hw_devices.io -module l4re -module io -module ned -module fb-drv -module mag -module dev_spi_jz4740 -module dev_backlight_spi_qi_lb60 -module dev_display_qi_lb60 -module dev_panel_qi_lb60 -module dev_cpm_jz4740 -module dev_keypad_qi_lb60 -module ex_qi_lb60_keypad_driver diff -r 3c3d4b58b196 -r eb63a4d93293 pkg/landfall-examples/letux400_keypad_driver/Makefile --- a/pkg/landfall-examples/letux400_keypad_driver/Makefile Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -PKGDIR ?= .. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = ex_letux400_keypad_driver -SRC_CC = letux400_keypad_driver.cc -SRC_DATA = unifont.tff -REQUIRES_LIBS = libio l4re_c-util libdevice-input-keypad libdrivers-keypad-letux400 mag-gfx - -include $(L4DIR)/mk/prog.mk diff -r 3c3d4b58b196 -r eb63a4d93293 pkg/landfall-examples/letux400_keypad_driver/letux400_keypad_driver.cc --- a/pkg/landfall-examples/letux400_keypad_driver/letux400_keypad_driver.cc Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,251 +0,0 @@ -/* - * Access the keypad on the configured device using an input driver. - * - * (c) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - * - * Font definitions and licence (see unifont.tff for bitmap data derived from - * GNU Unifont's unifont.hex file): - * - * Copyright (C) 1998-2003 Roman Czyborra (http://czyborra.com/) - * - * All glyphs are released under the GNU General Public License - * (GPL) version 2 or (at your option) a later version, with the - * GNU font embedding exception: - * - * ** GPL v2.0 license with font embedding exception: - * - * As a special exception, if you create a document which - * uses this font, and embed this font or unaltered portions - * of this font into the document, this font does not by - * itself cause the resulting document to be covered by - * the GNU General Public License. This exception does not - * however invalidate any other reasons why the document - * might be covered by the GNU General Public License. - * If you modify this font, you may extend this exception - * to your version of the font, but you are not obligated - * to do so. If you do not wish to do so, delete this - * exception statement from your version. - */ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -/* Video abstractions. */ - -static l4re_util_video_goos_fb_t gfb; -static l4re_video_view_info_t view_info; -static void *fb = 0; - -/* Bundled font data. */ - -extern char const _binary_unifont_tff_start[]; - -/* Screen abstractions. */ - -using namespace Mag_gfx; - -static Font *_font = 0; -static Canvas *_screen = 0; - - - -/* Factories for certain pixel formats. */ - -static Mem::Factory _rgb16; -static Mem::Factory _rgb32; - - - -/* Key to character conversion function. */ - -static const char *keys_to_strings[] = { - - 0, "Escape", "1", "2", "3", "4", "5", "6", "7", "8", - - "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R", - - "T", "Y", "U", "I", "O", "P", "[", "]", "Enter", "Left Ctrl", - - "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", - - "'", "`", "Left Shift", "\\", "Z", "X", "C", "V", "B", "N", - - "M", ",", ".", "/", "Right Shift", "Keypad *", "Left Alt", "Space", - "Caps Lock", "F1", - - "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "Num Lock", - - "Scroll Lock", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad -", "Keypad 4", - "Keypad 5", "Keypad 6", "Keypad +", "Keypad 1", - - "Keypad 2", "Keypad 3", "Keypad 0", "Keypad .", 0, 0, "#102", "F11", "F12", 0, - - 0, 0, 0, 0, 0, 0, "Keypad Enter", "Right Ctrl", "Keypad /", "SysRq", - - "Right Alt", "Line Feed", "Home", "Up", "Page Up", "Left", "Right", "End", - "Down", "Page Down", - - "Insert", "Delete", "Macro", "Mute", "Volume Down", "Volume Up", "Power", - "Keypad =", "Keypad +-", "Pause", -}; - -static const char null_string[] = "Unknown"; - -const int keys_to_strings_length = 120; - -static const char *key_to_string(int key) -{ - return key < keys_to_strings_length ? keys_to_strings[key] : 0; -} - -/* Show the keypad event status on the display. */ - -static uint8_t row = 0; -static uint32_t text_x = 0, text_y = 0, next_y = 0; - -static void handler(Input_event event, void *priv) -{ - uint32_t colsize = view_info.width / 10, - rowsize = view_info.height / 20; - uint8_t column; - uint16_t mask; - - /* Convert the key code into a bit pattern. */ - - if (!priv) - { - for (column = 0, mask = (1 << 9); column < 10; column++, mask >>= 1) - _screen->draw_box(Rect(Point(column * colsize, row * rowsize), Area(colsize, rowsize)), - event.code & mask ? event.value ? Rgb32::Color(0, 255, 0) : Rgb32::Color(255, 0, 0) - : Rgb32::Color(0, 0, 0)); - - /* Advance to the next row, wrapping around. */ - - row = (row + 1) % 20; - } - - /* Or produce a string. */ - - else if (event.value) - { - const char *s = ((const char *(*)(int)) priv)(event.code); - Rgba32::Color col; - - if (!s) - { - s = null_string; - col = Rgba32::Color(255, 0, 0, Rgba32::Color::Amax); - } - else - col = Rgba32::Color(255, 255, 255, Rgba32::Color::Amax); - - Area box = _font->str_sz(s, strlen(s)); - - /* Test for enough space horizontally. */ - - if (text_x + box.w() > view_info.width) - { - text_x = 0; - text_y = next_y; - next_y = text_y + box.h(); - } - - /* Expand the line height, if appropriate. */ - - else if (text_y + box.h() > next_y) - next_y += box.h(); - - /* Test for enough space vertically. */ - - if (next_y > view_info.height) - { - text_x = 0; - text_y = 0; - next_y = box.h(); - } - - Point p(text_x, text_y); - - _screen->draw_box(Rect(p, box), Rgb32::Color(0, 0, 0)); - _screen->draw_string(p, _font, col, s, strlen(s)); - - /* Move to the next position. */ - - text_x += box.w(); - } - - /* Refresh the display. */ - - l4re_util_video_goos_fb_refresh(&gfb, 0, 0, view_info.width, view_info.height); -} - -/* Arguments: [ chars ] */ - -int main(int argc, char *argv[]) -{ - Keypad *keypad = Keypad::get_keypad(); - Input_keypad_client client(keypad); - - if (l4re_util_video_goos_fb_setup_name(&gfb, "fb")) - return 1; - - if (l4re_util_video_goos_fb_view_info(&gfb, &view_info)) - return 1; - - if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) - return 1; - - /* Obtain a canvas for the framebuffer. */ - - Factory *factory; - - if (view_info.pixel_info.bytes_per_pixel == 2) - factory = &_rgb16; - else - factory = &_rgb32; - - Canvas *screen = factory->create_canvas((void *) ((unsigned long) fb + view_info.buffer_offset), - Area(view_info.width, view_info.height), - view_info.bytes_per_line); - - Font font(&_binary_unifont_tff_start[0]); - - _screen = screen; - _font = &font; - - /* Attach the event handler and wait for events. */ - - client.attach(handler, (argc > 1) && (!strcmp(argv[1], "chars")) ? (void *) key_to_string : 0); - - l4_sleep_forever(); - - return 0; -} diff -r 3c3d4b58b196 -r eb63a4d93293 pkg/landfall-examples/letux400_keypad_driver/unifont.tff Binary file pkg/landfall-examples/letux400_keypad_driver/unifont.tff has changed diff -r 3c3d4b58b196 -r eb63a4d93293 pkg/landfall-examples/qi_lb60_keypad_driver/Makefile --- a/pkg/landfall-examples/qi_lb60_keypad_driver/Makefile Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -PKGDIR ?= .. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = ex_qi_lb60_keypad_driver -SRC_CC = qi_lb60_keypad_driver.cc -SRC_DATA = unifont.tff -REQUIRES_LIBS = libio l4re_c-util libdevice-input-keypad libdrivers-keypad-qi_lb60 mag-gfx - -include $(L4DIR)/mk/prog.mk diff -r 3c3d4b58b196 -r eb63a4d93293 pkg/landfall-examples/qi_lb60_keypad_driver/qi_lb60_keypad_driver.cc --- a/pkg/landfall-examples/qi_lb60_keypad_driver/qi_lb60_keypad_driver.cc Fri May 18 17:19:28 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,251 +0,0 @@ -/* - * Access the keypad on the configured device using an input driver. - * - * (c) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - * - * Font definitions and licence (see unifont.tff for bitmap data derived from - * GNU Unifont's unifont.hex file): - * - * Copyright (C) 1998-2003 Roman Czyborra (http://czyborra.com/) - * - * All glyphs are released under the GNU General Public License - * (GPL) version 2 or (at your option) a later version, with the - * GNU font embedding exception: - * - * ** GPL v2.0 license with font embedding exception: - * - * As a special exception, if you create a document which - * uses this font, and embed this font or unaltered portions - * of this font into the document, this font does not by - * itself cause the resulting document to be covered by - * the GNU General Public License. This exception does not - * however invalidate any other reasons why the document - * might be covered by the GNU General Public License. - * If you modify this font, you may extend this exception - * to your version of the font, but you are not obligated - * to do so. If you do not wish to do so, delete this - * exception statement from your version. - */ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -/* Video abstractions. */ - -static l4re_util_video_goos_fb_t gfb; -static l4re_video_view_info_t view_info; -static void *fb = 0; - -/* Bundled font data. */ - -extern char const _binary_unifont_tff_start[]; - -/* Screen abstractions. */ - -using namespace Mag_gfx; - -static Font *_font = 0; -static Canvas *_screen = 0; - - - -/* Factories for certain pixel formats. */ - -static Mem::Factory _rgb16; -static Mem::Factory _rgb32; - - - -/* Key to character conversion function. */ - -static const char *keys_to_strings[] = { - - 0, "Escape", "1", "2", "3", "4", "5", "6", "7", "8", - - "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R", - - "T", "Y", "U", "I", "O", "P", "[", "]", "Enter", "Left Ctrl", - - "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", - - "'", "`", "Left Shift", "\\", "Z", "X", "C", "V", "B", "N", - - "M", ",", ".", "/", "Right Shift", "Keypad *", "Left Alt", "Space", - "Caps Lock", "F1", - - "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "Num Lock", - - "Scroll Lock", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad -", "Keypad 4", - "Keypad 5", "Keypad 6", "Keypad +", "Keypad 1", - - "Keypad 2", "Keypad 3", "Keypad 0", "Keypad .", 0, 0, "#102", "F11", "F12", 0, - - 0, 0, 0, 0, 0, 0, "Keypad Enter", "Right Ctrl", "Keypad /", "SysRq", - - "Right Alt", "Line Feed", "Home", "Up", "Page Up", "Left", "Right", "End", - "Down", "Page Down", - - "Insert", "Delete", "Macro", "Mute", "Volume Down", "Volume Up", "Power", - "Keypad =", "Keypad +-", "Pause", -}; - -static const char null_string[] = "Unknown"; - -const int keys_to_strings_length = 120; - -static const char *key_to_string(int key) -{ - return key < keys_to_strings_length ? keys_to_strings[key] : 0; -} - -/* Show the keypad event status on the display. */ - -static uint8_t row = 0; -static uint32_t text_x = 0, text_y = 0, next_y = 0; - -static void handler(Input_event event, void *priv) -{ - uint32_t colsize = view_info.width / 10, - rowsize = view_info.height / 20; - uint8_t column; - uint16_t mask; - - /* Convert the key code into a bit pattern. */ - - if (!priv) - { - for (column = 0, mask = (1 << 9); column < 10; column++, mask >>= 1) - _screen->draw_box(Rect(Point(column * colsize, row * rowsize), Area(colsize, rowsize)), - event.code & mask ? event.value ? Rgb32::Color(0, 255, 0) : Rgb32::Color(255, 0, 0) - : Rgb32::Color(0, 0, 0)); - - /* Advance to the next row, wrapping around. */ - - row = (row + 1) % 20; - } - - /* Or produce a string. */ - - else if (event.value) - { - const char *s = ((const char *(*)(int)) priv)(event.code); - Rgba32::Color col; - - if (!s) - { - s = null_string; - col = Rgba32::Color(255, 0, 0, Rgba32::Color::Amax); - } - else - col = Rgba32::Color(255, 255, 255, Rgba32::Color::Amax); - - Area box = _font->str_sz(s, strlen(s)); - - /* Test for enough space horizontally. */ - - if (text_x + box.w() > view_info.width) - { - text_x = 0; - text_y = next_y; - next_y = text_y + box.h(); - } - - /* Expand the line height, if appropriate. */ - - else if (text_y + box.h() > next_y) - next_y += box.h(); - - /* Test for enough space vertically. */ - - if (next_y > view_info.height) - { - text_x = 0; - text_y = 0; - next_y = box.h(); - } - - Point p(text_x, text_y); - - _screen->draw_box(Rect(p, box), Rgb32::Color(0, 0, 0)); - _screen->draw_string(p, _font, col, s, strlen(s)); - - /* Move to the next position. */ - - text_x += box.w(); - } - - /* Refresh the display. */ - - l4re_util_video_goos_fb_refresh(&gfb, 0, 0, view_info.width, view_info.height); -} - -/* Arguments: [ chars ] */ - -int main(int argc, char *argv[]) -{ - Keypad *keypad = Keypad::get_keypad(); - Input_keypad_client client(keypad); - - if (l4re_util_video_goos_fb_setup_name(&gfb, "fb")) - return 1; - - if (l4re_util_video_goos_fb_view_info(&gfb, &view_info)) - return 1; - - if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) - return 1; - - /* Obtain a canvas for the framebuffer. */ - - Factory *factory; - - if (view_info.pixel_info.bytes_per_pixel == 2) - factory = &_rgb16; - else - factory = &_rgb32; - - Canvas *screen = factory->create_canvas((void *) ((unsigned long) fb + view_info.buffer_offset), - Area(view_info.width, view_info.height), - view_info.bytes_per_line); - - Font font(&_binary_unifont_tff_start[0]); - - _screen = screen; - _font = &font; - - /* Attach the event handler and wait for events. */ - - client.attach(handler, (argc > 1) && (!strcmp(argv[1], "chars")) ? (void *) key_to_string : 0); - - l4_sleep_forever(); - - return 0; -} diff -r 3c3d4b58b196 -r eb63a4d93293 pkg/landfall-examples/qi_lb60_keypad_driver/unifont.tff Binary file pkg/landfall-examples/qi_lb60_keypad_driver/unifont.tff has changed