From: Yusuke Fujimaki <usk.fujimaki@gmail.com>
To: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org,
Yusuke Fujimaki <usk.fujimaki@gmail.com>
Subject: [PATCH] HID: asus: add support for hotkeys
Date: Thu, 12 May 2016 01:46:07 +0900 [thread overview]
Message-ID: <1462985167-8566-1-git-send-email-usk.fujimaki@gmail.com> (raw)
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@gmail.com>
---
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
next reply other threads:[~2016-05-11 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 16:46 Yusuke Fujimaki [this message]
2016-05-11 22:07 ` [PATCH] HID: asus: add support for hotkeys Dmitry Torokhov
2016-05-12 18:10 ` Yusuke FUJIMAKI
2016-05-12 20:28 ` Jiri Kosina
2016-05-17 18:01 ` Yusuke FUJIMAKI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462985167-8566-1-git-send-email-usk.fujimaki@gmail.com \
--to=usk.fujimaki@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).