X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Fhost_pnd.c;h=9064047de6703aebaad31df2dc60e2d48e1a84e0;hp=5c79b915f3e07a76e0fca275ccf70ad186a360ce;hb=4d0451847a77d420284c7fb0f50b1f167c1118ee;hpb=ed233fce977d411ce024631668f1488d0d078d19;ds=sidebyside diff --git a/loader/host_pnd.c b/loader/host_pnd.c index 5c79b91..9064047 100644 --- a/loader/host_pnd.c +++ b/loader/host_pnd.c @@ -14,17 +14,16 @@ #include "realfuncs.h" static int ifds[2] = { -1, -1 }; -static int init_done; static int keystate; -static void init(void) +int host_init(void) { char buff[64]; int i, ifd, ret; for (ifd = -1, i = 0; ifds[0] == -1 || ifds[1] == -1; i++) { snprintf(buff, sizeof(buff), "/dev/input/event%i", i); - ifd = open(buff, O_RDONLY | O_NONBLOCK, 0); + ifd = open(buff, O_RDONLY | O_NONBLOCK); if (ifd == -1) break; @@ -47,7 +46,8 @@ static void init(void) fprintf(stderr, PFX "missing buttons\n"); if (ifds[1] < 0) fprintf(stderr, PFX "missing keypad\n"); - init_done = 1; + + return 0; } static const struct { @@ -84,9 +84,6 @@ int host_read_btns(void) struct input_event ev; int i, ret; - if (!init_done) - init(); - while (1) { ret = read(ifds[0], &ev, sizeof(ev));