mirror of
https://github.com/moparisthebest/uinput-mapper
synced 2024-11-22 08:12:14 -05:00
Some debug and fixes.
This commit is contained in:
parent
7d83ea86db
commit
11909fb055
34
custom_map.h
34
custom_map.h
@ -15,31 +15,45 @@
|
||||
#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; \
|
||||
if (device == j) { \
|
||||
if(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; \
|
||||
} else { \
|
||||
printf("JOYSTICK_ADD_KEY for device %d, key %s, bit: %s\n", device, #key, #bit); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define JOYSTICK_SET_LIM(lim, val, key) \
|
||||
uidev.lim[key] = val;
|
||||
|
||||
/* Configure first joystick */
|
||||
/* Configure first joystick.
|
||||
*
|
||||
* Here we just tell the program what keys we want to use.
|
||||
* If a key is not enabled here, it will never be passed.
|
||||
*/
|
||||
|
||||
/* Hats.
|
||||
*
|
||||
* We set the absmax and absmin; otherwise the hats make no sense.
|
||||
*/
|
||||
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)
|
||||
|
||||
/* Buttons. */
|
||||
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)
|
||||
|
||||
/* Second joystick ; same comments as first one */
|
||||
JOYSTICK_ADD_KEY(ABS_HAT0X, UI_SET_ABSBIT, 1)
|
||||
JOYSTICK_SET_LIM(absmax, 1, ABS_HAT0X)
|
||||
JOYSTICK_SET_LIM(absmin, -1, ABS_HAT0X)
|
||||
@ -58,6 +72,8 @@ JOYSTICK_ADD_KEY(BTN_3, UI_SET_KEYBIT, 1)
|
||||
|
||||
/* Now follows keymapping, do not touch ifdef */
|
||||
#ifdef H_IN_CASE
|
||||
#ifndef H_IN_CASE_SEEN
|
||||
#define H_IN_CASE_SEEN
|
||||
#define KEYMAP(in_key, out_key, out_type, device, val) \
|
||||
case in_key: \
|
||||
je.type = out_type; \
|
||||
@ -84,7 +100,7 @@ KEYMAP(KEY_1, BTN_3, EV_KEY, 0, +)
|
||||
|
||||
/* Second joystick */
|
||||
|
||||
/* HAT*/
|
||||
/* 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, -)
|
||||
@ -98,4 +114,4 @@ KEYMAP(KEY_Q, BTN_2, EV_KEY, 1, +)
|
||||
/* Yellow button */
|
||||
KEYMAP(KEY_2, BTN_3, EV_KEY, 1, +)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user