[PATCH] HID: asus: add support for hotkeys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Asus X205TA and E200HA keyboard hotkeys (excluding volume control) sends vendor specific usage id.
This patch add input mapping to support such hotkeys.

Signed-off-by: Yusuke Fujimaki <usk.fujimaki@xxxxxxxxx>
---
 drivers/hid/hid-asus.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 7a811ec..a71f90c 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -26,6 +26,10 @@
 
 #include "hid-ids.h"
 
+#define HID_UP_ASUSVENDOR	0xff310000
+#define asus_map_key_clear(c)	hid_map_usage_clear(hi, usage, bit, max, \
+					EV_KEY, (c))
+
 static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 		unsigned int *rsize)
 {
@@ -36,6 +40,26 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
+static int asus_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+		struct hid_field *field, struct hid_usage *usage,
+		unsigned long **bit, int *max)
+{
+	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_ASUSVENDOR)
+		return 0;
+
+	switch (usage->hid & HID_USAGE) {
+	case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN);	break;
+	case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP);	break;
+	case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF);		break;
+	case 0x6b: asus_map_key_clear(KEY_TOUCHPAD_TOGGLE);	break;
+	case 0x6c: asus_map_key_clear(KEY_SLEEP);		break;
+	case 0x88: asus_map_key_clear(KEY_RFKILL);		break;
+	default:
+		return 0;
+	}
+	return 1;
+}
+
 static const struct hid_device_id asus_devices[] = {
 	{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) },
 	{ }
@@ -45,6 +69,7 @@ MODULE_DEVICE_TABLE(hid, asus_devices);
 static struct hid_driver asus_driver = {
 	.name = "asus",
 	.id_table = asus_devices,
+	.input_mapping = asus_input_mapping,
 	.report_fixup = asus_report_fixup
 };
 module_hid_driver(asus_driver);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux