-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathkeymon_keys.c
More file actions
100 lines (88 loc) · 3 KB
/
keymon_keys.c
File metadata and controls
100 lines (88 loc) · 3 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <bits/input/key.h>
#include <bits/input/sws.h>
#include <string.h>
#include <format.h>
#include <util.h>
#include "keymon.h"
/* There are much more keys than listed here, but handling those with
keymon is not a good idea. So the list here is only for the keys
that are expected to be handle by keymon on regular basis. Anything
else can be configure with raw integer keycodes. */
static const struct key {
char name[16];
int code;
} keys[] = {
{ "Esc", KEY_ESC },
{ "Minus", KEY_MINUS },
{ "Equal", KEY_EQUAL },
{ "Backspace", KEY_BACKSPACE },
{ "Backslash", KEY_BACKSLASH },
{ "NumLock", KEY_NUMLOCK },
{ "ScrollLock", KEY_SCROLLLOCK },
{ "Space", KEY_SPACE },
{ "Del", KEY_DELETE },
{ "Delete", KEY_DELETE },
{ "PgUp", KEY_PAGEUP },
{ "PgDown", KEY_PAGEDOWN },
{ "Up", KEY_UP },
{ "Down", KEY_DOWN },
{ "Left", KEY_LEFT },
{ "Right", KEY_RIGHT },
{ "F1", KEY_F1 },
{ "F2", KEY_F2 },
{ "F3", KEY_F3 },
{ "F4", KEY_F4 },
{ "F5", KEY_F5 },
{ "F6", KEY_F6 },
{ "F7", KEY_F7 },
{ "F8", KEY_F8 },
{ "F9", KEY_F9 },
{ "F10", KEY_F10 },
{ "F11", KEY_F11 },
{ "F12", KEY_F12 },
{ "SysRq", KEY_SYSRQ },
{ "Mute", KEY_MUTE },
{ "Volume-", KEY_VOLUMEDOWN },
{ "Volume+", KEY_VOLUMEUP },
{ "Power", KEY_POWER },
{ "Pause", KEY_PAUSE },
{ "Sleep", KEY_SLEEP },
{ "Stop", KEY_STOP },
{ "Setup", KEY_SETUP },
{ "Scale", KEY_SCALE },
{ "WakeUp", KEY_WAKEUP },
{ "Brightness-", KEY_BRIGHTNESSDOWN },
{ "Brightness+", KEY_BRIGHTNESSUP },
{ "WWAN", KEY_WWAN },
{ "RFKill", KEY_RFKILL },
{ "MicMute", KEY_MICMUTE },
{ "Battery", KEY_BATTERY },
{ "Bluetooth", KEY_BLUETOOTH },
{ "WLAN", KEY_WLAN },
{ "UWB", KEY_UWB }
};
static const struct sw {
char name[12];
int code;
} sws[] = {
{ "Lid", SW_LID },
{ "Tablet", SW_TABLET_MODE },
{ "Headphone", SW_HEADPHONE_INSERT },
{ "Dock", SW_DOCK }
};
int find_key(char* name)
{
const struct key* ky;
const struct sw* sw;
int code;
char* p;
if((p = parseint(name, &code)) && !*p)
return code;
for(ky = keys; ky < ARRAY_END(keys); ky++)
if(!strncmp(ky->name, name, sizeof(ky->name)))
return ky->code;
for(sw = sws; sw < ARRAY_END(sws); sw++)
if(!strncmp(sw->name, name, sizeof(sw->name)))
return sw->code | CODE_SWITCH;
return 0;
}