diff mbox

HID: asus: Add missing Fn key maps on ASUS E200H

Message ID 20170327084104.18105-1-tiwai@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Iwai March 27, 2017, 8:41 a.m. UTC
The mapping of a few Fn combo keys seems missing since they are vendor
specific usage page (0xff31).  Add the mapping manually for sleep
(Fn-F1), rfkill (Fn-F2), brightness down (Fn-F5), brightness up
(Fn-F6), display toggle (Fn-F7), and touchpad toggle (Fn-F9).
For the display toggle and the touchpad toggle, KEY_SCREENLOCK and
KEY_F21 are assigned as convention.

The monitor switch (Fn-F8), and audio volume down / up /mute (Fn-F10,
F11, F12) work as is without the extra mapping, thus left as is.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/hid/hid-asus.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Jiri Kosina March 30, 2017, 9:19 a.m. UTC | #1
On Mon, 27 Mar 2017, Takashi Iwai wrote:

> The mapping of a few Fn combo keys seems missing since they are vendor
> specific usage page (0xff31).  Add the mapping manually for sleep
> (Fn-F1), rfkill (Fn-F2), brightness down (Fn-F5), brightness up
> (Fn-F6), display toggle (Fn-F7), and touchpad toggle (Fn-F9).
> For the display toggle and the touchpad toggle, KEY_SCREENLOCK and
> KEY_F21 are assigned as convention.
> 
> The monitor switch (Fn-F8), and audio volume down / up /mute (Fn-F10,
> F11, F12) work as is without the extra mapping, thus left as is.
> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

I think is has already been covered by Matjaz's (adding to CC) patches in 
hid.git#for-4.12/asus. Could you please check whether it covers everything 
your patch did?

Thanks,
Takashi Iwai March 30, 2017, 9:42 a.m. UTC | #2
On Thu, 30 Mar 2017 11:19:21 +0200,
Jiri Kosina wrote:
> 
> On Mon, 27 Mar 2017, Takashi Iwai wrote:
> 
> > The mapping of a few Fn combo keys seems missing since they are vendor
> > specific usage page (0xff31).  Add the mapping manually for sleep
> > (Fn-F1), rfkill (Fn-F2), brightness down (Fn-F5), brightness up
> > (Fn-F6), display toggle (Fn-F7), and touchpad toggle (Fn-F9).
> > For the display toggle and the touchpad toggle, KEY_SCREENLOCK and
> > KEY_F21 are assigned as convention.
> > 
> > The monitor switch (Fn-F8), and audio volume down / up /mute (Fn-F10,
> > F11, F12) work as is without the extra mapping, thus left as is.
> > 
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> I think is has already been covered by Matjaz's (adding to CC) patches in 
> hid.git#for-4.12/asus. Could you please check whether it covers everything 
> your patch did?

Thanks, the patches looks covering enough.  I'll report back if it
doesn't work.


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

Patch

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 70b12f89a193..fe4ddaf339e7 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -199,6 +199,8 @@  static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
 	return 0;
 }
 
+#define map_key(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,7 +215,25 @@  static int asus_input_mapping(struct hid_device *hdev,
 		return -1;
 	}
 
-	return 0;
+	/*
+	 * Map some missing Fn-combo keys on ASUS E200H
+	 */
+
+	if ((usage->hid & HID_USAGE_PAGE) != 0xff310000)
+		return 0;
+
+	switch (usage->hid & HID_USAGE) {
+	case 0x006c: map_key(KEY_SLEEP);		break; /* Fn+F1 */
+	case 0x0088: map_key(KEY_RFKILL);		break; /* Fn+F2 */
+	case 0x0010: map_key(KEY_BRIGHTNESSDOWN);	break; /* Fn+F5 */
+	case 0x0020: map_key(KEY_BRIGHTNESSUP);		break; /* Fn+F6 */
+	case 0x0035: map_key(KEY_SCREENLOCK);		break; /* Fn+F7 */
+	case 0x006b: map_key(KEY_F21);			break; /* Fn+F9 */
+	default:
+		return 0;
+	}
+
+	return 1;
 }
 
 static int asus_start_multitouch(struct hid_device *hdev)