Commit 13d02c69 authored by Rahul Rameshbabu's avatar Rahul Rameshbabu Committed by Jiri Kosina

HID: nvidia-shield: Add mappings for consumer HID USAGE buttons

Map Android Home, Back, Search, VolumeUp, VolumeDown, and PlayPause buttons
to the appropriate input event codes.
Signed-off-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 09308562
...@@ -15,6 +15,16 @@ ...@@ -15,6 +15,16 @@
#include "hid-ids.h" #include "hid-ids.h"
#define NOT_INIT_STR "NOT INITIALIZED" #define NOT_INIT_STR "NOT INITIALIZED"
#define android_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
enum {
HID_USAGE_ANDROID_PLAYPAUSE_BTN = 0xcd, /* Double-tap volume slider */
HID_USAGE_ANDROID_VOLUMEUP_BTN = 0xe9,
HID_USAGE_ANDROID_VOLUMEDOWN_BTN = 0xea,
HID_USAGE_ANDROID_SEARCH_BTN = 0x221, /* NVIDIA btn on Thunderstrike */
HID_USAGE_ANDROID_HOME_BTN = 0x223,
HID_USAGE_ANDROID_BACK_BTN = 0x224,
};
enum { enum {
SHIELD_FW_VERSION_INITIALIZED = 0, SHIELD_FW_VERSION_INITIALIZED = 0,
...@@ -416,6 +426,40 @@ static struct shield_device *thunderstrike_create(struct hid_device *hdev) ...@@ -416,6 +426,40 @@ static struct shield_device *thunderstrike_create(struct hid_device *hdev)
return shield_dev; return shield_dev;
} }
static int android_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_CONSUMER)
return 0;
switch (usage->hid & HID_USAGE) {
case HID_USAGE_ANDROID_PLAYPAUSE_BTN:
android_map_key(KEY_PLAYPAUSE);
break;
case HID_USAGE_ANDROID_VOLUMEUP_BTN:
android_map_key(KEY_VOLUMEUP);
break;
case HID_USAGE_ANDROID_VOLUMEDOWN_BTN:
android_map_key(KEY_VOLUMEDOWN);
break;
case HID_USAGE_ANDROID_SEARCH_BTN:
android_map_key(BTN_Z);
break;
case HID_USAGE_ANDROID_HOME_BTN:
android_map_key(BTN_MODE);
break;
case HID_USAGE_ANDROID_BACK_BTN:
android_map_key(BTN_SELECT);
break;
default:
return 0;
}
return 1;
}
static ssize_t firmware_version_show(struct device *dev, static ssize_t firmware_version_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -571,11 +615,12 @@ static const struct hid_device_id shield_devices[] = { ...@@ -571,11 +615,12 @@ static const struct hid_device_id shield_devices[] = {
MODULE_DEVICE_TABLE(hid, shield_devices); MODULE_DEVICE_TABLE(hid, shield_devices);
static struct hid_driver shield_driver = { static struct hid_driver shield_driver = {
.name = "shield", .name = "shield",
.id_table = shield_devices, .id_table = shield_devices,
.probe = shield_probe, .input_mapping = android_input_mapping,
.remove = shield_remove, .probe = shield_probe,
.raw_event = shield_raw_event, .remove = shield_remove,
.raw_event = shield_raw_event,
.driver = { .driver = {
.dev_groups = shield_device_groups, .dev_groups = shield_device_groups,
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment