hid-roccat-kone.h 6.7 KB

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