blob: 799c3c9f5057c41e2a8e5d749e10b2196ee58551 [file] [log] [blame]
/*
* HID driver for Asus Gamepad.
* Fix the descriptor due to tightening HID specifications.
* Copyright (c) 2019 Siarhei Vishniakou <svv@google.com>
*
* Based on a patch contributed by JeiFeng Lee and Thunder Yu.
*/
/*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/
#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
#include "hid-ids.h"
static __u8 GAMEPAD_DESCRIPTOR[] = {
0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x09, 0x0a,
0x01, 0x00, 0x0a, 0x02, 0x00, 0x0a, 0x04, 0x00, 0x0a, 0x05, 0x00,
0x0a, 0x07, 0x00, 0x0a, 0x08, 0x00, 0x0a, 0x0e, 0x00, 0x0a, 0x0f,
0x00, 0x0a, 0x0d, 0x00, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95,
0x09, 0x81, 0x02, 0x05, 0x0c, 0x0a, 0x24, 0x02, 0x0a, 0x23, 0x02,
0x95, 0x02, 0x81, 0x02, 0x75, 0x01, 0x95, 0x01, 0x81, 0x03, 0x05,
0x01, 0x75, 0x04, 0x95, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x66,
0x14, 0x00, 0x09, 0x39, 0x81, 0x42, 0x66, 0x00, 0x00, 0x09, 0x01,
0xa1, 0x00, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x15,
0x00, 0x26, 0xff, 0x00, 0x35, 0x00, 0x46, 0xff, 0x00, 0x75, 0x08,
0x95, 0x04, 0x81, 0x02, 0x05, 0x02, 0x09, 0xc5, 0x09, 0xc4, 0x95,
0x02, 0x81, 0x02, 0xc0, 0x85, 0x02, 0x05, 0x08, 0x0a, 0x01, 0x00,
0x0a, 0x02, 0x00, 0x0a, 0x03, 0x00, 0x0a, 0x04, 0x00, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x04, 0x91, 0x02, 0x75, 0x04, 0x95,
0x01, 0x91, 0x03, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85,
0x03, 0x05, 0x01, 0x09, 0x06, 0xa1, 0x02, 0x05, 0x06, 0x09, 0x20,
0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x02,
0x06, 0xbc, 0xff, 0x0a, 0xad, 0xbd, 0x75, 0x08, 0x95, 0x06, 0x81,
0x02, 0xc0, 0xc0};
static __u8 *asus_gamepad_report_fixup(struct hid_device *hdev,
__u8 *rdesc, unsigned int *rsize)
{
if (hdev->product == USB_DEVICE_ID_ASUSTEK_GAMEPAD) {
hid_info(hdev, "Fixing up Asus Gamepad report descriptor\n");
*rsize = ARRAY_SIZE(GAMEPAD_DESCRIPTOR);
return GAMEPAD_DESCRIPTOR;
}
return rdesc;
}
static const struct hid_device_id asus_devices[] = {
{HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
USB_DEVICE_ID_ASUSTEK_GAMEPAD)},
};
MODULE_DEVICE_TABLE(hid, asus_devices);
static struct hid_driver asus_driver = {
.name = "asus-gamepad",
.id_table = asus_devices,
.report_fixup = asus_gamepad_report_fixup};
module_hid_driver(asus_driver);
MODULE_LICENSE("GPL");