Linux Audio

Check our new training course

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