Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 1 | #ifndef __HID_ROCCAT_PYRA_H |
| 2 | #define __HID_ROCCAT_PYRA_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net> |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/types.h> |
| 16 | |
| 17 | #pragma pack(push) |
| 18 | #pragma pack(1) |
| 19 | |
| 20 | struct pyra_b { |
| 21 | uint8_t command; /* PYRA_COMMAND_B */ |
| 22 | uint8_t size; /* always 3 */ |
| 23 | uint8_t unknown; /* 1 */ |
| 24 | }; |
| 25 | |
| 26 | struct pyra_control { |
| 27 | uint8_t command; /* PYRA_COMMAND_CONTROL */ |
| 28 | /* |
| 29 | * value is profile number for request_settings and request_buttons |
| 30 | * 1 if status ok for request_status |
| 31 | */ |
| 32 | uint8_t value; /* Range 0-4 */ |
| 33 | uint8_t request; |
| 34 | }; |
| 35 | |
| 36 | enum pyra_control_requests { |
| 37 | PYRA_CONTROL_REQUEST_STATUS = 0x00, |
| 38 | PYRA_CONTROL_REQUEST_PROFILE_SETTINGS = 0x10, |
| 39 | PYRA_CONTROL_REQUEST_PROFILE_BUTTONS = 0x20 |
| 40 | }; |
| 41 | |
| 42 | struct pyra_settings { |
| 43 | uint8_t command; /* PYRA_COMMAND_SETTINGS */ |
| 44 | uint8_t size; /* always 3 */ |
| 45 | uint8_t startup_profile; /* Range 0-4! */ |
| 46 | }; |
| 47 | |
| 48 | struct pyra_profile_settings { |
| 49 | uint8_t command; /* PYRA_COMMAND_PROFILE_SETTINGS */ |
| 50 | uint8_t size; /* always 0xd */ |
| 51 | uint8_t number; /* Range 0-4 */ |
| 52 | uint8_t xysync; |
| 53 | uint8_t x_sensitivity; /* 0x1-0xa */ |
| 54 | uint8_t y_sensitivity; |
| 55 | uint8_t x_cpi; /* unused */ |
| 56 | uint8_t y_cpi; /* this value is for x and y */ |
| 57 | uint8_t lightswitch; /* 0 = off, 1 = on */ |
| 58 | uint8_t light_effect; |
| 59 | uint8_t handedness; |
| 60 | uint16_t checksum; /* byte sum */ |
| 61 | }; |
| 62 | |
| 63 | struct pyra_profile_buttons { |
| 64 | uint8_t command; /* PYRA_COMMAND_PROFILE_BUTTONS */ |
| 65 | uint8_t size; /* always 0x13 */ |
| 66 | uint8_t number; /* Range 0-4 */ |
| 67 | uint8_t buttons[14]; |
| 68 | uint16_t checksum; /* byte sum */ |
| 69 | }; |
| 70 | |
| 71 | struct pyra_info { |
| 72 | uint8_t command; /* PYRA_COMMAND_INFO */ |
| 73 | uint8_t size; /* always 6 */ |
| 74 | uint8_t firmware_version; |
| 75 | uint8_t unknown1; /* always 0 */ |
| 76 | uint8_t unknown2; /* always 1 */ |
| 77 | uint8_t unknown3; /* always 0 */ |
| 78 | }; |
| 79 | |
| 80 | enum pyra_commands { |
| 81 | PYRA_COMMAND_CONTROL = 0x4, |
| 82 | PYRA_COMMAND_SETTINGS = 0x5, |
| 83 | PYRA_COMMAND_PROFILE_SETTINGS = 0x6, |
| 84 | PYRA_COMMAND_PROFILE_BUTTONS = 0x7, |
| 85 | PYRA_COMMAND_INFO = 0x9, |
| 86 | PYRA_COMMAND_B = 0xb |
| 87 | }; |
| 88 | |
| 89 | enum pyra_usb_commands { |
| 90 | PYRA_USB_COMMAND_CONTROL = 0x304, |
| 91 | PYRA_USB_COMMAND_SETTINGS = 0x305, |
| 92 | PYRA_USB_COMMAND_PROFILE_SETTINGS = 0x306, |
| 93 | PYRA_USB_COMMAND_PROFILE_BUTTONS = 0x307, |
| 94 | PYRA_USB_COMMAND_INFO = 0x309, |
| 95 | PYRA_USB_COMMAND_B = 0x30b /* writes 3 bytes */ |
| 96 | }; |
| 97 | |
| 98 | enum pyra_mouse_report_numbers { |
| 99 | PYRA_MOUSE_REPORT_NUMBER_HID = 1, |
| 100 | PYRA_MOUSE_REPORT_NUMBER_AUDIO = 2, |
| 101 | PYRA_MOUSE_REPORT_NUMBER_BUTTON = 3, |
| 102 | }; |
| 103 | |
| 104 | struct pyra_mouse_event_button { |
| 105 | uint8_t report_number; /* always 3 */ |
| 106 | uint8_t unknown; /* always 0 */ |
| 107 | uint8_t type; |
| 108 | uint8_t data1; |
| 109 | uint8_t data2; |
| 110 | }; |
| 111 | |
| 112 | struct pyra_mouse_event_audio { |
| 113 | uint8_t report_number; /* always 2 */ |
| 114 | uint8_t type; |
| 115 | uint8_t unused; /* always 0 */ |
| 116 | }; |
| 117 | |
| 118 | /* hid audio controls */ |
| 119 | enum pyra_mouse_event_audio_types { |
| 120 | PYRA_MOUSE_EVENT_AUDIO_TYPE_MUTE = 0xe2, |
| 121 | PYRA_MOUSE_EVENT_AUDIO_TYPE_VOLUME_UP = 0xe9, |
| 122 | PYRA_MOUSE_EVENT_AUDIO_TYPE_VOLUME_DOWN = 0xea, |
| 123 | }; |
| 124 | |
| 125 | enum pyra_mouse_event_button_types { |
| 126 | /* |
| 127 | * Mouse sends tilt events on report_number 1 and 3 |
| 128 | * Tilt events are sent repeatedly with 0.94s between first and second |
| 129 | * event and 0.22s on subsequent |
| 130 | */ |
| 131 | PYRA_MOUSE_EVENT_BUTTON_TYPE_TILT = 0x10, |
| 132 | |
| 133 | /* |
| 134 | * These are sent sequentially |
| 135 | * data1 contains new profile number in range 1-5 |
| 136 | */ |
| 137 | PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_1 = 0x20, |
| 138 | PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2 = 0x30, |
| 139 | |
| 140 | /* |
| 141 | * data1 = button_number (rmp index) |
| 142 | * data2 = pressed/released |
| 143 | */ |
| 144 | PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO = 0x40, |
| 145 | PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT = 0x50, |
| 146 | |
| 147 | /* |
| 148 | * data1 = button_number (rmp index) |
| 149 | */ |
| 150 | PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH = 0x60, |
| 151 | |
| 152 | /* data1 = new cpi */ |
| 153 | PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI = 0xb0, |
| 154 | |
| 155 | /* data1 and data2 = new sensitivity */ |
| 156 | PYRA_MOUSE_EVENT_BUTTON_TYPE_SENSITIVITY = 0xc0, |
| 157 | |
| 158 | PYRA_MOUSE_EVENT_BUTTON_TYPE_MULTIMEDIA = 0xf0, |
| 159 | }; |
| 160 | |
| 161 | enum { |
| 162 | PYRA_MOUSE_EVENT_BUTTON_PRESS = 0, |
| 163 | PYRA_MOUSE_EVENT_BUTTON_RELEASE = 1, |
| 164 | }; |
| 165 | |
| 166 | struct pyra_roccat_report { |
| 167 | uint8_t type; |
| 168 | uint8_t value; |
| 169 | uint8_t key; |
| 170 | }; |
| 171 | |
| 172 | #pragma pack(pop) |
| 173 | |
| 174 | struct pyra_device { |
| 175 | int actual_profile; |
| 176 | int actual_cpi; |
| 177 | int firmware_version; |
| 178 | int roccat_claimed; |
| 179 | int chrdev_minor; |
| 180 | struct mutex pyra_lock; |
| 181 | struct pyra_settings settings; |
| 182 | struct pyra_profile_settings profile_settings[5]; |
| 183 | struct pyra_profile_buttons profile_buttons[5]; |
| 184 | }; |
| 185 | |
| 186 | #endif |