From 0114ccc43b628801282c5a076e0f3a9f368ea329 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 23 Jul 2009 21:01:39 +0000 Subject: [PATCH] fix FAKE_IN_GP2X git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@711 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/in_gp2x.c | 95 ++++++++++++++++++++++++++------------------------ linux/gp2x.c | 1 + 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/gp2x/in_gp2x.c b/gp2x/in_gp2x.c index ab4ba17..f0da436 100644 --- a/gp2x/in_gp2x.c +++ b/gp2x/in_gp2x.c @@ -36,50 +36,9 @@ static const char * const in_gp2x_keys[IN_GP2X_NBUTTONS] = { [BTN_PUSH] = "PUSH" }; -static int in_gp2x_get_mmsp2_bits(void); -static int in_gp2x_get_wiz_bits(void); - -static void in_gp2x_probe(void) -{ - gp2x_soc_t soc; - - soc = soc_detect(); - switch (soc) - { - case SOCID_MMSP2: - in_gp2x_get_bits = in_gp2x_get_mmsp2_bits; - break; - case SOCID_POLLUX: - gpiodev = open("/dev/GPIO", O_RDONLY); - if (gpiodev < 0) { - perror("in_gp2x: couldn't open /dev/GPIO"); - return; - } - in_gp2x_get_bits = in_gp2x_get_wiz_bits; - break; - default: - return; - } - - in_register(IN_PREFIX "GP2X pad", IN_DRVID_GP2X, -1, (void *)1, 1); -} - -static void in_gp2x_free(void *drv_data) -{ - if (gpiodev >= 0) { - close(gpiodev); - gpiodev = -1; - } -} - -static int in_gp2x_get_bind_count(void) -{ - return IN_GP2X_NBUTTONS; -} static int in_gp2x_get_mmsp2_bits(void) { -#ifndef FAKE_IN_GP2X extern volatile unsigned short *gp2x_memregs; int value; value = gp2x_memregs[0x1198>>1] & 0xff; // GPIO M @@ -92,10 +51,6 @@ static int in_gp2x_get_mmsp2_bits(void) value = ~value & 0x08c0ff55; return value; -#else - extern int current_keys; - return current_keys; -#endif } static int in_gp2x_get_wiz_bits(void) @@ -124,6 +79,56 @@ static int in_gp2x_get_wiz_bits(void) return value; } +#ifdef FAKE_IN_GP2X +static int in_gp2x_get_fake_bits(void) +{ + extern int current_keys; + return current_keys; +} +#endif + +static void in_gp2x_probe(void) +{ + gp2x_soc_t soc; + + soc = soc_detect(); + switch (soc) + { + case SOCID_MMSP2: + in_gp2x_get_bits = in_gp2x_get_mmsp2_bits; + break; + case SOCID_POLLUX: + gpiodev = open("/dev/GPIO", O_RDONLY); + if (gpiodev < 0) { + perror("in_gp2x: couldn't open /dev/GPIO"); + return; + } + in_gp2x_get_bits = in_gp2x_get_wiz_bits; + break; + default: +#ifdef FAKE_IN_GP2X + in_gp2x_get_bits = in_gp2x_get_fake_bits; + break; +#endif + return; + } + + in_register(IN_PREFIX "GP2X pad", IN_DRVID_GP2X, -1, (void *)1, 1); +} + +static void in_gp2x_free(void *drv_data) +{ + if (gpiodev >= 0) { + close(gpiodev); + gpiodev = -1; + } +} + +static int in_gp2x_get_bind_count(void) +{ + return IN_GP2X_NBUTTONS; +} + /* returns bitfield of binds of pressed buttons */ int in_gp2x_update(void *drv_data, int *binds) { diff --git a/linux/gp2x.c b/linux/gp2x.c index daf18fe..949a402 100644 --- a/linux/gp2x.c +++ b/linux/gp2x.c @@ -30,6 +30,7 @@ static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT; int mix_32_to_16l_level; int crashed_940 = 0; int default_cpu_clock = 123; +void *gp2x_memregs = NULL; /* gtk */ struct gtk_global_struct -- 2.39.5