hid-roccat-kone.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. #ifndef __HID_ROCCAT_KONE_H
  2. #define __HID_ROCCAT_KONE_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. #pragma pack(push)
  14. #pragma pack(1)
  15. struct kone_keystroke {
  16. uint8_t key;
  17. uint8_t action;
  18. uint16_t period; /* in milliseconds */
  19. };
  20. enum kone_keystroke_buttons {
  21. kone_keystroke_button_1 = 0xf0, /* left mouse button */
  22. kone_keystroke_button_2 = 0xf1, /* right mouse button */
  23. kone_keystroke_button_3 = 0xf2, /* wheel */
  24. kone_keystroke_button_9 = 0xf3, /* side button up */
  25. kone_keystroke_button_8 = 0xf4 /* side button down */
  26. };
  27. enum kone_keystroke_actions {
  28. kone_keystroke_action_press = 0,
  29. kone_keystroke_action_release = 1
  30. };
  31. struct kone_button_info {
  32. uint8_t number; /* range 1-8 */
  33. uint8_t type;
  34. uint8_t macro_type; /* 0 = short, 1 = overlong */
  35. uint8_t macro_set_name[16]; /* can be max 15 chars long */
  36. uint8_t macro_name[16]; /* can be max 15 chars long */
  37. uint8_t count;
  38. struct kone_keystroke keystrokes[20];
  39. };
  40. enum kone_button_info_types {
  41. /* valid button types until firmware 1.32 */
  42. kone_button_info_type_button_1 = 0x1, /* click (left mouse button) */
  43. kone_button_info_type_button_2 = 0x2, /* menu (right mouse button)*/
  44. kone_button_info_type_button_3 = 0x3, /* scroll (wheel) */
  45. kone_button_info_type_double_click = 0x4,
  46. kone_button_info_type_key = 0x5,
  47. kone_button_info_type_macro = 0x6,
  48. kone_button_info_type_off = 0x7,
  49. /* TODO clarify function and rename */
  50. kone_button_info_type_osd_xy_prescaling = 0x8,
  51. kone_button_info_type_osd_dpi = 0x9,
  52. kone_button_info_type_osd_profile = 0xa,
  53. kone_button_info_type_button_9 = 0xb, /* ie forward */
  54. kone_button_info_type_button_8 = 0xc, /* ie backward */
  55. kone_button_info_type_dpi_up = 0xd, /* internal */
  56. kone_button_info_type_dpi_down = 0xe, /* internal */
  57. kone_button_info_type_button_7 = 0xf, /* tilt left */
  58. kone_button_info_type_button_6 = 0x10, /* tilt right */
  59. kone_button_info_type_profile_up = 0x11, /* internal */
  60. kone_button_info_type_profile_down = 0x12, /* internal */
  61. /* additional valid button types since firmware 1.38 */
  62. kone_button_info_type_multimedia_open_player = 0x20,
  63. kone_button_info_type_multimedia_next_track = 0x21,
  64. kone_button_info_type_multimedia_prev_track = 0x22,
  65. kone_button_info_type_multimedia_play_pause = 0x23,
  66. kone_button_info_type_multimedia_stop = 0x24,
  67. kone_button_info_type_multimedia_mute = 0x25,
  68. kone_button_info_type_multimedia_volume_up = 0x26,
  69. kone_button_info_type_multimedia_volume_down = 0x27
  70. };
  71. enum kone_button_info_numbers {
  72. kone_button_top = 1,
  73. kone_button_wheel_tilt_left = 2,
  74. kone_button_wheel_tilt_right = 3,
  75. kone_button_forward = 4,
  76. kone_button_backward = 5,
  77. kone_button_middle = 6,
  78. kone_button_plus = 7,
  79. kone_button_minus = 8,
  80. };
  81. struct kone_light_info {
  82. uint8_t number; /* number of light 1-5 */
  83. uint8_t mod; /* 1 = on, 2 = off */
  84. uint8_t red; /* range 0x00-0xff */
  85. uint8_t green; /* range 0x00-0xff */
  86. uint8_t blue; /* range 0x00-0xff */
  87. };
  88. struct kone_profile {
  89. uint16_t size; /* always 975 */
  90. uint16_t unused; /* always 0 */
  91. /*
  92. * range 1-5
  93. * This number does not need to correspond with location where profile
  94. * saved
  95. */
  96. uint8_t profile; /* range 1-5 */
  97. uint16_t main_sensitivity; /* range 100-1000 */
  98. uint8_t xy_sensitivity_enabled; /* 1 = on, 2 = off */
  99. uint16_t x_sensitivity; /* range 100-1000 */
  100. uint16_t y_sensitivity; /* range 100-1000 */
  101. uint8_t dpi_rate; /* bit 1 = 800, ... */
  102. uint8_t startup_dpi; /* range 1-6 */
  103. uint8_t polling_rate; /* 1 = 125Hz, 2 = 500Hz, 3 = 1000Hz */
  104. /* kone has no dcu
  105. * value is always 2 in firmwares <= 1.32 and
  106. * 1 in firmwares > 1.32
  107. */
  108. uint8_t dcu_flag;
  109. uint8_t light_effect_1; /* range 1-3 */
  110. uint8_t light_effect_2; /* range 1-5 */
  111. uint8_t light_effect_3; /* range 1-4 */
  112. uint8_t light_effect_speed; /* range 0-255 */
  113. struct kone_light_info light_infos[5];
  114. /* offset is kone_button_info_numbers - 1 */
  115. struct kone_button_info button_infos[8];
  116. uint16_t checksum; /* \brief holds checksum of struct */
  117. };
  118. enum kone_polling_rates {
  119. kone_polling_rate_125 = 1,
  120. kone_polling_rate_500 = 2,
  121. kone_polling_rate_1000 = 3
  122. };
  123. struct kone_settings {
  124. uint16_t size; /* always 36 */
  125. uint8_t startup_profile; /* 1-5 */
  126. uint8_t unknown1;
  127. uint8_t tcu; /* 0 = off, 1 = on */
  128. uint8_t unknown2[23];
  129. uint8_t calibration_data[4];
  130. uint8_t unknown3[2];
  131. uint16_t checksum;
  132. };
  133. /*
  134. * 12 byte mouse event read by interrupt_read
  135. */
  136. struct kone_mouse_event {
  137. uint8_t report_number; /* always 1 */
  138. uint8_t button;
  139. uint16_t x;
  140. uint16_t y;
  141. uint8_t wheel; /* up = 1, down = -1 */
  142. uint8_t tilt; /* right = 1, left = -1 */
  143. uint8_t unknown;
  144. uint8_t event;
  145. uint8_t value; /* press = 0, release = 1 */
  146. uint8_t macro_key; /* 0 to 8 */
  147. };
  148. enum kone_mouse_events {
  149. /* osd events are thought to be display on screen */
  150. kone_mouse_event_osd_dpi = 0xa0,
  151. kone_mouse_event_osd_profile = 0xb0,
  152. /* TODO clarify meaning and occurence of kone_mouse_event_calibration */
  153. kone_mouse_event_calibration = 0xc0,
  154. kone_mouse_event_call_overlong_macro = 0xe0,
  155. /* switch events notify if user changed values with mousebutton click */
  156. kone_mouse_event_switch_dpi = 0xf0,
  157. kone_mouse_event_switch_profile = 0xf1
  158. };
  159. enum kone_commands {
  160. kone_command_profile = 0x5a,
  161. kone_command_settings = 0x15a,
  162. kone_command_firmware_version = 0x25a,
  163. kone_command_weight = 0x45a,
  164. kone_command_calibrate = 0x55a,
  165. kone_command_confirm_write = 0x65a,
  166. kone_command_firmware = 0xe5a
  167. };
  168. struct kone_roccat_report {
  169. uint8_t event;
  170. uint8_t value; /* holds dpi or profile value */
  171. uint8_t key; /* macro key on overlong macro execution */
  172. };
  173. #pragma pack(pop)
  174. struct kone_device {
  175. /*
  176. * Storing actual values when we get informed about changes since there
  177. * is no way of getting this information from the device on demand
  178. */
  179. int actual_profile, actual_dpi;
  180. /* Used for neutralizing abnormal button behaviour */
  181. struct kone_mouse_event last_mouse_event;
  182. /*
  183. * It's unlikely that multiple sysfs attributes are accessed at a time,
  184. * so only one mutex is used to secure hardware access and profiles and
  185. * settings of this struct.
  186. */
  187. struct mutex kone_lock;
  188. /*
  189. * Storing the data here reduces IO and ensures that data is available
  190. * when its needed (E.g. interrupt handler).
  191. */
  192. struct kone_profile profiles[5];
  193. struct kone_settings settings;
  194. /*
  195. * firmware doesn't change unless firmware update is implemented,
  196. * so it's read only once
  197. */
  198. int firmware_version;
  199. int roccat_claimed;
  200. int chrdev_minor;
  201. };
  202. #endif