|
| 1 | +/* |
| 2 | + * HID driver for some Asus Gaming model equipped with "special" macrokey |
| 3 | + * devices for hotkey handling |
| 4 | + * |
| 5 | + * Currently supported devices are: |
| 6 | + * ASUS laptops for "Republic of Gamers" |
| 7 | + * GL553VD/GL553VE |
| 8 | + * GL753VD/GL753VE |
| 9 | + * |
| 10 | + * Copyright (c) 2016 Chris Chiu <chiu@endlessm.com> |
| 11 | + * |
| 12 | + * This module based on hid-gyration |
| 13 | + * |
| 14 | + */ |
| 15 | + |
| 16 | +/* |
| 17 | + * This program is free software; you can redistribute it and/or modify it |
| 18 | + * under the terms of the GNU General Public License as published by the Free |
| 19 | + * Software Foundation; either version 2 of the License, or (at your option) |
| 20 | + * any later version. |
| 21 | + */ |
| 22 | + |
| 23 | +#include <linux/device.h> |
| 24 | +#include <linux/input.h> |
| 25 | +#include <linux/hid.h> |
| 26 | +#include <linux/module.h> |
| 27 | + |
| 28 | +#include "hid-ids.h" |
| 29 | + |
| 30 | +#define asus_rog_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ |
| 31 | + max, EV_KEY, (c)) |
| 32 | +static int asus_rog_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 33 | + struct hid_field *field, struct hid_usage *usage, |
| 34 | + unsigned long **bit, int *max) |
| 35 | +{ |
| 36 | + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_ASUS_ROG_HOTKEY) |
| 37 | + return 0; |
| 38 | + |
| 39 | + set_bit(EV_REP, hi->input->evbit); |
| 40 | + switch (usage->hid & HID_USAGE) { |
| 41 | + /* Reported on ASUS Gaming model (Republic of Gamers) keyboards */ |
| 42 | + case 0x6c: asus_rog_map_key_clear(KEY_SLEEP); break; |
| 43 | + case 0x88: asus_rog_map_key_clear(KEY_WLAN); break; |
| 44 | + case 0xc5: asus_rog_map_key_clear(KEY_KBDILLUMDOWN); break; |
| 45 | + case 0xc4: asus_rog_map_key_clear(KEY_KBDILLUMUP); break; |
| 46 | + case 0x10: asus_rog_map_key_clear(KEY_BRIGHTNESSDOWN); break; |
| 47 | + case 0x20: asus_rog_map_key_clear(KEY_BRIGHTNESSUP); break; |
| 48 | + case 0x35: asus_rog_map_key_clear(KEY_DISPLAY_OFF); break; |
| 49 | + // KEY_F21 is for ASUS touchpad toggle |
| 50 | + case 0x6b: asus_rog_map_key_clear(KEY_F21); break; |
| 51 | + case 0x82: asus_rog_map_key_clear(KEY_CAMERA); break; |
| 52 | + case 0xb5: asus_rog_map_key_clear(KEY_CALC); break; |
| 53 | + // KEY_PROG1 for ROG key |
| 54 | + case 0x38: asus_rog_map_key_clear(KEY_PROG1); break; |
| 55 | + // KEY_PROG2 for Fn+C ASUS Splendid |
| 56 | + case 0xba: asus_rog_map_key_clear(KEY_PROG2); break; |
| 57 | + // KEY_PROG3 for Fn+Space Power4Gear Hybrid, may not be present |
| 58 | + case 0x5c: asus_rog_map_key_clear(KEY_PROG3); break; |
| 59 | + |
| 60 | + default: |
| 61 | + return 0; |
| 62 | + } |
| 63 | + return 1; |
| 64 | +} |
| 65 | + |
| 66 | +static const struct hid_device_id asus_rog_devices[] = { |
| 67 | + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_MACROKEY1) }, |
| 68 | + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_MACROKEY2) }, |
| 69 | + { } |
| 70 | +}; |
| 71 | +MODULE_DEVICE_TABLE(hid, asus_rog_devices); |
| 72 | + |
| 73 | +static struct hid_driver asus_rog_driver = { |
| 74 | + .name = "asus-rog", |
| 75 | + .id_table = asus_rog_devices, |
| 76 | + .input_mapping = asus_rog_input_mapping, |
| 77 | +}; |
| 78 | +module_hid_driver(asus_rog_driver); |
| 79 | + |
| 80 | +MODULE_LICENSE("GPL"); |
0 commit comments