X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Finput.c;h=77d9f3aa722905e56e0e018cf92ae7fc599fdc53;hb=34581c95f808322ecb29e0931ba8f5c879cc89b6;hp=9e4d5f2b7433266d040a6508769ac94e04dfde7b;hpb=289cd18ef05c122c79ae2483740851b43a53b7ff;p=libpicofe.git diff --git a/common/input.c b/common/input.c index 9e4d5f2..77d9f3a 100644 --- a/common/input.c +++ b/common/input.c @@ -3,7 +3,7 @@ #include #include "input.h" -#include "../linux/event.h" +#include "../linux/in_evdev.h" typedef struct { @@ -23,10 +23,8 @@ static int in_dev_count = 0; static int in_bind_count(int drv_id) { int count = 0; -#ifdef IN_EVDEV if (drv_id == IN_DRVID_EVDEV) count = in_evdev_bind_count(); -#endif if (count <= 0) printf("input: failed to get bind count for drv %d\n", drv_id); @@ -50,10 +48,8 @@ static int *in_alloc_binds(int drv_id) static void in_free(in_dev_t *dev) { if (dev->probed) { -#ifdef IN_EVDEV if (dev->drv_id == IN_DRVID_EVDEV) in_evdev_free(dev->drv_data); -#endif } dev->probed = 0; dev->drv_data = NULL; @@ -128,9 +124,7 @@ void in_probe(void) for (i = 0; i < in_dev_count; i++) in_devices[i].probed = 0; -#ifdef IN_EVDEV in_evdev_probe(); -#endif /* get rid of devs without binds and probes */ for (i = 0; i < in_dev_count; i++) { @@ -163,15 +157,44 @@ int in_update(void) for (i = 0; i < in_dev_count; i++) { if (in_devices[i].probed && in_devices[i].binds != NULL) { -#ifdef IN_EVDEV - result |= in_evdev_update(in_devices[i].drv_data, in_devices[i].binds); -#endif + if (in_devices[i].drv_id == IN_DRVID_EVDEV) + result |= in_evdev_update(in_devices[i].drv_data, in_devices[i].binds); } } return result; } +/* + * update with wait for a press, return bitfield of BTN_* + * only can use 1 drv here.. + */ +int in_update_menu(void) +{ + int result = 0; +#ifdef IN_EVDEV + void *data[IN_MAX_DEVS]; + int i, count = 0; + + for (i = 0; i < in_dev_count; i++) { + if (in_devices[i].probed) + data[count++] = in_devices[i].drv_data; + } + + if (count == 0) { + /* don't deadlock, fail */ + printf("input: failed to find devices to read\n"); + exit(1); + } + + result = in_evdev_update_menu(data, count); +#else +#error no menu read handlers +#endif + + return result; +} + void in_init(void) { memset(in_devices, 0, sizeof(in_devices)); @@ -180,11 +203,14 @@ void in_init(void) int main(void) { + int ret; + in_init(); in_probe(); while (1) { - in_update(); + ret = in_update_menu(); + printf("%08x\n", ret); sleep(1); }