HID: asus: support Republic of Gamers special keys
authorChris Chiu <chiu@endlessm.com>
Wed, 1 Mar 2017 21:48:51 +0000 (15:48 -0600)
committerJiri Kosina <jkosina@suse.cz>
Thu, 30 Mar 2017 09:16:53 +0000 (11:16 +0200)
Add support for the special keys found on the internal keyboard of the
Asus Republic of Gamers (ROG) laptop models GL553VD, GL553VE, GL753VD
and GL753VE.

Signed-off-by: Chris Chiu <chiu@endlessm.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/Kconfig
drivers/hid/hid-asus.c
drivers/hid/hid-core.c
drivers/hid/hid-ids.h

index b22bcefd5e854ab5eed8f473d933a5918323d629..de4ed3752a4edb231cf61ef4b0d98a165da9aaa7 100644 (file)
@@ -137,11 +137,14 @@ config HID_APPLEIR
 config HID_ASUS
        tristate "Asus"
        ---help---
-       Support for Asus notebook built-in keyboard and touchpad via i2c.
+       Support for Asus notebook built-in keyboard and touchpad via i2c, and
+       the Asus Republic of Gamers laptop keyboard special keys.
 
        Supported devices:
        - EeeBook X205TA
        - VivoBook E200HA
+       - GL553V series
+       - GL753V series
 
 config HID_AUREAL
        tristate "Aureal"
index 70b12f89a193dc369273cea5565bf804a78cc50a..5bae6ffcae947ceaa784b726ab9271319b820471 100644 (file)
@@ -199,6 +199,8 @@ static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
        return 0;
 }
 
+#define rog_map_key_clear(c)   hid_map_usage_clear(hi, usage, bit, \
+                                                   max, EV_KEY, (c))
 static int asus_input_mapping(struct hid_device *hdev,
                struct hid_input *hi, struct hid_field *field,
                struct hid_usage *usage, unsigned long **bit,
@@ -213,6 +215,38 @@ static int asus_input_mapping(struct hid_device *hdev,
                return -1;
        }
 
+       /* ASUS Republic of Gamers laptop keyboard hotkeys */
+       if ((usage->hid & HID_USAGE_PAGE) == 0xff310000) {
+               set_bit(EV_REP, hi->input->evbit);
+               switch (usage->hid & HID_USAGE) {
+               case 0x10: rog_map_key_clear(KEY_BRIGHTNESSDOWN);       break;
+               case 0x20: rog_map_key_clear(KEY_BRIGHTNESSUP);         break;
+               case 0x35: rog_map_key_clear(KEY_DISPLAY_OFF);          break;
+               case 0x6c: rog_map_key_clear(KEY_SLEEP);                break;
+               case 0x82: rog_map_key_clear(KEY_CAMERA);               break;
+               case 0x88: rog_map_key_clear(KEY_WLAN);                 break;
+               case 0xb5: rog_map_key_clear(KEY_CALC);                 break;
+               case 0xc4: rog_map_key_clear(KEY_KBDILLUMUP);           break;
+               case 0xc5: rog_map_key_clear(KEY_KBDILLUMDOWN);         break;
+
+               /* ASUS touchpad toggle */
+               case 0x6b: rog_map_key_clear(KEY_F21);                  break;
+
+               /* ROG key */
+               case 0x38: rog_map_key_clear(KEY_PROG1);                break;
+
+               /* Fn+C ASUS Splendid */
+               case 0xba: rog_map_key_clear(KEY_PROG2);                break;
+
+               /* Fn+Space Power4Gear Hybrid */
+               case 0x5c: rog_map_key_clear(KEY_PROG3);                break;
+
+               default:
+                       return 0;
+               }
+               return 1;
+       }
+
        return 0;
 }
 
@@ -323,6 +357,10 @@ static const struct hid_device_id asus_devices[] = {
                 USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD), KEYBOARD_QUIRKS},
        { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
                         USB_DEVICE_ID_ASUSTEK_TOUCHPAD), TOUCHPAD_QUIRKS },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
+               USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
+               USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2) },
        { }
 };
 MODULE_DEVICE_TABLE(hid, asus_devices);
index 3ceb4a2af381f03d7f51b40cfe4d262be774de48..5408bce3428beb53728e7db08b077cf5b3c11359 100644 (file)
@@ -1854,6 +1854,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_TOUCHPAD) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) },
        { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
        { HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185BFM, 0x2208) },
index 0e2e7c571d2261a148baec5bcddeb5cc7aa75e56..ae4e90f166d3d368f7b0223fe79ea1f0c59d242a 100644 (file)
 #define USB_DEVICE_ID_ASUSTEK_LCM2     0x175b
 #define USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD        0x8585
 #define USB_DEVICE_ID_ASUSTEK_TOUCHPAD 0x0101
+#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854
+#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2 0x1837
 
 #define USB_VENDOR_ID_ATEN             0x0557
 #define USB_DEVICE_ID_ATEN_UC100KM     0x2004