Commit 3b5f6f5001d0f3dfde98ccc6b9350fe74dac41f8
1 parent
ba42034267
Exists in
v2017.01-smarct4x
and in
30 other branches
input: Allow updating of keyboard LEDs
Add a function which returns a new keyboard LED value when the LEDs need updating. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Showing 2 changed files with 22 additions and 1 deletions Side-by-side Diff
drivers/input/input.c
... | ... | @@ -275,6 +275,7 @@ |
275 | 275 | if (config->flags & FLAG_SCROLL_LOCK) |
276 | 276 | leds |= INPUT_LED_SCROLL; |
277 | 277 | config->leds = leds; |
278 | + config->leds_changed = flip; | |
278 | 279 | } |
279 | 280 | } |
280 | 281 | |
... | ... | @@ -584,6 +585,14 @@ |
584 | 585 | void input_allow_repeats(struct input_config *config, bool allow_repeats) |
585 | 586 | { |
586 | 587 | config->allow_repeats = allow_repeats; |
588 | +} | |
589 | + | |
590 | +int input_leds_changed(struct input_config *config) | |
591 | +{ | |
592 | + if (config->leds_changed) | |
593 | + return config->leds; | |
594 | + | |
595 | + return -1; | |
587 | 596 | } |
588 | 597 | |
589 | 598 | int input_add_tables(struct input_config *config, bool german) |
include/input.h
... | ... | @@ -43,7 +43,8 @@ |
43 | 43 | /* Which modifiers are active (1 bit for each MOD_... value) */ |
44 | 44 | uchar modifiers; |
45 | 45 | uchar flags; /* active state keys (FLAGS_...) */ |
46 | - uchar leds; /* active LEDS (INPUT_LED_...) */ | |
46 | + uchar leds; /* active LEDs (INPUT_LED_...) */ | |
47 | + uchar leds_changed; /* LEDs that just changed */ | |
47 | 48 | uchar num_tables; /* number of modifier tables */ |
48 | 49 | int prev_keycodes[INPUT_BUFFER_LEN]; /* keys held last time */ |
49 | 50 | int num_prev_keycodes; /* number of prev keys */ |
... | ... | @@ -160,6 +161,17 @@ |
160 | 161 | * keyboard repeat processing with a timer. |
161 | 162 | */ |
162 | 163 | void input_allow_repeats(struct input_config *config, bool allow_repeats); |
164 | + | |
165 | +/** | |
166 | + * Check if keyboard LEDs need to be updated | |
167 | + * | |
168 | + * This can be called after input_tstc() to see if keyboard LEDs need | |
169 | + * updating. | |
170 | + * | |
171 | + * @param config Input state | |
172 | + * @return -1 if no LEDs need updating, other value if they do | |
173 | + */ | |
174 | +int input_leds_changed(struct input_config *config); | |
163 | 175 | |
164 | 176 | /** |
165 | 177 | * Set up the key map tables |