Skip to content

Commit 7b89a3b

Browse files
authoredMay 26, 2020
Merge pull request #57 from infinitekh/master
Add support of right side modifier keys.
2 parents 1b7f67d + 1225425 commit 7b89a3b

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed
 

‎common.c

+26
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ static const keymap_entry keymap[] =
184184
{"XF86AudioRaiseVolume", 0x80},
185185
{"XF86AudioLowerVolume", 0x81},
186186
{"<82>", 0x82},
187+
{"Hangul", 0x82},
187188
{"<83>", 0x83},
189+
{"Hangul_Hanja",0x83},
188190
{"A", 0x84},
189191
{"B", 0x85},
190192
{"C", 0x86},
@@ -326,6 +328,30 @@ Bool parse_modifier(const char *arg, enum modifier *mod) {
326328
} else if (strcasecmp("shift", arg) == 0) {
327329
*mod = SHIFT;
328330
return 1;
331+
} else if (strcasecmp("l_ctrl", arg) == 0) {
332+
*mod = CTRL;
333+
return 1;
334+
} else if (strcasecmp("l_alt", arg) == 0) {
335+
*mod = ALT;
336+
return 1;
337+
} else if (strcasecmp("l_win", arg) == 0) {
338+
*mod = WIN;
339+
return 1;
340+
} else if (strcasecmp("l_shift", arg) == 0) {
341+
*mod = SHIFT;
342+
return 1;
343+
} else if (strcasecmp("r_ctrl", arg) == 0) {
344+
*mod = R_CTRL;
345+
return 1;
346+
} else if (strcasecmp("r_alt", arg) == 0) {
347+
*mod = R_ALT;
348+
return 1;
349+
} else if (strcasecmp("r_win", arg) == 0) {
350+
*mod = R_WIN;
351+
return 1;
352+
} else if (strcasecmp("r_shift", arg) == 0) {
353+
*mod = R_SHIFT;
354+
return 1;
329355
}
330356
return 0;
331357
}

‎common.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ enum modifier {
2727
SHIFT = 2,
2828
ALT = 4,
2929
WIN = 8,
30+
R_CTRL = 16,
31+
R_SHIFT = 32,
32+
R_ALT = 64,
33+
R_WIN = 128,
3034
};
3135

3236
enum mouse_button {

‎footswitch.c

+17-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void usage() {
6363
" -S rstring - append the specified raw string (hex numbers delimited with spaces)\n"
6464
" -a key - append the specified key\n"
6565
" -k key - write the specified key\n"
66-
" -m modifier - ctrl|shift|alt|win\n"
66+
" -m modifier - (l_,r_)ctrl|shift|alt|win\n"
6767
" -b button - mouse_left|mouse_middle|mouse_right\n"
6868
" -x X - move the mouse cursor horizontally by X pixels\n"
6969
" -y Y - move the mouse cursor vertically by Y pixels\n"
@@ -168,16 +168,28 @@ void print_mouse(unsigned char data[]) {
168168
void print_key(unsigned char data[]) {
169169
char combo[128] = {0};
170170
if ((data[2] & CTRL) != 0) {
171-
strcat(combo, "ctrl+");
171+
strcat(combo, "l_ctrl+");
172172
}
173173
if ((data[2] & SHIFT) != 0) {
174-
strcat(combo, "shift+");
174+
strcat(combo, "l_shift+");
175175
}
176176
if ((data[2] & ALT) != 0) {
177-
strcat(combo, "alt+");
177+
strcat(combo, "l_alt+");
178178
}
179179
if ((data[2] & WIN) != 0) {
180-
strcat(combo, "win+");
180+
strcat(combo, "l_win+");
181+
}
182+
if ((data[2] & R_CTRL) != 0) {
183+
strcat(combo, "r_ctrl+");
184+
}
185+
if ((data[2] & R_SHIFT) != 0) {
186+
strcat(combo, "r_shift+");
187+
}
188+
if ((data[2] & R_ALT) != 0) {
189+
strcat(combo, "r_alt+");
190+
}
191+
if ((data[2] & R_WIN) != 0) {
192+
strcat(combo, "r_win+");
181193
}
182194
if (data[3] != 0) {
183195
const char *key = decode_byte(data[3]);

0 commit comments

Comments
 (0)