From 9a551f21f2e6617e086998b15de2d7a307848668 Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Tue, 11 Dec 2012 17:41:21 +0100 Subject: [PATCH] Allow multiple input devices. --- config_functions.h | 4 ++-- confs/mulitput.h | 34 ++++++++++++++++++---------------- confs/techinc_arcade.h | 39 +++++++++++++++++++++------------------ map.c | 8 ++++---- 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/config_functions.h b/config_functions.h index acd467c..e8b132a 100644 --- a/config_functions.h +++ b/config_functions.h @@ -40,8 +40,8 @@ macro \ } -#define KEYMAP(in_type, in_key, out_key, out_type, device, val) \ - if(e.type == in_type && e.code == in_key) {\ +#define KEYMAP(in_type, in_key, out_key, out_type, device, in_device, val) \ + if(e.type == in_type && e.code == in_key && (in_device == -1 || in_device == fdrr)) {\ je.type = out_type; \ je.code = out_key; \ je.value = val(e.value); \ diff --git a/confs/mulitput.h b/confs/mulitput.h index 6a7f64d..0427aad 100644 --- a/confs/mulitput.h +++ b/confs/mulitput.h @@ -66,6 +66,8 @@ /* Set up amount of input devices here */ #define INPUT_DEVICE_COUNT 2 +#define INPUT_DEVICE_ANY 0 + #endif /* -------------------------------------------------------------------------- */ @@ -156,36 +158,36 @@ JOYSTICK_ADD_KEY(BTN_3, UI_SET_KEYBIT, 1) LEGAL_VALUE(e.value == 1 || e.value == 0, /* HAT */ - KEYMAP(EV_KEY, KEY_UP, ABS_HAT0Y, EV_ABS, 0, -) - KEYMAP(EV_KEY, KEY_DOWN, ABS_HAT0Y, EV_ABS, 0, +) - KEYMAP(EV_KEY, KEY_LEFT, ABS_HAT0X, EV_ABS, 0, -) - KEYMAP(EV_KEY, KEY_RIGHT, ABS_HAT0X, EV_ABS, 0, +) + KEYMAP(EV_KEY, KEY_UP, ABS_HAT0Y, EV_ABS, 0, -1, -) + KEYMAP(EV_KEY, KEY_DOWN, ABS_HAT0Y, EV_ABS, 0, -1, +) + KEYMAP(EV_KEY, KEY_LEFT, ABS_HAT0X, EV_ABS, 0, -1, -) + KEYMAP(EV_KEY, KEY_RIGHT, ABS_HAT0X, EV_ABS, 0, -1, +) /* Red buttons */ - KEYMAP(EV_KEY, KEY_LEFTCTRL, BTN_0, EV_KEY, 0, +) - KEYMAP(EV_KEY, KEY_LEFTALT, BTN_1, EV_KEY, 0, +) - KEYMAP(EV_KEY, KEY_SPACE, BTN_2, EV_KEY, 0, +) + KEYMAP(EV_KEY, KEY_LEFTCTRL, BTN_0, EV_KEY, 0, -1, +) + KEYMAP(EV_KEY, KEY_LEFTALT, BTN_1, EV_KEY, 0, -1, +) + KEYMAP(EV_KEY, KEY_SPACE, BTN_2, EV_KEY, 0, -1, +) /* Yellow button */ - KEYMAP(EV_KEY, KEY_1, BTN_3, EV_KEY, 0, +) + KEYMAP(EV_KEY, KEY_1, BTN_3, EV_KEY, 0, -1, +) ) /* Second joystick */ LEGAL_VALUE(e.value == 1 || e.value == 0, /* HAT */ - KEYMAP(EV_KEY, KEY_R, ABS_HAT0Y, EV_ABS, 1, -) - KEYMAP(EV_KEY, KEY_F, ABS_HAT0Y, EV_ABS, 1, +) - KEYMAP(EV_KEY, KEY_D, ABS_HAT0X, EV_ABS, 1, -) - KEYMAP(EV_KEY, KEY_G, ABS_HAT0X, EV_ABS, 1, +) + KEYMAP(EV_KEY, KEY_R, ABS_HAT0Y, EV_ABS, 1, -1, -) + KEYMAP(EV_KEY, KEY_F, ABS_HAT0Y, EV_ABS, 1, -1, +) + KEYMAP(EV_KEY, KEY_D, ABS_HAT0X, EV_ABS, 1, -1, -) + KEYMAP(EV_KEY, KEY_G, ABS_HAT0X, EV_ABS, 1, -1, +) /* Red buttons */ - KEYMAP(EV_KEY, KEY_A, BTN_0, EV_KEY, 1, +) - KEYMAP(EV_KEY, KEY_S, BTN_1, EV_KEY, 1, +) - KEYMAP(EV_KEY, KEY_Q, BTN_2, EV_KEY, 1, +) + KEYMAP(EV_KEY, KEY_A, BTN_0, EV_KEY, 1, -1, +) + KEYMAP(EV_KEY, KEY_S, BTN_1, EV_KEY, 1, -1, +) + KEYMAP(EV_KEY, KEY_Q, BTN_2, EV_KEY, 1, -1, +) /* Yellow button */ - KEYMAP(EV_KEY, KEY_2, BTN_3, EV_KEY, 1, +) + KEYMAP(EV_KEY, KEY_2, BTN_3, EV_KEY, 1, -1, +) ) #endif diff --git a/confs/techinc_arcade.h b/confs/techinc_arcade.h index 3a86ff6..3ef01cf 100644 --- a/confs/techinc_arcade.h +++ b/confs/techinc_arcade.h @@ -64,7 +64,9 @@ #define JOYCOUNT 2 /* Set up amount of input devices here */ -#define INPUT_DEVICE_COUNT 1 +#define INPUT_DEVICE_COUNT 2 + +#define INPUT_DEVICE_ANY 0 #endif @@ -76,7 +78,8 @@ #ifndef H_CONFIGURE_EVENTS_SEEN #define H_CONFIGURE_EVENTS_SEEN -ADD_INPUT_PATH("/dev/input/by-path/platform-i8042-serio-0-event-kbd", 0) +ADD_INPUT_PATH("/dev/input/by-id/usb-Cypress_I-PAC_Arcade_Control_Interface-event-kbd", 0) +ADD_INPUT_PATH("usb-Dell_Dell_USB_Keyboard-event-kbd", 1) #endif #endif @@ -155,36 +158,36 @@ JOYSTICK_ADD_KEY(BTN_3, UI_SET_KEYBIT, 1) LEGAL_VALUE(e.value == 1 || e.value == 0, /* HAT */ - KEYMAP(EV_KEY, KEY_UP, ABS_HAT0Y, EV_ABS, 0, -) - KEYMAP(EV_KEY, KEY_DOWN, ABS_HAT0Y, EV_ABS, 0, +) - KEYMAP(EV_KEY, KEY_LEFT, ABS_HAT0X, EV_ABS, 0, -) - KEYMAP(EV_KEY, KEY_RIGHT, ABS_HAT0X, EV_ABS, 0, +) + KEYMAP(EV_KEY, KEY_UP, ABS_HAT0Y, EV_ABS, 0, -1, -) + KEYMAP(EV_KEY, KEY_DOWN, ABS_HAT0Y, EV_ABS, 0, -1, +) + KEYMAP(EV_KEY, KEY_LEFT, ABS_HAT0X, EV_ABS, 0, -1, -) + KEYMAP(EV_KEY, KEY_RIGHT, ABS_HAT0X, EV_ABS, 0, -1, +) /* Red buttons */ - KEYMAP(EV_KEY, KEY_LEFTCTRL, BTN_0, EV_KEY, 0, +) - KEYMAP(EV_KEY, KEY_LEFTALT, BTN_1, EV_KEY, 0, +) - KEYMAP(EV_KEY, KEY_SPACE, BTN_2, EV_KEY, 0, +) + KEYMAP(EV_KEY, KEY_LEFTCTRL, BTN_0, EV_KEY, 0, -1, +) + KEYMAP(EV_KEY, KEY_LEFTALT, BTN_1, EV_KEY, 0, -1, +) + KEYMAP(EV_KEY, KEY_SPACE, BTN_2, EV_KEY, 0, -1, +) /* Yellow button */ - KEYMAP(EV_KEY, KEY_1, BTN_3, EV_KEY, 0, +) + KEYMAP(EV_KEY, KEY_1, BTN_3, EV_KEY, 0, -1, +) ) /* Second joystick */ LEGAL_VALUE(e.value == 1 || e.value == 0, /* HAT */ - KEYMAP(EV_KEY, KEY_R, ABS_HAT0Y, EV_ABS, 1, -) - KEYMAP(EV_KEY, KEY_F, ABS_HAT0Y, EV_ABS, 1, +) - KEYMAP(EV_KEY, KEY_D, ABS_HAT0X, EV_ABS, 1, -) - KEYMAP(EV_KEY, KEY_G, ABS_HAT0X, EV_ABS, 1, +) + KEYMAP(EV_KEY, KEY_R, ABS_HAT0Y, EV_ABS, 1, -1, -) + KEYMAP(EV_KEY, KEY_F, ABS_HAT0Y, EV_ABS, 1, -1, +) + KEYMAP(EV_KEY, KEY_D, ABS_HAT0X, EV_ABS, 1, -1, -) + KEYMAP(EV_KEY, KEY_G, ABS_HAT0X, EV_ABS, 1, -1, +) /* Red buttons */ - KEYMAP(EV_KEY, KEY_A, BTN_0, EV_KEY, 1, +) - KEYMAP(EV_KEY, KEY_S, BTN_1, EV_KEY, 1, +) - KEYMAP(EV_KEY, KEY_Q, BTN_2, EV_KEY, 1, +) + KEYMAP(EV_KEY, KEY_A, BTN_0, EV_KEY, 1, -1, +) + KEYMAP(EV_KEY, KEY_S, BTN_1, EV_KEY, 1, -1, +) + KEYMAP(EV_KEY, KEY_Q, BTN_2, EV_KEY, 1, -1, +) /* Yellow button */ - KEYMAP(EV_KEY, KEY_2, BTN_3, EV_KEY, 1, +) + KEYMAP(EV_KEY, KEY_2, BTN_3, EV_KEY, 1, -1, +) ) #endif diff --git a/map.c b/map.c index de9268a..6e177cd 100644 --- a/map.c +++ b/map.c @@ -172,10 +172,6 @@ int main(int argc, char** argv) { printf("Event: (Type: %d, Code: %d, Value %d)\n", e.type, e.code, e.value); } - /* Update poll read mechanism */ - fdrr = (fdrr + 1) % INPUT_DEVICE_COUNT; - rfds -= 1; - /* Now handle received event */ memset(&je, '\0', sizeof(struct input_event)); nowrite = 1; @@ -184,6 +180,10 @@ int main(int argc, char** argv) { #define H_JOYMAP #include "config.h" + /* Update poll read mechanism */ + fdrr = (fdrr + 1) % INPUT_DEVICE_COUNT; + rfds -= 1; + if (nowrite == 0) { printf("Writing %d to %d\n", e.code, j); if(write(js[j], &je, sizeof(struct input_event)) < 0) {