X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Finput%2Finput.c;h=011667fedda4269a26dedfa8b1f83a9486086519;hb=d37f020e6fe4af64dea7108652319e05e0d3279c;hp=a64bd87e19c6e966ccebd676035beef30ae95876;hpb=a683d0d347f2977632c5b1b0b58ca1fa894fef9c;p=oweals%2Fu-boot.git diff --git a/drivers/input/input.c b/drivers/input/input.c index a64bd87e19..011667fedd 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -8,16 +8,21 @@ */ #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, @@ -235,6 +240,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 +276,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 +284,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 } } @@ -452,16 +469,25 @@ static int input_keycodes_to_ascii(struct input_config *config, /* Start conversion by looking for the first new keycode (by same). */ for (i = same; i < num_keycodes; i++) { int key = keycode[i]; - int ch = (key < table->num_entries) ? table->xlate[key] : 0xff; + int ch; /* * For a normal key (with an ASCII value), add it; otherwise * translate special key to escape sequence if possible. */ - if (ch != 0xff) { - if (ch_count < max_chars) - output_ch[ch_count] = (uchar)ch; - ch_count++; + if (key < table->num_entries) { + ch = table->xlate[key]; + 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 { ch_count += input_keycode_to_ansi364(config, key, output_ch, max_chars); @@ -583,6 +609,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;