Some debug and fixes.

This commit is contained in:
Merlijn Wajer 2012-12-05 00:13:19 +01:00
parent 7d83ea86db
commit 11909fb055
2 changed files with 26 additions and 9 deletions

View File

@ -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

1
map.c
View File

@ -160,6 +160,7 @@ int main(int argc, char** argv) {
nowrite = 1;
}
if (nowrite == 0) {
printf("Writing %d to %d\n", e.code, j);
if(write(js[j], &je, sizeof(struct input_event)) < 0) {
perror("EV_ABS Write event");
return -1;