From 13d9b8bbf8e0049c9492fc4978e743b27b637b62 Mon Sep 17 00:00:00 2001 From: Christoffer Sandberg Date: Tue, 16 Jun 2020 14:40:54 +0200 Subject: [PATCH] Add special key-combo when gauge key is pressed --- src/tuxedo_keyboard.c | 4 ---- src/uniwill_keyboard.h | 30 ++++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index 553a800..e780cba 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -67,10 +67,6 @@ static int tuxedo_input_init(const struct key_entry key_map[]) } } - // Add touchpad key event bits for manual report workaround - tuxedo_input_device->evbit[0] = BIT_MASK(EV_KEY); - tuxedo_input_device->keybit[BIT_WORD(KEY_F21)] = BIT_MASK(KEY_F21); - err = input_register_device(tuxedo_input_device); if (unlikely(err)) { TUXEDO_ERROR("Error registering input device\n"); diff --git a/src/uniwill_keyboard.h b/src/uniwill_keyboard.h index 5f48eb1..1b195a8 100644 --- a/src/uniwill_keyboard.h +++ b/src/uniwill_keyboard.h @@ -34,19 +34,30 @@ #define UNIWILL_OSD_RADIOON 0x01A #define UNIWILL_OSD_RADIOOFF 0x01B +#define UNIWILL_OSD_TOUCHPADWORKAROUND 0xFFF + struct tuxedo_keyboard_driver uniwill_keyboard_driver; static struct key_entry uniwill_wmi_keymap[] = { // { KE_KEY, UNIWILL_OSD_RADIOON, { KEY_RFKILL } }, // { KE_KEY, UNIWILL_OSD_RADIOOFF, { KEY_RFKILL } }, + // { KE_KEY, 0xb0, { KEY_F13 } }, + { KE_KEY, UNIWILL_OSD_TOUCHPADWORKAROUND, { KEY_F21 } }, + // Only used to put ev bits + { KE_KEY, 0xffff, { KEY_F6 } }, + { KE_KEY, 0xffff, { KEY_LEFTALT } }, + { KE_KEY, 0xffff, { KEY_LEFTMETA } }, { KE_END, 0 } }; static void key_event_work(struct work_struct *work) { - input_report_key(uniwill_keyboard_driver.input_device, KEY_F21, 1); - input_report_key(uniwill_keyboard_driver.input_device, KEY_F21, 0); - input_sync(uniwill_keyboard_driver.input_device); + sparse_keymap_report_known_event( + current_driver->input_device, + UNIWILL_OSD_TOUCHPADWORKAROUND, + 1, + true + ); } // Previous key codes for detecting longer combination @@ -61,7 +72,6 @@ static int keyboard_notifier_callb(struct notifier_block *nb, unsigned long code if (!param->down) { if (code == KBD_KEYCODE) { - TUXEDO_DEBUG("[%d, %d, %d]\n", prevprev_key, prev_key, param->value); switch (param->value) { case 125: // If the last keys up were 85 -> 29 -> 125 @@ -107,6 +117,18 @@ static void uniwill_wmi_handle_event(u32 value, void *context, u32 guid_nr) } } + // Special key combination when mode change key is pressed + if (code == 0xb0) { + input_report_key(current_driver->input_device, KEY_LEFTMETA, 1); + input_report_key(current_driver->input_device, KEY_LEFTALT, 1); + input_report_key(current_driver->input_device, KEY_F6, 1); + input_sync(current_driver->input_device); + input_report_key(current_driver->input_device, KEY_F6, 0); + input_report_key(current_driver->input_device, KEY_LEFTALT, 0); + input_report_key(current_driver->input_device, KEY_LEFTMETA, 0); + input_sync(current_driver->input_device); + } + kfree(obj); }