hid-steelseries-srws1.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * HID driver for Steelseries SRW-S1
  3. *
  4. * Copyright (c) 2013 Simon Wood
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. */
  12. #include <linux/device.h>
  13. #include <linux/hid.h>
  14. #include <linux/module.h>
  15. #include "hid-ids.h"
  16. /* Fixed report descriptor for Steelseries SRW-S1 wheel controller
  17. *
  18. * The original descriptor hides the sensitivity and assists dials
  19. * a custom vendor usage page. This inserts a patch to make them
  20. * appear in the 'Generic Desktop' usage.
  21. */
  22. static __u8 steelseries_srws1_rdesc_fixed[] = {
  23. 0x05, 0x01, /* Usage Page (Desktop) */
  24. 0x09, 0x08, /* Usage (MultiAxis), Changed */
  25. 0xA1, 0x01, /* Collection (Application), */
  26. 0xA1, 0x02, /* Collection (Logical), */
  27. 0x95, 0x01, /* Report Count (1), */
  28. 0x05, 0x01, /* Changed Usage Page (Desktop), */
  29. 0x09, 0x30, /* Changed Usage (X), */
  30. 0x16, 0xF8, 0xF8, /* Logical Minimum (-1800), */
  31. 0x26, 0x08, 0x07, /* Logical Maximum (1800), */
  32. 0x65, 0x14, /* Unit (Degrees), */
  33. 0x55, 0x0F, /* Unit Exponent (15), */
  34. 0x75, 0x10, /* Report Size (16), */
  35. 0x81, 0x02, /* Input (Variable), */
  36. 0x09, 0x31, /* Changed Usage (Y), */
  37. 0x15, 0x00, /* Logical Minimum (0), */
  38. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  39. 0x75, 0x0C, /* Report Size (12), */
  40. 0x81, 0x02, /* Input (Variable), */
  41. 0x09, 0x32, /* Changed Usage (Z), */
  42. 0x15, 0x00, /* Logical Minimum (0), */
  43. 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
  44. 0x75, 0x0C, /* Report Size (12), */
  45. 0x81, 0x02, /* Input (Variable), */
  46. 0x05, 0x01, /* Usage Page (Desktop), */
  47. 0x09, 0x39, /* Usage (Hat Switch), */
  48. 0x25, 0x07, /* Logical Maximum (7), */
  49. 0x35, 0x00, /* Physical Minimum (0), */
  50. 0x46, 0x3B, 0x01, /* Physical Maximum (315), */
  51. 0x65, 0x14, /* Unit (Degrees), */
  52. 0x75, 0x04, /* Report Size (4), */
  53. 0x95, 0x01, /* Report Count (1), */
  54. 0x81, 0x02, /* Input (Variable), */
  55. 0x25, 0x01, /* Logical Maximum (1), */
  56. 0x45, 0x01, /* Physical Maximum (1), */
  57. 0x65, 0x00, /* Unit, */
  58. 0x75, 0x01, /* Report Size (1), */
  59. 0x95, 0x03, /* Report Count (3), */
  60. 0x81, 0x01, /* Input (Constant), */
  61. 0x05, 0x09, /* Usage Page (Button), */
  62. 0x19, 0x01, /* Usage Minimum (01h), */
  63. 0x29, 0x11, /* Usage Maximum (11h), */
  64. 0x95, 0x11, /* Report Count (17), */
  65. 0x81, 0x02, /* Input (Variable), */
  66. /* ---- Dial patch starts here ---- */
  67. 0x05, 0x01, /* Usage Page (Desktop), */
  68. 0x09, 0x33, /* Usage (RX), */
  69. 0x75, 0x04, /* Report Size (4), */
  70. 0x95, 0x02, /* Report Count (2), */
  71. 0x15, 0x00, /* Logical Minimum (0), */
  72. 0x25, 0x0b, /* Logical Maximum (b), */
  73. 0x81, 0x02, /* Input (Variable), */
  74. 0x09, 0x35, /* Usage (RZ), */
  75. 0x75, 0x04, /* Report Size (4), */
  76. 0x95, 0x01, /* Report Count (1), */
  77. 0x25, 0x03, /* Logical Maximum (3), */
  78. 0x81, 0x02, /* Input (Variable), */
  79. /* ---- Dial patch ends here ---- */
  80. 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
  81. 0x09, 0x01, /* Usage (01h), */
  82. 0x75, 0x04, /* Changed Report Size (4), */
  83. 0x95, 0x0D, /* Changed Report Count (13), */
  84. 0x81, 0x02, /* Input (Variable), */
  85. 0xC0, /* End Collection, */
  86. 0xA1, 0x02, /* Collection (Logical), */
  87. 0x09, 0x02, /* Usage (02h), */
  88. 0x75, 0x08, /* Report Size (8), */
  89. 0x95, 0x10, /* Report Count (16), */
  90. 0x91, 0x02, /* Output (Variable), */
  91. 0xC0, /* End Collection, */
  92. 0xC0 /* End Collection */
  93. };
  94. static __u8 *steelseries_srws1_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  95. unsigned int *rsize)
  96. {
  97. if (*rsize >= 115 && rdesc[11] == 0x02 && rdesc[13] == 0xc8
  98. && rdesc[29] == 0xbb && rdesc[40] == 0xc5) {
  99. hid_info(hdev, "Fixing up Steelseries SRW-S1 report descriptor\n");
  100. rdesc = steelseries_srws1_rdesc_fixed;
  101. *rsize = sizeof(steelseries_srws1_rdesc_fixed);
  102. }
  103. return rdesc;
  104. }
  105. static const struct hid_device_id steelseries_srws1_devices[] = {
  106. { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
  107. { }
  108. };
  109. MODULE_DEVICE_TABLE(hid, steelseries_srws1_devices);
  110. static struct hid_driver steelseries_srws1_driver = {
  111. .name = "steelseries_srws1",
  112. .id_table = steelseries_srws1_devices,
  113. .report_fixup = steelseries_srws1_report_fixup
  114. };
  115. static int __init steelseries_srws1_init(void)
  116. {
  117. return hid_register_driver(&steelseries_srws1_driver);
  118. }
  119. static void __exit steelseries_srws1_exit(void)
  120. {
  121. hid_unregister_driver(&steelseries_srws1_driver);
  122. }
  123. module_init(steelseries_srws1_init);
  124. module_exit(steelseries_srws1_exit);
  125. MODULE_LICENSE("GPL");