diff options
author | Jun Yan <juyan@nvidia.com> | 2013-12-30 19:24:48 -0800 |
---|---|---|
committer | Raymond Poudrier <rapoudrier@nvidia.com> | 2014-01-09 16:46:56 -0800 |
commit | e8c64f6f7cf8280b903a6f29116b79abb1538f05 (patch) | |
tree | c6791e59c28ecc313382239259384474f61c008d | |
parent | e3da83cbffa4b2dc8707723f60b2d9ca2b45f1e9 (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
Signed-off-by: Jun Yan <juyan@nvidia.com>
Reviewed-on: http://git-master/r/350820
Reviewed-by: Raymond Poudrier <rapoudrier@nvidia.com>
Tested-by: Raymond Poudrier <rapoudrier@nvidia.com>
-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); |