hid-roccat-kone.h 6.8 KB

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