ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
keymap.h
Go to the documentation of this file.
1 #ifndef KEYMAP_H
2 #define KEYMAP_H
3 
4 #include "keymap_mac.h"
5 
6 // Reserved keys (no input)
7 #define KEY_NONE -1
8 #define KEY_CORSAIR -2
9 #define KEY_UNBOUND -3
10 
11 // The mouse wheel is actually a relative axis, but we treat it like a pair of buttons
12 #define BTN_WHEELUP 0x1f01
13 #define BTN_WHEELDOWN 0x1f02
14 
15 #ifdef OS_MAC
16 // On Linux there's no meaningful distinction between these keys
17 // On OSX this is used for layout auto-detection (see input_mac.c)
18 #define KEY_BACKSLASH_ISO 0xfff
19 #else
20 #define KEY_BACKSLASH_ISO KEY_BACKSLASH
21 #endif
22 
23 // Number of keys, according to keyboard hardware (NOTE: should be divisible by 8)
24 #define N_KEYS_HW 152
25 #define N_KEYBYTES_HW ((N_KEYS_HW + 7) / 8)
26 // Light zones (have LED codes but don't generate input)
27 #define N_KEY_ZONES 22 // two strafe side lights (although really they are tied into one control) + logo backlight + Platinum top bar
28 // Additional keys recognized by the driver but may not be present on keyboard
29 #define N_KEYS_EXTRA 12
30 // Mouse buttons
31 #define N_BUTTONS_HW 20
32 #define N_BUTTONS_EXTENDED 25
33 #define MOUSE_BUTTON_FIRST (N_KEYS_HW + N_KEY_ZONES + N_KEYS_EXTRA)
34 #define MOUSE_EXTRA_FIRST (MOUSE_BUTTON_FIRST + N_BUTTONS_HW)
35 // Number of keys that generate input
36 #define N_KEYS_INPUT (MOUSE_BUTTON_FIRST + N_BUTTONS_EXTENDED)
37 #define N_KEYBYTES_INPUT ((N_KEYS_INPUT + 7) / 8)
38 // Mouse zones
39 #define LED_MOUSE N_KEYS_HW
40 #define N_MOUSE_ZONES 6
41 #define N_MOUSE_ZONES_EXTENDED 12
42 // Index of DPI light
43 #define LED_DPI (LED_MOUSE + 2)
44 // Total number of keys recognized by software
45 #define N_KEYS_EXTENDED (N_KEYS_INPUT + N_MOUSE_ZONES_EXTENDED)
46 #define N_KEYBYTES_EXTENDED ((N_KEYS_EXTENDED + 7) / 8)
47 
48 // Map from key name to LED code and USB scan code
49 typedef struct {
50  const char* name;
51  short led;
52  short scan;
53 } key;
54 
55 // Scancode divisions
56 #define SCAN_SILENT 0x8000
57 #define SCAN_KBD 0
58 #define SCAN_MOUSE 0x1000
59 
60 // List of keys, ordered according to where they appear in the keyboard input.
61 // Begins with keyboard keys, followed by extra keys, then mouse buttons, and finally LED zones
62 extern const key keymap[N_KEYS_EXTENDED];
63 
64 // Translates input from HID to a ckb input bitfield.
65 // Use positive endpoint for non-RGB keyboards, negative endpoint for RGB
66 void hid_kb_translate(unsigned char* kbinput, int endpoint, int length, const unsigned char* urbinput);
67 void hid_mouse_translate(unsigned char* kbinput, short* xaxis, short* yaxis, int endpoint, int length, const unsigned char* urbinput, ushort fwversion);
68 
69 // Copies input from Corsair reports
70 void corsair_kbcopy(unsigned char* kbinput, int endpoint, const unsigned char* urbinput);
71 void corsair_mousecopy(unsigned char* kbinput, int endpoint, const unsigned char* urbinput);
72 
73 #endif // KEYMAP_H
void hid_mouse_translate(unsigned char *kbinput, short *xaxis, short *yaxis, int endpoint, int length, const unsigned char *urbinput, ushort fwversion)
Definition: keymap.c:391
short scan
Definition: keymap.h:52
short led
Definition: keymap.h:51
Definition: keymap.h:49
void corsair_mousecopy(unsigned char *kbinput, int endpoint, const unsigned char *urbinput)
Definition: keymap.c:429
const key keymap[(((152+22+12)+25)+12)]
Definition: keymap.c:5
const char * name
Definition: keymap.h:50
unsigned short ushort
Definition: includes.h:25
void corsair_kbcopy(unsigned char *kbinput, int endpoint, const unsigned char *urbinput)
Definition: keymap.c:420
#define N_KEYS_EXTENDED
Definition: keymap.h:45
void hid_kb_translate(unsigned char *kbinput, int endpoint, int length, const unsigned char *urbinput)
Definition: keymap.c:246