From 6fb0c7a7a53e1eba7a0f5dc5b1ade312a0d76119 Mon Sep 17 00:00:00 2001 From: Toad King Date: Thu, 14 Jun 2012 03:21:06 -0400 Subject: initial pocketsnes commit --- src/input.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 src/input.c (limited to 'src/input.c') diff --git a/src/input.c b/src/input.c new file mode 100644 index 0000000..07063ce --- /dev/null +++ b/src/input.c @@ -0,0 +1,191 @@ + +#include "menu.h" + +#if defined(__GP2X__) +#include "usbjoy.h" +static struct usbjoy *joys[4]; +static char joyCount = 0; +static int buttonMap[4][32]; +#endif + +struct INPUT Inp; +static int repeatCounter = 0; +int InputInit() +{ + memset(&Inp,0,sizeof(Inp)); +#if defined(__GP2X__) +int i; + for (i=1; i<5; i++) + { + struct usbjoy *joy = joy_open(i); + if(joy != NULL) + { + joys[joyCount] = joy; + memset(buttonMap[joyCount],0,sizeof(buttonMap[joyCount])); + buttonMap[joyCount][0] = (1<numbuttons<10) + { + buttonMap[joyCount][6] = (1<=0x80) held&=0xbf; // Keep looping around + + Inp.held[i]=held; + } + + // Work out some key repeat values: + for (i=0;i<32;i++) + { + char rep=0; + int held=Inp.held[i]; + + if (held==1) + { + // Key has just been pressed again, so set repeat by default + rep=1; + } + else + { + // Now make sure key has been held for a period of time + // before auto toggling the repeat flag + if (held>=0x20) + { + repeatCounter++; + if(repeatCounter>15) + { + rep=1; + repeatCounter=0; + } + } + } + + Inp.repeat[i]=rep; + } + + return 0; +} -- cgit v1.2.3