uinput-mapper/c/config_functions.h

54 lines
1.6 KiB
C
Raw Normal View History

2012-12-04 18:49:41 -05:00
#ifndef H_CONFIG_FUNCTIONS
#define H_CONFIG_FUNCTIONS
2012-12-07 14:20:19 -05:00
#define ADD_INPUT_PATH(INPUT_PATH, NUM) \
/* Open input and uinput */ \
in[NUM] = open(INPUT_PATH, O_RDONLY); \
if(in[NUM] < 0) { \
perror("Could not open: " INPUT_PATH); \
return 1; \
}
2013-04-17 18:48:24 -04:00
#define MAPPER_SET_OPT(opt, bit, device) \
2012-12-04 18:49:41 -05:00
if (device == j) { \
2013-04-17 18:48:24 -04:00
printf("SET_OPT: %d, %ld, %d\n", opt, bit, device); \
2012-12-04 18:49:41 -05:00
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); \
} \
}
2013-04-17 18:48:24 -04:00
#define MAPPER_ADD_KEY(key, bit, device) \
2012-12-04 18:49:41 -05:00
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;
#define LEGAL_VALUE(statement, macro) \
if (statement) { \
macro \
}
2012-12-04 18:49:41 -05:00
2012-12-11 11:41:21 -05:00
#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)) {\
2012-12-04 18:49:41 -05:00
je.type = out_type; \
je.code = out_key; \
je.value = val(e.value); \
j = device; \
nowrite = 0;\
}
2012-12-04 18:49:41 -05:00
#endif