hid-roccat-koneplus.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #ifndef __HID_ROCCAT_KONEPLUS_H
  2. #define __HID_ROCCAT_KONEPLUS_H
  3. /*
  4. * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
  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/types.h>
  13. /*
  14. * case 1: writes request 80 and reads value 1
  15. *
  16. */
  17. struct koneplus_control {
  18. uint8_t command; /* KONEPLUS_COMMAND_CONTROL */
  19. /*
  20. * value is profile number in range 0-4 for requesting settings and buttons
  21. * 1 if status ok for requesting status
  22. */
  23. uint8_t value;
  24. uint8_t request;
  25. } __attribute__ ((__packed__));
  26. enum koneplus_control_requests {
  27. KONEPLUS_CONTROL_REQUEST_STATUS = 0x00,
  28. KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x80,
  29. KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS = 0x90,
  30. };
  31. enum koneplus_control_values {
  32. KONEPLUS_CONTROL_REQUEST_STATUS_OVERLOAD = 0,
  33. KONEPLUS_CONTROL_REQUEST_STATUS_OK = 1,
  34. KONEPLUS_CONTROL_REQUEST_STATUS_WAIT = 3,
  35. };
  36. struct koneplus_actual_profile {
  37. uint8_t command; /* KONEPLUS_COMMAND_ACTUAL_PROFILE */
  38. uint8_t size; /* always 3 */
  39. uint8_t actual_profile; /* Range 0-4! */
  40. } __attribute__ ((__packed__));
  41. struct koneplus_profile_settings {
  42. uint8_t command; /* KONEPLUS_COMMAND_PROFILE_SETTINGS */
  43. uint8_t size; /* always 43 */
  44. uint8_t number; /* range 0-4 */
  45. uint8_t advanced_sensitivity;
  46. uint8_t sensitivity_x;
  47. uint8_t sensitivity_y;
  48. uint8_t cpi_levels_enabled;
  49. uint8_t cpi_levels_x[5];
  50. uint8_t cpi_startup_level; /* range 0-4 */
  51. uint8_t cpi_levels_y[5]; /* range 1-60 means 100-6000 cpi */
  52. uint8_t unknown1;
  53. uint8_t polling_rate;
  54. uint8_t lights_enabled;
  55. uint8_t light_effect_mode;
  56. uint8_t color_flow_effect;
  57. uint8_t light_effect_type;
  58. uint8_t light_effect_speed;
  59. uint8_t lights[16];
  60. uint16_t checksum;
  61. } __attribute__ ((__packed__));
  62. struct koneplus_profile_buttons {
  63. uint8_t command; /* KONEPLUS_COMMAND_PROFILE_BUTTONS */
  64. uint8_t size; /* always 77 */
  65. uint8_t number; /* range 0-4 */
  66. uint8_t data[72];
  67. uint16_t checksum;
  68. } __attribute__ ((__packed__));
  69. struct koneplus_macro {
  70. uint8_t command; /* KONEPLUS_COMMAND_MACRO */
  71. uint16_t size; /* always 0x822 little endian */
  72. uint8_t profile; /* range 0-4 */
  73. uint8_t button; /* range 0-23 */
  74. uint8_t data[2075];
  75. uint16_t checksum;
  76. } __attribute__ ((__packed__));
  77. struct koneplus_info {
  78. uint8_t command; /* KONEPLUS_COMMAND_INFO */
  79. uint8_t size; /* always 6 */
  80. uint8_t firmware_version;
  81. uint8_t unknown[3];
  82. } __attribute__ ((__packed__));
  83. struct koneplus_e {
  84. uint8_t command; /* KONEPLUS_COMMAND_E */
  85. uint8_t size; /* always 3 */
  86. uint8_t unknown; /* TODO 1; 0 before firmware update */
  87. } __attribute__ ((__packed__));
  88. struct koneplus_sensor {
  89. uint8_t command; /* KONEPLUS_COMMAND_SENSOR */
  90. uint8_t size; /* always 6 */
  91. uint8_t data[4];
  92. } __attribute__ ((__packed__));
  93. struct koneplus_firmware_write {
  94. uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE */
  95. uint8_t unknown[1025];
  96. } __attribute__ ((__packed__));
  97. struct koneplus_firmware_write_control {
  98. uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL */
  99. /*
  100. * value is 1 on success
  101. * 3 means "not finished yet"
  102. */
  103. uint8_t value;
  104. uint8_t unknown; /* always 0x75 */
  105. } __attribute__ ((__packed__));
  106. struct koneplus_tcu {
  107. uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */
  108. uint8_t data[2];
  109. } __attribute__ ((__packed__));
  110. struct koneplus_tcu_image {
  111. uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */
  112. uint8_t data[1024];
  113. uint16_t checksum;
  114. } __attribute__ ((__packed__));
  115. enum koneplus_commands {
  116. KONEPLUS_COMMAND_CONTROL = 0x4,
  117. KONEPLUS_COMMAND_ACTUAL_PROFILE = 0x5,
  118. KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6,
  119. KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7,
  120. KONEPLUS_COMMAND_MACRO = 0x8,
  121. KONEPLUS_COMMAND_INFO = 0x9,
  122. KONEPLUS_COMMAND_E = 0xe,
  123. KONEPLUS_COMMAND_SENSOR = 0xf,
  124. KONEPLUS_COMMAND_FIRMWARE_WRITE = 0x1b,
  125. KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL = 0x1c,
  126. };
  127. enum koneplus_usb_commands {
  128. KONEPLUS_USB_COMMAND_CONTROL = 0x304,
  129. KONEPLUS_USB_COMMAND_ACTUAL_PROFILE = 0x305,
  130. KONEPLUS_USB_COMMAND_PROFILE_SETTINGS = 0x306,
  131. KONEPLUS_USB_COMMAND_PROFILE_BUTTONS = 0x307,
  132. KONEPLUS_USB_COMMAND_MACRO = 0x308,
  133. KONEPLUS_USB_COMMAND_INFO = 0x309,
  134. KONEPLUS_USB_COMMAND_TCU = 0x30c,
  135. KONEPLUS_USB_COMMAND_E = 0x30e,
  136. KONEPLUS_USB_COMMAND_SENSOR = 0x30f,
  137. KONEPLUS_USB_COMMAND_FIRMWARE_WRITE = 0x31b,
  138. KONEPLUS_USB_COMMAND_FIRMWARE_WRITE_CONTROL = 0x31c,
  139. };
  140. enum koneplus_mouse_report_numbers {
  141. KONEPLUS_MOUSE_REPORT_NUMBER_HID = 1,
  142. KONEPLUS_MOUSE_REPORT_NUMBER_AUDIO = 2,
  143. KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON = 3,
  144. };
  145. struct koneplus_mouse_report_button {
  146. uint8_t report_number; /* always KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON */
  147. uint8_t zero1;
  148. uint8_t type;
  149. uint8_t data1;
  150. uint8_t data2;
  151. uint8_t zero2;
  152. uint8_t unknown[2];
  153. } __attribute__ ((__packed__));
  154. enum koneplus_mouse_report_button_types {
  155. /* data1 = new profile range 1-5 */
  156. KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE = 0x20,
  157. /* data1 = button number range 1-24; data2 = action */
  158. KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH = 0x60,
  159. /* data1 = button number range 1-24; data2 = action */
  160. KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER = 0x80,
  161. /* data1 = setting number range 1-5 */
  162. KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_CPI = 0xb0,
  163. /* data1 and data2 = range 0x1-0xb */
  164. KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_SENSITIVITY = 0xc0,
  165. /* data1 = 22 = next track...
  166. * data2 = action
  167. */
  168. KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_MULTIMEDIA = 0xf0,
  169. };
  170. enum koneplus_mouse_report_button_action {
  171. KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS = 0,
  172. KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_RELEASE = 1,
  173. };
  174. struct koneplus_roccat_report {
  175. uint8_t type;
  176. uint8_t data1;
  177. uint8_t data2;
  178. uint8_t profile;
  179. } __attribute__ ((__packed__));
  180. struct koneplus_device {
  181. int actual_profile;
  182. int roccat_claimed;
  183. int chrdev_minor;
  184. struct mutex koneplus_lock;
  185. struct koneplus_info info;
  186. struct koneplus_profile_settings profile_settings[5];
  187. struct koneplus_profile_buttons profile_buttons[5];
  188. };
  189. #endif