blob: c03332a4fa9aeb07ddf30ecf6071c8a8dcc1fb9f [file] [log] [blame]
Stefan Achatz47dbdbff2010-11-26 19:57:42 +00001#ifndef __HID_ROCCAT_KONEPLUS_H
2#define __HID_ROCCAT_KONEPLUS_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
Stefan Achatz6d1dec82011-05-29 19:32:57 +020017struct koneplus_talk {
18 uint8_t command; /* KONEPLUS_COMMAND_TALK */
19 uint8_t size; /* always 0x10 */
20 uint8_t data[14];
21} __packed;
22
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000023/*
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000024 * case 1: writes request 80 and reads value 1
25 *
26 */
27struct koneplus_control {
28 uint8_t command; /* KONEPLUS_COMMAND_CONTROL */
29 /*
30 * value is profile number in range 0-4 for requesting settings and buttons
31 * 1 if status ok for requesting status
32 */
33 uint8_t value;
34 uint8_t request;
Jiri Kosina4d043102010-12-09 14:29:34 +010035} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000036
37enum koneplus_control_requests {
38 KONEPLUS_CONTROL_REQUEST_STATUS = 0x00,
39 KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x80,
40 KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS = 0x90,
41};
42
43enum koneplus_control_values {
44 KONEPLUS_CONTROL_REQUEST_STATUS_OVERLOAD = 0,
45 KONEPLUS_CONTROL_REQUEST_STATUS_OK = 1,
46 KONEPLUS_CONTROL_REQUEST_STATUS_WAIT = 3,
47};
48
Stefan Achatzb50f3152011-04-13 17:17:52 +020049struct koneplus_actual_profile {
50 uint8_t command; /* KONEPLUS_COMMAND_ACTUAL_PROFILE */
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000051 uint8_t size; /* always 3 */
Stefan Achatzb50f3152011-04-13 17:17:52 +020052 uint8_t actual_profile; /* Range 0-4! */
Jiri Kosina4d043102010-12-09 14:29:34 +010053} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000054
55struct koneplus_profile_settings {
56 uint8_t command; /* KONEPLUS_COMMAND_PROFILE_SETTINGS */
57 uint8_t size; /* always 43 */
58 uint8_t number; /* range 0-4 */
59 uint8_t advanced_sensitivity;
60 uint8_t sensitivity_x;
61 uint8_t sensitivity_y;
62 uint8_t cpi_levels_enabled;
63 uint8_t cpi_levels_x[5];
64 uint8_t cpi_startup_level; /* range 0-4 */
65 uint8_t cpi_levels_y[5]; /* range 1-60 means 100-6000 cpi */
66 uint8_t unknown1;
67 uint8_t polling_rate;
68 uint8_t lights_enabled;
69 uint8_t light_effect_mode;
70 uint8_t color_flow_effect;
71 uint8_t light_effect_type;
72 uint8_t light_effect_speed;
73 uint8_t lights[16];
74 uint16_t checksum;
Jiri Kosina4d043102010-12-09 14:29:34 +010075} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000076
77struct koneplus_profile_buttons {
78 uint8_t command; /* KONEPLUS_COMMAND_PROFILE_BUTTONS */
79 uint8_t size; /* always 77 */
80 uint8_t number; /* range 0-4 */
81 uint8_t data[72];
82 uint16_t checksum;
Jiri Kosina4d043102010-12-09 14:29:34 +010083} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000084
85struct koneplus_macro {
86 uint8_t command; /* KONEPLUS_COMMAND_MACRO */
87 uint16_t size; /* always 0x822 little endian */
88 uint8_t profile; /* range 0-4 */
89 uint8_t button; /* range 0-23 */
90 uint8_t data[2075];
91 uint16_t checksum;
Jiri Kosina4d043102010-12-09 14:29:34 +010092} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +000093
94struct koneplus_info {
95 uint8_t command; /* KONEPLUS_COMMAND_INFO */
96 uint8_t size; /* always 6 */
97 uint8_t firmware_version;
98 uint8_t unknown[3];
Jiri Kosina4d043102010-12-09 14:29:34 +010099} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000100
101struct koneplus_e {
102 uint8_t command; /* KONEPLUS_COMMAND_E */
103 uint8_t size; /* always 3 */
104 uint8_t unknown; /* TODO 1; 0 before firmware update */
Jiri Kosina4d043102010-12-09 14:29:34 +0100105} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000106
107struct koneplus_sensor {
108 uint8_t command; /* KONEPLUS_COMMAND_SENSOR */
109 uint8_t size; /* always 6 */
110 uint8_t data[4];
Jiri Kosina4d043102010-12-09 14:29:34 +0100111} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000112
113struct koneplus_firmware_write {
114 uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE */
115 uint8_t unknown[1025];
Jiri Kosina4d043102010-12-09 14:29:34 +0100116} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000117
118struct koneplus_firmware_write_control {
119 uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL */
120 /*
121 * value is 1 on success
122 * 3 means "not finished yet"
123 */
124 uint8_t value;
125 uint8_t unknown; /* always 0x75 */
Jiri Kosina4d043102010-12-09 14:29:34 +0100126} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000127
128struct koneplus_tcu {
129 uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */
130 uint8_t data[2];
Jiri Kosina4d043102010-12-09 14:29:34 +0100131} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000132
133struct koneplus_tcu_image {
134 uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */
135 uint8_t data[1024];
136 uint16_t checksum;
Jiri Kosina4d043102010-12-09 14:29:34 +0100137} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000138
139enum koneplus_commands {
140 KONEPLUS_COMMAND_CONTROL = 0x4,
Stefan Achatzb50f3152011-04-13 17:17:52 +0200141 KONEPLUS_COMMAND_ACTUAL_PROFILE = 0x5,
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000142 KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6,
143 KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7,
144 KONEPLUS_COMMAND_MACRO = 0x8,
145 KONEPLUS_COMMAND_INFO = 0x9,
Stefan Achatz1edd5b42011-06-01 15:54:17 +0200146 KONEPLUS_COMMAND_TCU = 0xc,
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000147 KONEPLUS_COMMAND_E = 0xe,
148 KONEPLUS_COMMAND_SENSOR = 0xf,
Stefan Achatz6d1dec82011-05-29 19:32:57 +0200149 KONEPLUS_COMMAND_TALK = 0x10,
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000150 KONEPLUS_COMMAND_FIRMWARE_WRITE = 0x1b,
151 KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL = 0x1c,
152};
153
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000154enum koneplus_mouse_report_numbers {
155 KONEPLUS_MOUSE_REPORT_NUMBER_HID = 1,
156 KONEPLUS_MOUSE_REPORT_NUMBER_AUDIO = 2,
157 KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON = 3,
158};
159
160struct koneplus_mouse_report_button {
161 uint8_t report_number; /* always KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON */
162 uint8_t zero1;
163 uint8_t type;
164 uint8_t data1;
165 uint8_t data2;
166 uint8_t zero2;
167 uint8_t unknown[2];
Jiri Kosina4d043102010-12-09 14:29:34 +0100168} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000169
170enum koneplus_mouse_report_button_types {
171 /* data1 = new profile range 1-5 */
172 KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE = 0x20,
173
174 /* data1 = button number range 1-24; data2 = action */
175 KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH = 0x60,
176
177 /* data1 = button number range 1-24; data2 = action */
178 KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER = 0x80,
179
180 /* data1 = setting number range 1-5 */
181 KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_CPI = 0xb0,
182
183 /* data1 and data2 = range 0x1-0xb */
184 KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_SENSITIVITY = 0xc0,
185
186 /* data1 = 22 = next track...
187 * data2 = action
188 */
189 KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_MULTIMEDIA = 0xf0,
Stefan Achatz6d1dec82011-05-29 19:32:57 +0200190 KONEPLUS_MOUSE_REPORT_TALK = 0xff,
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000191};
192
193enum koneplus_mouse_report_button_action {
194 KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS = 0,
195 KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_RELEASE = 1,
196};
197
198struct koneplus_roccat_report {
199 uint8_t type;
200 uint8_t data1;
201 uint8_t data2;
202 uint8_t profile;
Jiri Kosina4d043102010-12-09 14:29:34 +0100203} __attribute__ ((__packed__));
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000204
205struct koneplus_device {
206 int actual_profile;
207
208 int roccat_claimed;
209 int chrdev_minor;
210
211 struct mutex koneplus_lock;
212
Stefan Achatz47dbdbff2010-11-26 19:57:42 +0000213 struct koneplus_info info;
214 struct koneplus_profile_settings profile_settings[5];
215 struct koneplus_profile_buttons profile_buttons[5];
216};
217
218#endif