Skip to content

Commit

Permalink
HID: Add driver for Holtek gaming mouse 04d9:a067
Browse files Browse the repository at this point in the history
This mouse is sold as Sharkoon Drakonia and Perixx MX-2000 and reports a
too high usage maximum and logical maximum. This driver fixes the report
descriptor so those values don't exceed HID_MAX_USAGES.

Signed-off-by: Christian Ohm <chr.ohm@gmx.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Christian Ohm authored and Jiri Kosina committed May 28, 2013
1 parent f755407 commit 41de326
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ config HID_HOLTEK
Support for Holtek based devices:
- Holtek On Line Grip based game controller
- Trust GXT 18 Gaming Keyboard
- Sharkoon Drakonia / Perixx MX-2000 gaming mice

config HOLTEK_FF
bool "Holtek On Line Grip force feedback support"
Expand Down
1 change: 1 addition & 0 deletions drivers/hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ obj-$(CONFIG_HID_ELECOM) += hid-elecom.o
obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o
obj-$(CONFIG_HID_HOLTEK) += hid-holtek-mouse.o
obj-$(CONFIG_HID_HOLTEK) += hid-holtekff.o
obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o
obj-$(CONFIG_HID_ICADE) += hid-icade.o
Expand Down
72 changes: 72 additions & 0 deletions drivers/hid/hid-holtek-mouse.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* HID driver for Holtek gaming mice
* Copyright (c) 2013 Christian Ohm
* Heavily inspired by various other HID drivers that adjust the report
* descriptor.
*/

/*
* 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/hid.h>
#include <linux/module.h>
#include <linux/usb.h>

#include "hid-ids.h"

/*
* The report descriptor of some Holtek based gaming mice specifies an
* excessively large number of consumer usages (2^15), which is more than
* HID_MAX_USAGES. This prevents proper parsing of the report descriptor.
*
* This driver fixes the report descriptor for USB ID 04d9:a067, sold as
* Sharkoon Drakonia and Perixx MX-2000.
*/

static __u8 *holtek_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);

if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
/* Change usage maximum and logical maximum from 0x7fff to
* 0x2fff, so they don't exceed HID_MAX_USAGES */
if (*rsize >= 122 && rdesc[115] == 0xff && rdesc[116] == 0x7f
&& rdesc[120] == 0xff && rdesc[121] == 0x7f) {
hid_info(hdev, "Fixing up report descriptor\n");
rdesc[116] = rdesc[121] = 0x2f;
}
}
return rdesc;
}

static const struct hid_device_id holtek_mouse_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) },
{ }
};
MODULE_DEVICE_TABLE(hid, holtek_mouse_devices);

static struct hid_driver holtek_mouse_driver = {
.name = "holtek_mouse",
.id_table = holtek_mouse_devices,
.report_fixup = holtek_mouse_report_fixup,
};

static int __init holtek_mouse_init(void)
{
return hid_register_driver(&holtek_mouse_driver);
}

static void __exit holtek_mouse_exit(void)
{
hid_unregister_driver(&holtek_mouse_driver);
}

module_exit(holtek_mouse_exit);
module_init(holtek_mouse_init);
MODULE_LICENSE("GPL");
1 change: 1 addition & 0 deletions drivers/hid/hid-ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@

#define USB_VENDOR_ID_HOLTEK_ALT 0x04d9
#define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD 0xa055
#define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067 0xa067

#define USB_VENDOR_ID_IMATION 0x0718
#define USB_DEVICE_ID_DISC_STAKKA 0xd000
Expand Down

0 comments on commit 41de326

Please sign in to comment.