7 {
"esc", 0x00, KEY_ESC },
8 {
"f1", 0x0c, KEY_F1 },
9 {
"f2", 0x18, KEY_F2 },
10 {
"f3", 0x24, KEY_F3 },
11 {
"f4", 0x30, KEY_F4 },
12 {
"f5", 0x3c, KEY_F5 },
13 {
"f6", 0x48, KEY_F6 },
14 {
"f7", 0x54, KEY_F7 },
15 {
"f8", 0x60, KEY_F8 },
16 {
"f9", 0x6c, KEY_F9 },
17 {
"f10", 0x78, KEY_F10 },
18 {
"f11", 0x84, KEY_F11 },
19 {
"grave", 0x01, KEY_GRAVE },
30 {
"minus", 0x85, KEY_MINUS },
31 {
"tab", 0x02, KEY_TAB },
42 {
"lbrace", 0x86, KEY_LEFTBRACE },
43 {
"caps", 0x03, KEY_CAPSLOCK },
53 {
"colon", 0x7b, KEY_SEMICOLON },
54 {
"quote", 0x87, KEY_APOSTROPHE },
55 {
"lshift", 0x04, KEY_LEFTSHIFT },
56 {
"bslash_iso", 0x10, KEY_102ND },
64 {
"comma", 0x70, KEY_COMMA },
65 {
"dot", 0x7c, KEY_DOT },
66 {
"slash", 0x88, KEY_SLASH },
67 {
"lctrl", 0x05, KEY_LEFTCTRL },
68 {
"lwin", 0x11, KEY_LEFTMETA },
69 {
"lalt", 0x1d, KEY_LEFTALT },
71 {
"space", 0x35, KEY_SPACE },
73 {
"katahira", 0x4d, KEY_KATAKANAHIRAGANA },
74 {
"ralt", 0x59, KEY_RIGHTALT },
75 {
"rwin", 0x65, KEY_RIGHTMETA },
76 {
"rmenu", 0x71, KEY_COMPOSE },
79 {
"f12", 0x06, KEY_F12 },
80 {
"prtscn", 0x12, KEY_SYSRQ },
81 {
"scroll", 0x1e, KEY_SCROLLLOCK },
82 {
"pause", 0x2a, KEY_PAUSE },
83 {
"ins", 0x36, KEY_INSERT },
84 {
"home", 0x42, KEY_HOME },
85 {
"pgup", 0x4e, KEY_PAGEUP },
86 {
"rbrace", 0x5a, KEY_RIGHTBRACE },
87 {
"bslash", 0x66, KEY_BACKSLASH },
89 {
"enter", 0x7e, KEY_ENTER },
90 {
"ro", 0x8a, KEY_RO },
91 {
"equal", 0x07, KEY_EQUAL },
92 {
"yen", 0x13, KEY_YEN },
93 {
"bspace", 0x1f, KEY_BACKSPACE },
94 {
"del", 0x2b, KEY_DELETE },
95 {
"end", 0x37, KEY_END },
96 {
"pgdn", 0x43, KEY_PAGEDOWN },
97 {
"rshift", 0x4f, KEY_RIGHTSHIFT },
98 {
"rctrl", 0x5b, KEY_RIGHTCTRL },
99 {
"up", 0x67, KEY_UP },
100 {
"left", 0x73, KEY_LEFT },
101 {
"down", 0x7f, KEY_DOWN },
102 {
"right", 0x8b, KEY_RIGHT },
104 {
"mute", 0x14, KEY_MUTE },
105 {
"stop", 0x20, KEY_STOPCD },
106 {
"prev", 0x2c, KEY_PREVIOUSSONG },
107 {
"play", 0x38, KEY_PLAYPAUSE },
108 {
"next", 0x44, KEY_NEXTSONG },
109 {
"numlock", 0x50, KEY_NUMLOCK },
110 {
"numslash", 0x5c, KEY_KPSLASH },
111 {
"numstar", 0x68, KEY_KPASTERISK },
112 {
"numminus", 0x74, KEY_KPMINUS },
113 {
"numplus", 0x80, KEY_KPPLUS },
114 {
"numenter", 0x8c, KEY_KPENTER },
115 {
"num7", 0x09, KEY_KP7 },
116 {
"num8", 0x15, KEY_KP8 },
117 {
"num9", 0x21, KEY_KP9 },
119 {
"num4", 0x39, KEY_KP4 },
120 {
"num5", 0x45, KEY_KP5 },
121 {
"num6", 0x51, KEY_KP6 },
122 {
"num1", 0x5d, KEY_KP1 },
123 {
"num2", 0x69, KEY_KP2 },
124 {
"num3", 0x75, KEY_KP3 },
125 {
"num0", 0x81, KEY_KP0 },
126 {
"numdot", 0x8d, KEY_KPDOT },
137 {
"volup", 0x20, KEY_VOLUMEUP },
138 {
"voldn", 0x2c, KEY_VOLUMEDOWN },
151 {
"muhenkan", 0x29, KEY_MUHENKAN },
152 {
"henkan", 0x41, KEY_HENKAN },
153 {
"fn", 0x65, KEY_FN },
188 {
"lightup", -1, KEY_BRIGHTNESSUP },
189 {
"lightdn", -1, KEY_BRIGHTNESSDOWN },
190 {
"eject", -1, KEY_EJECTCD },
191 {
"power", -1, KEY_POWER },
192 {
"f13", -1, KEY_F13 },
193 {
"f14", -1, KEY_F14 },
194 {
"f15", -1, KEY_F15 },
195 {
"f16", -1, KEY_F16 },
196 {
"f17", -1, KEY_F17 },
197 {
"f18", -1, KEY_F18 },
198 {
"f19", -1, KEY_F19 },
199 {
"f20", -1, KEY_F20 },
246 void hid_kb_translate(
unsigned char* kbinput,
int endpoint,
int length,
const unsigned char* urbinput){
252 static const short hid_codes[256] = {
253 -1, -1, -1, -1, 37, 54, 52, 39, 27, 40, 41, 42, 32, 43, 44, 45,
254 56, 55, 33, 34, 25, 28, 38, 29, 31, 53, 26, 51, 30, 50, 13, 14,
255 15, 16, 17, 18, 19, 20, 21, 22, 82, 0, 86, 24, 64, 23, 84, 35,
256 79, 80, 81, 46, 47, 12, 57, 58, 59, 36, 1, 2, 3, 4, 5, 6,
257 7, 8, 9, 10, 11, 72, 73, 74, 75, 76, 77, 78, 87, 88, 89, 95,
258 93, 94, 92, 102, 103, 104, 105, 106, 107, 115, 116, 117, 112, 113, 114, 108,
259 109, 110, 118, 119, 49, 69, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
260 -2, -2, -2, -2, -2, -2, -2, -2, 98, -2, -2, -2, -2, -2, -2, 97,
261 130, 131, -1, -1, -1, -2, -1, 83, 66, 85, 145, 144, -2, -1, -1, -1,
262 -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
263 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
264 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
265 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -3, -1, -1, -1,
266 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 136, 137, 138, 139, 140, 141,
267 60, 48, 62, 61, 91, 90, 67, 68, 142, 143, 99, 101, -2, 130, 131, 97,
268 -2, 133, 134, 135, -2, 96, -2, 132, -2, -2, 71, 71, 71, 71, -1, -1,
275 for(
int i = 0; i < 256; i++){
276 if(hid_codes[i] >= 0)
280 for(
int i = 0; i < 8; i++){
281 if((urbinput[0] >> i) & 1)
284 for(
int i = 2; i < length; i++){
286 int scan = hid_codes[urbinput[i]];
290 ckb_warn(
"Got unknown key press %d on EP 1\n", urbinput[i]);
296 if(urbinput[0] == 1){
300 for(
int bit = 0; bit < 8; bit++){
301 if((urbinput[1] >> bit) & 1)
306 for(
int byte = 0; byte < 19; byte++){
307 char input = urbinput[byte + 2];
308 for(
int bit = 0; bit < 8; bit++){
309 int keybit = byte * 8 + bit;
310 int scan = hid_codes[keybit];
311 if((input >> bit) & 1){
315 ckb_warn(
"Got unknown key press %d on EP 2\n", keybit);
321 }
else if (urbinput[0] == 2)
335 for(
int i = 0; i < length; i++){
365 for(
int bit = 0; bit < 8; bit++){
366 if((urbinput[0] >> bit) & 1)
371 for(
int byte = 0; byte < 14; byte++){
372 char input = urbinput[byte + 1];
373 for(
int bit = 0; bit < 8; bit++){
374 int keybit = byte * 8 + bit;
375 int scan = hid_codes[keybit];
376 if((input >> bit) & 1){
380 ckb_warn(
"Got unknown key press %d on EP 3\n", keybit);
389 #define BUTTON_HID_COUNT 5
391 void hid_mouse_translate(
unsigned char* kbinput,
short* xaxis,
short* yaxis,
int endpoint,
int length,
const unsigned char* urbinput,
ushort fwversion){
393 if((endpoint != 2 && endpoint != -2) || (fwversion < 0x300 && length < 10))
400 if(urbinput[1] & (1 << bit))
406 *xaxis += *(
short*)(urbinput + 5);
407 *yaxis += *(
short*)(urbinput + 7);
409 char wheel = urbinput[9];
420 void corsair_kbcopy(
unsigned char* kbinput,
int endpoint,
const unsigned char* urbinput){
421 if(endpoint == 2 || endpoint == -2){
430 if(endpoint == 2 || endpoint == -2){
437 uchar test = 1 << (bit % 8);
438 if(urbinput[byte] & test)
#define MOUSE_BUTTON_FIRST
#define CLEAR_KEYBIT(array, index)
const key keymap[(((152+22+12)+25)+12)]
#define KEY_BACKSLASH_ISO
#define SET_KEYBIT(array, index)
#define ckb_warn(fmt, args...)
void corsair_mousecopy(unsigned char *kbinput, int endpoint, const unsigned char *urbinput)
void hid_mouse_translate(unsigned char *kbinput, short *xaxis, short *yaxis, int endpoint, int length, const unsigned char *urbinput, ushort fwversion)
void hid_kb_translate(unsigned char *kbinput, int endpoint, int length, const unsigned char *urbinput)
#define MOUSE_EXTRA_FIRST
void corsair_kbcopy(unsigned char *kbinput, int endpoint, const unsigned char *urbinput)