hid-roccat-pyra.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #ifndef __HID_ROCCAT_PYRA_H
  2. #define __HID_ROCCAT_PYRA_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 pyra_b {
  14. uint8_t command; /* PYRA_COMMAND_B */
  15. uint8_t size; /* always 3 */
  16. uint8_t unknown; /* 1 */
  17. } __attribute__ ((__packed__));
  18. struct pyra_control {
  19. uint8_t command; /* PYRA_COMMAND_CONTROL */
  20. /*
  21. * value is profile number for request_settings and request_buttons
  22. * 1 if status ok for request_status
  23. */
  24. uint8_t value; /* Range 0-4 */
  25. uint8_t request;
  26. } __attribute__ ((__packed__));
  27. enum pyra_control_requests {
  28. PYRA_CONTROL_REQUEST_STATUS = 0x00,
  29. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS = 0x10,
  30. PYRA_CONTROL_REQUEST_PROFILE_BUTTONS = 0x20
  31. };
  32. struct pyra_settings {
  33. uint8_t command; /* PYRA_COMMAND_SETTINGS */
  34. uint8_t size; /* always 3 */
  35. uint8_t startup_profile; /* Range 0-4! */
  36. } __attribute__ ((__packed__));
  37. struct pyra_profile_settings {
  38. uint8_t command; /* PYRA_COMMAND_PROFILE_SETTINGS */
  39. uint8_t size; /* always 0xd */
  40. uint8_t number; /* Range 0-4 */
  41. uint8_t xysync;
  42. uint8_t x_sensitivity; /* 0x1-0xa */
  43. uint8_t y_sensitivity;
  44. uint8_t x_cpi; /* unused */
  45. uint8_t y_cpi; /* this value is for x and y */
  46. uint8_t lightswitch; /* 0 = off, 1 = on */
  47. uint8_t light_effect;
  48. uint8_t handedness;
  49. uint16_t checksum; /* byte sum */
  50. } __attribute__ ((__packed__));
  51. struct pyra_profile_buttons {
  52. uint8_t command; /* PYRA_COMMAND_PROFILE_BUTTONS */
  53. uint8_t size; /* always 0x13 */
  54. uint8_t number; /* Range 0-4 */
  55. uint8_t buttons[14];
  56. uint16_t checksum; /* byte sum */
  57. } __attribute__ ((__packed__));
  58. struct pyra_info {
  59. uint8_t command; /* PYRA_COMMAND_INFO */
  60. uint8_t size; /* always 6 */
  61. uint8_t firmware_version;
  62. uint8_t unknown1; /* always 0 */
  63. uint8_t unknown2; /* always 1 */
  64. uint8_t unknown3; /* always 0 */
  65. } __attribute__ ((__packed__));
  66. enum pyra_commands {
  67. PYRA_COMMAND_CONTROL = 0x4,
  68. PYRA_COMMAND_SETTINGS = 0x5,
  69. PYRA_COMMAND_PROFILE_SETTINGS = 0x6,
  70. PYRA_COMMAND_PROFILE_BUTTONS = 0x7,
  71. PYRA_COMMAND_INFO = 0x9,
  72. PYRA_COMMAND_B = 0xb
  73. };
  74. enum pyra_usb_commands {
  75. PYRA_USB_COMMAND_CONTROL = 0x304,
  76. PYRA_USB_COMMAND_SETTINGS = 0x305,
  77. PYRA_USB_COMMAND_PROFILE_SETTINGS = 0x306,
  78. PYRA_USB_COMMAND_PROFILE_BUTTONS = 0x307,
  79. PYRA_USB_COMMAND_INFO = 0x309,
  80. PYRA_USB_COMMAND_B = 0x30b /* writes 3 bytes */
  81. };
  82. enum pyra_mouse_report_numbers {
  83. PYRA_MOUSE_REPORT_NUMBER_HID = 1,
  84. PYRA_MOUSE_REPORT_NUMBER_AUDIO = 2,
  85. PYRA_MOUSE_REPORT_NUMBER_BUTTON = 3,
  86. };
  87. struct pyra_mouse_event_button {
  88. uint8_t report_number; /* always 3 */
  89. uint8_t unknown; /* always 0 */
  90. uint8_t type;
  91. uint8_t data1;
  92. uint8_t data2;
  93. } __attribute__ ((__packed__));
  94. struct pyra_mouse_event_audio {
  95. uint8_t report_number; /* always 2 */
  96. uint8_t type;
  97. uint8_t unused; /* always 0 */
  98. } __attribute__ ((__packed__));
  99. /* hid audio controls */
  100. enum pyra_mouse_event_audio_types {
  101. PYRA_MOUSE_EVENT_AUDIO_TYPE_MUTE = 0xe2,
  102. PYRA_MOUSE_EVENT_AUDIO_TYPE_VOLUME_UP = 0xe9,
  103. PYRA_MOUSE_EVENT_AUDIO_TYPE_VOLUME_DOWN = 0xea,
  104. };
  105. enum pyra_mouse_event_button_types {
  106. /*
  107. * Mouse sends tilt events on report_number 1 and 3
  108. * Tilt events are sent repeatedly with 0.94s between first and second
  109. * event and 0.22s on subsequent
  110. */
  111. PYRA_MOUSE_EVENT_BUTTON_TYPE_TILT = 0x10,
  112. /*
  113. * These are sent sequentially
  114. * data1 contains new profile number in range 1-5
  115. */
  116. PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_1 = 0x20,
  117. PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2 = 0x30,
  118. /*
  119. * data1 = button_number (rmp index)
  120. * data2 = pressed/released
  121. */
  122. PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO = 0x40,
  123. PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT = 0x50,
  124. /*
  125. * data1 = button_number (rmp index)
  126. */
  127. PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH = 0x60,
  128. /* data1 = new cpi */
  129. PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI = 0xb0,
  130. /* data1 and data2 = new sensitivity */
  131. PYRA_MOUSE_EVENT_BUTTON_TYPE_SENSITIVITY = 0xc0,
  132. PYRA_MOUSE_EVENT_BUTTON_TYPE_MULTIMEDIA = 0xf0,
  133. };
  134. enum {
  135. PYRA_MOUSE_EVENT_BUTTON_PRESS = 0,
  136. PYRA_MOUSE_EVENT_BUTTON_RELEASE = 1,
  137. };
  138. struct pyra_roccat_report {
  139. uint8_t type;
  140. uint8_t value;
  141. uint8_t key;
  142. } __attribute__ ((__packed__));
  143. struct pyra_device {
  144. int actual_profile;
  145. int actual_cpi;
  146. int firmware_version;
  147. int roccat_claimed;
  148. int chrdev_minor;
  149. struct mutex pyra_lock;
  150. struct pyra_settings settings;
  151. struct pyra_profile_settings profile_settings[5];
  152. struct pyra_profile_buttons profile_buttons[5];
  153. };
  154. #endif