-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardUtils.h
More file actions
55 lines (48 loc) · 1.2 KB
/
KeyboardUtils.h
File metadata and controls
55 lines (48 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/***********************************************************
* Utilities for decoding USB keyboard keys
***********************************************************/
#ifndef KEYBOARD_UTILS_H
#define KEYBOARD_UTILS_H
enum keyModCombos{
Ctrl = 1,
Shift, // 2
CtrlShift,
Alt, // 4
CtrlAlt,
AltShift,
CtrlAltShift,
Win, // 8
CtrlWin,
ShiftWin,
CtrlShiftWin,
AltWin,
CtrlAltWin,
AltShiftWin,
CtrlShiftAltWin // 15
};
// sucky messaging system
enum nonCharsAndShortcuts{
Esc = 128,
Enter,
Backspace,
Tab,
CtrlL,
CtrlAltDelete,
Left,
Right,
F5,
F6
};
// Right modifier keys are on bits 7..4 - we don't care, so squish them together
#define combineMods(mods) ((mods & 0b1111) | (mods >> 4))
/*
Returns the keycode cast to a char, which generally matches the character you expect.
For special keys, calls an appropriate function and returns 0 or something appropriate.
*/
unsigned char decodeKey(int key, int oemKey, int mods, int leds);
/*
Called from decodeKey; maps OEM keycodes (constant regardless of modifiers) + modifiers to functions
(Note that we only get 127 shortcuts - should be plenty though)
*/
unsigned char handleNonChar(int oemKey, int mods);
#endif