uinput-mapper/custom_map.h

102 lines
2.7 KiB
C
Raw Normal View History

2012-12-04 14:05:00 -05:00
#ifndef H_GLOBAL_MAP
#define H_GLOBAL_MAP
/* Set up amount of joysticks here */
#define JOYCOUNT 2
/* Set up event to read from */
#define INPUT_PATH "/dev/input/by-path/platform-i8042-serio-0-event-kbd"
2012-12-04 14:26:33 -05:00
#endif
2012-12-04 14:05:00 -05:00
#ifdef H_CONFIGURE_JOYSTICKS
#ifndef H_CONFIGURE_JOYSTICKS_SEEN
#define H_CONFIGURE_JOYSTICKS_SEEN
#define JOYSTICK_ADD_KEY(key, bit, device) \
printf("JOYSTICK_ADD_KEY for device %d, key %s, bit: %s\n", device, #key, #bit); \
if(device == j && ioctl(js[device], bit, key) < 0) { \
perror("Error in JOYSTICK_ADD_KEY"); \
fprintf(stderr, "ERROR: JOYSTICK_ADD_KEY for device %d, key %s, bit: %s\n", device, #key, #bit); \
return 1; \
}
#define JOYSTICK_SET_LIM(lim, val, key) \
uidev.lim[key] = val;
/* Configure first joystick */
JOYSTICK_ADD_KEY(ABS_HAT0X, UI_SET_ABSBIT, 0)
JOYSTICK_SET_LIM(absmax, 1, ABS_HAT0X)
JOYSTICK_SET_LIM(absmin, -1, ABS_HAT0X)
JOYSTICK_ADD_KEY(ABS_HAT0Y, UI_SET_ABSBIT, 0)
JOYSTICK_SET_LIM(absmax, 1, ABS_HAT0Y)
JOYSTICK_SET_LIM(absmin, -1, ABS_HAT0Y)
JOYSTICK_ADD_KEY(BTN_JOYSTICK, UI_SET_KEYBIT, 0)
JOYSTICK_ADD_KEY(BTN_0, UI_SET_KEYBIT, 0)
JOYSTICK_ADD_KEY(BTN_1, UI_SET_KEYBIT, 0)
JOYSTICK_ADD_KEY(BTN_2, UI_SET_KEYBIT, 0)
JOYSTICK_ADD_KEY(BTN_3, UI_SET_KEYBIT, 0)
JOYSTICK_ADD_KEY(ABS_HAT0X, UI_SET_ABSBIT, 1)
2012-12-04 17:59:38 -05:00
JOYSTICK_SET_LIM(absmax, 1, ABS_HAT0X)
JOYSTICK_SET_LIM(absmin, -1, ABS_HAT0X)
JOYSTICK_ADD_KEY(ABS_HAT0Y, UI_SET_ABSBIT, 1)
2012-12-04 17:59:38 -05:00
JOYSTICK_SET_LIM(absmax, 1, ABS_HAT0X)
JOYSTICK_SET_LIM(absmin, -1, ABS_HAT0X)
JOYSTICK_ADD_KEY(BTN_JOYSTICK, UI_SET_KEYBIT, 1)
JOYSTICK_ADD_KEY(BTN_0, UI_SET_KEYBIT, 1)
JOYSTICK_ADD_KEY(BTN_1, UI_SET_KEYBIT, 1)
JOYSTICK_ADD_KEY(BTN_2, UI_SET_KEYBIT, 1)
JOYSTICK_ADD_KEY(BTN_3, UI_SET_KEYBIT, 1)
#endif
#endif
2012-12-04 14:05:00 -05:00
/* Now follows keymapping, do not touch ifdef */
#ifdef H_IN_CASE
#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, -)
2012-12-04 14:34:38 -05:00
KEYMAP(KEY_DOWN, ABS_HAT0Y, EV_ABS, 0, +)
KEYMAP(KEY_LEFT, ABS_HAT0X, EV_ABS, 0, -)
2012-12-04 14:34:38 -05:00
KEYMAP(KEY_RIGHT, ABS_HAT0X, EV_ABS, 0, +)
/* Red buttons */
2012-12-04 14:34:38 -05:00
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 */
2012-12-04 14:34:38 -05:00
KEYMAP(KEY_1, BTN_3, EV_KEY, 0, +)
/* Second joystick */
/* HAT*/
KEYMAP(KEY_R, ABS_HAT0Y, EV_ABS, 1, -)
2012-12-04 14:34:38 -05:00
KEYMAP(KEY_F, ABS_HAT0Y, EV_ABS, 1, +)
KEYMAP(KEY_D, ABS_HAT0X, EV_ABS, 1, -)
2012-12-04 14:34:38 -05:00
KEYMAP(KEY_G, ABS_HAT0X, EV_ABS, 1, +)
/* Red buttons */
2012-12-04 14:34:38 -05:00
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 */
2012-12-04 14:34:38 -05:00
KEYMAP(KEY_2, BTN_3, EV_KEY, 1, +)
2012-12-04 14:05:00 -05:00
#endif