diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-08-20 09:11:47 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-03 08:50:41 -0700 |
commit | 82a7fa7eab7a055671aab75191ff960060948b8d (patch) | |
tree | ede342bc0b53cb1db1e45a534896d850d87b3e45 | |
parent | 9cb48c2c876b5b327e132f5d38d66c6308238793 (diff) | |
download | chrome-ec-82a7fa7eab7a055671aab75191ff960060948b8d.tar.gz |
usb_hid_keyboard: Keep tablet mode status when clearing report
On boot, keyboard scanning will get disabled/enabled due to the
USB interface being initialized, which will accidentally clear
the tablet mode switch: make sure to report that bit in the report.
BRANCH=none
BUG=b:73133611
TEST=Connect whisksers in tablet mode, check using usbmon and evtest
that the keyboard keeps reporting tablet mode event.
Change-Id: I3f3ed7cbb22887b84bf9a5375c7def0a51c5533c
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1180640
Reviewed-by: Wei-Han Chen <stimim@chromium.org>
-rw-r--r-- | chip/stm32/usb_hid_keyboard.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c index 11cc42974c..efc02b48a4 100644 --- a/chip/stm32/usb_hid_keyboard.c +++ b/chip/stm32/usb_hid_keyboard.c @@ -478,6 +478,11 @@ void keyboard_clear_buffer(void) mutex_unlock(&key_queue_mutex); memset(&report, 0, sizeof(report)); +#ifdef CONFIG_KEYBOARD_TABLET_MODE_SWITCH + if (tablet_get_mode()) + report.extra |= 0x01 << (HID_KEYBOARD_TABLET_MODE_SWITCH - + HID_KEYBOARD_EXTRA_LOW); +#endif write_keyboard_report(); } @@ -614,11 +619,15 @@ static void queue_keycode_event(uint8_t keycode, int is_pressed) } #ifdef CONFIG_KEYBOARD_TABLET_MODE_SWITCH +#include "console.h" + static void tablet_mode_change(void) { queue_keycode_event(HID_KEYBOARD_TABLET_MODE_SWITCH, tablet_get_mode()); } DECLARE_HOOK(HOOK_TABLET_MODE_CHANGE, tablet_mode_change, HOOK_PRIO_DEFAULT); +/* Run after tablet_mode_init. */ +DECLARE_HOOK(HOOK_INIT, tablet_mode_change, HOOK_PRIO_DEFAULT+1); #endif void keyboard_state_changed(int row, int col, int is_pressed) |