diff options
author | Jun Yan <juyan@nvidia.com> | 2013-12-30 19:24:48 -0800 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2014-06-25 00:49:03 -0700 |
commit | 36c68f3edb0a5f4be541e8168e2bd404c9a1357e (patch) | |
tree | 1a6823e1e765ca2764bd4cc25688a2a8e7c911f2 | |
parent | 19fc07fedae665f645554998473d454c697415cb (diff) |
hid: nvidia: Map home and back in kernel
This is to support recovery kernel, where we
don't have Android keymapping but totally relying
on "real" KEY_HOME/KEY_BACK.
Bug 1431870
Change-Id: Ib3185bc230b65b5e25094caf3a61fa45ed2b835b
Reviewed-on: http://git-master/r/350820
(cherry picked from commit e8c64f6f7cf8280b903a6f29116b79abb1538f05)
Signed-off-by: Jean Huang <jeanh@nvidia.com>
Reviewed-on: http://git-master/r/427942
GVS: Gerrit_Virtual_Submit
-rw-r--r-- | drivers/hid/hid-nvidia.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/hid/hid-nvidia.c b/drivers/hid/hid-nvidia.c index 29a4ae2a4a16..9001cc6c9bc3 100644 --- a/drivers/hid/hid-nvidia.c +++ b/drivers/hid/hid-nvidia.c @@ -1,7 +1,7 @@ /* * HID driver for NVIDIA Shield Joystick * - * Copyright (c) 2013, NVIDIA Corporation. All Rights Reserved. + * Copyright (c) 2013-2014, NVIDIA Corporation. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -29,6 +29,9 @@ #define JOYSTICK_FLAT 64 #define TRIGGER_FLAT 0 +#define JOYSTICK_HOME_CODE 15 +#define JOYSTICK_BACK_CODE 12 + static int nvidia_input_mapped(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) @@ -62,10 +65,29 @@ static int nvidia_input_mapped(struct hid_device *hdev, struct hid_input *hi, hidinput_calc_abs_res(field, usage->code)); return -1; } + return 0; +} +static int nvidia_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) { + int code; + if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { + code = ((usage->hid - 1) & HID_USAGE); + if (code == JOYSTICK_HOME_CODE) { + code = KEY_HOME; + hid_map_usage(hi, usage, bit, max, EV_KEY, code); + return 1; + } else if (code == JOYSTICK_BACK_CODE) { + code = KEY_BACK; + hid_map_usage(hi, usage, bit, max, EV_KEY, code); + return 1; + } + } return 0; } + static const struct hid_device_id nvidia_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_NVIDIA, USB_DEVICE_ID_NVIDIA_LOKI) }, { } @@ -76,6 +98,7 @@ static struct hid_driver nvidia_driver = { .name = "hid-nvidia", .id_table = nvidia_devices, .input_mapped = nvidia_input_mapped, + .input_mapping = nvidia_input_mapping, }; module_hid_driver(nvidia_driver); |