X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Finput%2Finput.c;h=29620a9e2793b5d318bafc9d67d77ef734698ef8;hb=a8ca5c8adb3efe892982389aae8b2a234939a588;hp=5de8d9d005d8b5ee0709bf5eb8b9a297a594fcf8;hpb=ba42034267050d1a41479ba133d1c5b8679397f7;p=u-boot diff --git a/drivers/input/input.c b/drivers/input/input.c index 5de8d9d005..29620a9e27 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1,23 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Translate key codes into ASCII * * Copyright (c) 2011 The Chromium OS Authors. * (C) Copyright 2004 DENX Software Engineering, Wolfgang Denk, wd@denx.de - * - * SPDX-License-Identifier: GPL-2.0+ */ #include +#include +#include #include #include #include +#ifdef CONFIG_DM_KEYBOARD +#include +#endif #include enum { /* These correspond to the lights on the keyboard */ - FLAG_NUM_LOCK = 1 << 0, - FLAG_CAPS_LOCK = 1 << 1, - FLAG_SCROLL_LOCK = 1 << 2, + FLAG_SCROLL_LOCK = 1 << 0, + FLAG_NUM_LOCK = 1 << 1, + FLAG_CAPS_LOCK = 1 << 2, /* Special flag ORed with key code to indicate release */ KEY_RELEASE = 1 << 15, @@ -78,6 +82,9 @@ static unsigned char kbd_ctrl_xlate[] = { '\r', 0xff, '/', '*', }; +/* + * German keymap. Special letters are mapped according to code page 437. + */ static const uchar kbd_plain_xlate_german[] = { 0xff, 0x1b, '1', '2', '3', '4', '5', '6', /* scan 00-07 */ '7', '8', '9', '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */ @@ -119,7 +126,7 @@ static unsigned char kbd_shift_xlate_german[] = { }; static unsigned char kbd_right_alt_xlate_german[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */ + 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */ '{', '[', ']', '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */ '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */ 0xff, 0xff, 0xff, '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */ @@ -235,6 +242,10 @@ int input_getc(struct input_config *config) static struct input_key_xlate *process_modifier(struct input_config *config, int key, int release) { +#ifdef CONFIG_DM_KEYBOARD + struct udevice *dev = config->dev; + struct keyboard_ops *ops = keyboard_get_ops(dev); +#endif struct input_key_xlate *table; int i; @@ -267,7 +278,7 @@ static struct input_key_xlate *process_modifier(struct input_config *config, if (flip != -1) { int leds = 0; - config->leds ^= flip; + config->flags ^= flip; if (config->flags & FLAG_NUM_LOCK) leds |= INPUT_LED_NUM; if (config->flags & FLAG_CAPS_LOCK) @@ -275,6 +286,14 @@ static struct input_key_xlate *process_modifier(struct input_config *config, if (config->flags & FLAG_SCROLL_LOCK) leds |= INPUT_LED_SCROLL; config->leds = leds; + config->leds_changed = flip; + +#ifdef CONFIG_DM_KEYBOARD + if (ops->update_leds) { + if (ops->update_leds(dev, config->leds)) + debug("Update keyboard's LED failed\n"); + } +#endif } } @@ -463,6 +482,12 @@ static int input_keycodes_to_ascii(struct input_config *config, if ((config->flags & FLAG_CAPS_LOCK) && ch >= 'a' && ch <= 'z') ch -= 'a' - 'A'; + /* ban digit numbers if 'Num Lock' is not on */ + if (!(config->flags & FLAG_NUM_LOCK)) { + if (key >= KEY_KP7 && key <= KEY_KPDOT && + key != KEY_KPMINUS && key != KEY_KPPLUS) + ch = 0xff; + } if (ch_count < max_chars && ch != 0xff) output_ch[ch_count++] = (uchar)ch; } else { @@ -586,6 +611,14 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats) config->allow_repeats = allow_repeats; } +int input_leds_changed(struct input_config *config) +{ + if (config->leds_changed) + return config->leds; + + return -1; +} + int input_add_tables(struct input_config *config, bool german) { struct kbd_entry *entry; @@ -621,7 +654,7 @@ int input_stdio_register(struct stdio_dev *dev) error = stdio_register(dev); /* check if this is the standard input device */ - if (!error && strcmp(getenv("stdin"), dev->name) == 0) { + if (!error && strcmp(env_get("stdin"), dev->name) == 0) { /* reassign the console */ if (OVERWRITE_CONSOLE || console_assign(stdin, dev->name))