mirror of
https://github.com/moparisthebest/uinput-mapper
synced 2024-11-15 21:25:01 -05:00
Input mapping is now completely macroed.
This commit is contained in:
parent
36ad37749c
commit
81ad877ce2
39
custom_map.h
Normal file
39
custom_map.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#define KEYMAP(in_key, out_key, out_type, device, val) \
|
||||||
|
case in_key: \
|
||||||
|
je.type = out_type; \
|
||||||
|
je.code = out_key; \
|
||||||
|
je.value = val(e.value); \
|
||||||
|
j = device; \
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* First joystick */
|
||||||
|
|
||||||
|
/* HAT */
|
||||||
|
KEYMAP(KEY_UP, ABS_HAT0Y, EV_ABS, 0, -)
|
||||||
|
KEYMAP(KEY_DOWN, ABS_HAT0Y, EV_ABS, 0, )
|
||||||
|
KEYMAP(KEY_LEFT, ABS_HAT0X, EV_ABS, 0, -)
|
||||||
|
KEYMAP(KEY_RIGHT, ABS_HAT0X, EV_ABS, 0, )
|
||||||
|
|
||||||
|
/* Red buttons */
|
||||||
|
KEYMAP(KEY_LEFTCTRL, BTN_0, EV_KEY, 0, )
|
||||||
|
KEYMAP(KEY_LEFTALT, BTN_1, EV_KEY, 0, )
|
||||||
|
KEYMAP(KEY_SPACE, BTN_2, EV_KEY, 0, )
|
||||||
|
|
||||||
|
/* Yellow button */
|
||||||
|
KEYMAP(KEY_1, BTN_3, EV_KEY, 0, )
|
||||||
|
|
||||||
|
/* Second joystick */
|
||||||
|
|
||||||
|
/* HAT*/
|
||||||
|
KEYMAP(KEY_R, ABS_HAT0Y, EV_ABS, 1, -)
|
||||||
|
KEYMAP(KEY_F, ABS_HAT0Y, EV_ABS, 1, )
|
||||||
|
KEYMAP(KEY_D, ABS_HAT0X, EV_ABS, 1, -)
|
||||||
|
KEYMAP(KEY_G, ABS_HAT0X, EV_ABS, 1, )
|
||||||
|
|
||||||
|
/* Red buttons */
|
||||||
|
KEYMAP(KEY_A, BTN_0, EV_KEY, 1, )
|
||||||
|
KEYMAP(KEY_S, BTN_1, EV_KEY, 1, )
|
||||||
|
KEYMAP(KEY_Q, BTN_2, EV_KEY, 1, )
|
||||||
|
|
||||||
|
/* Yellow button */
|
||||||
|
KEYMAP(KEY_2, BTN_3, EV_KEY, 1,)
|
36
map.c
36
map.c
@ -176,41 +176,13 @@ int main(int argc, char** argv) {
|
|||||||
nowrite = 0;
|
nowrite = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
|
|
||||||
/* Only catch keys and ignore auto-repeat (value == 2) */
|
/* Only catch keys and ignore auto-repeat (value == 2) */
|
||||||
if (e.type == EV_KEY && e.value != 2) {
|
if (e.type == EV_KEY && e.value != 2) {
|
||||||
switch(e.code) {
|
switch(e.code) {
|
||||||
case KEY_UP:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0Y; je.value = -e.value; j = 0; break;
|
#include "custom_map.h"
|
||||||
case KEY_DOWN:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0Y; je.value = e.value; j = 0; break;
|
|
||||||
case KEY_LEFT:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0X; je.value = -e.value; j = 0; break;
|
|
||||||
case KEY_RIGHT:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0X; je.value = e.value; j = 0; break;
|
|
||||||
case KEY_LEFTCTRL:
|
|
||||||
je.type = EV_KEY; je.code = BTN_0; je.value = e.value; j = 0; break;
|
|
||||||
case KEY_LEFTALT:
|
|
||||||
je.type = EV_KEY; je.code = BTN_1; je.value = e.value; j = 0; break;
|
|
||||||
case KEY_SPACE:
|
|
||||||
je.type = EV_KEY; je.code = BTN_2; je.value = e.value; j = 0; break;
|
|
||||||
case KEY_1:
|
|
||||||
je.type = EV_KEY; je.code = BTN_3; je.value = e.value; j = 0; break;
|
|
||||||
case KEY_R:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0Y; je.value = -e.value; j = 1; break;
|
|
||||||
case KEY_F:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0Y; je.value = e.value; j = 1; break;
|
|
||||||
case KEY_D:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0X; je.value = -e.value; j = 1; break;
|
|
||||||
case KEY_G:
|
|
||||||
je.type = EV_ABS; je.code = ABS_HAT0X; je.value = e.value; j = 1; break;
|
|
||||||
case KEY_A:
|
|
||||||
je.type = EV_KEY; je.code = BTN_0; je.value = e.value; j = 1; break;
|
|
||||||
case KEY_S:
|
|
||||||
je.type = EV_KEY; je.code = BTN_1; je.value = e.value; j = 1; break;
|
|
||||||
case KEY_Q:
|
|
||||||
je.type = EV_KEY; je.code = BTN_2; je.value = e.value; j = 1; break;
|
|
||||||
case KEY_2:
|
|
||||||
je.type = EV_KEY; je.code = BTN_3; je.value = e.value; j = 1; break;
|
|
||||||
default:
|
default:
|
||||||
nowrite = 1;
|
nowrite = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user