mirror of
https://github.com/moparisthebest/uinput-mapper
synced 2024-11-25 17:02:15 -05:00
More configuration.
This commit is contained in:
parent
161f401ab4
commit
5178c63e1a
23
custom_map.h
23
custom_map.h
@ -66,9 +66,19 @@
|
||||
#ifndef H_CONFIGURE_JOYSTICKS_SEEN
|
||||
#define H_CONFIGURE_JOYSTICKS_SEEN
|
||||
|
||||
#define JOYSTICK_SET_OPT(opt, bit, device) \
|
||||
if (device == j) { \
|
||||
if (ioctl(js[device], bit, opt) < 0) { \
|
||||
perror("Error in JOYSTICK_SET_OPT"); \
|
||||
fprintf(stderr, "ERROR: JOYSTICK_SET_OPT for device %d, opt %s, bit: %s\n", device, #opt, #bit); \
|
||||
} else { \
|
||||
printf("JOYSTICK_SET_OPT for device %d, opt %s, bit: %s\n", device, #opt, #bit); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define JOYSTICK_ADD_KEY(key, bit, device) \
|
||||
if (device == j) { \
|
||||
if(ioctl(js[device], bit, key) < 0) { \
|
||||
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; \
|
||||
@ -83,10 +93,16 @@
|
||||
|
||||
/* Configure first joystick.
|
||||
*
|
||||
* Here we just tell the program what keys we want to use.
|
||||
* Here we just tell the program what keys event we will expose and what
|
||||
* keys we want to use.
|
||||
*
|
||||
* If a key is not enabled here, it will never be passed.
|
||||
*/
|
||||
|
||||
/* We want to send ABS and KEY events */
|
||||
JOYSTICK_SET_OPT(EV_ABS, UI_SET_EVBIT, 0)
|
||||
JOYSTICK_SET_OPT(EV_KEY, UI_SET_EVBIT, 0)
|
||||
|
||||
/* Hats:
|
||||
* We set the absmax and absmin; otherwise the hats make no sense.
|
||||
*/
|
||||
@ -107,6 +123,9 @@ 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_SET_OPT(EV_ABS, UI_SET_EVBIT, 1)
|
||||
JOYSTICK_SET_OPT(EV_KEY, UI_SET_EVBIT, 1)
|
||||
|
||||
JOYSTICK_ADD_KEY(ABS_HAT0X, UI_SET_ABSBIT, 1)
|
||||
JOYSTICK_SET_LIM(absmax, 1, ABS_HAT0X)
|
||||
JOYSTICK_SET_LIM(absmin, -1, ABS_HAT0X)
|
||||
|
11
map.c
11
map.c
@ -104,17 +104,6 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Register device opts */
|
||||
if (ioctl(js[j], UI_SET_EVBIT, EV_ABS) < 0) {
|
||||
perror("ioctl EV_ABS");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ioctl(js[j], UI_SET_EVBIT, EV_KEY) < 0) {
|
||||
perror("ioctl EV_KEY");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define H_CONFIGURE_JOYSTICKS
|
||||
#include "custom_map.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user