X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fin_gp2x.c;h=01352c5ce2c880d402ab24e382be55749ef2eaf0;hb=902972d1c7f353aebb17a5ab587b2526e1a45d60;hp=51c9bf5b0b207b660ea08c399d6983703b15bb02;hpb=8e77275edade55d89b0723a60ab4ef1e2ec288de;p=libpicofe.git diff --git a/gp2x/in_gp2x.c b/gp2x/in_gp2x.c index 51c9bf5..01352c5 100644 --- a/gp2x/in_gp2x.c +++ b/gp2x/in_gp2x.c @@ -8,7 +8,7 @@ #include "../common/input.h" #include "in_gp2x.h" -#include "soc.h" +#include "plat_gp2x.h" #define IN_PREFIX "gp2x:" #define IN_GP2X_NBUTTONS 32 @@ -27,10 +27,10 @@ enum { BTN_UP = 0, BTN_LEFT = 2, BTN_DOWN = 4, BTN_RIGHT = 6, BTN_VOL_UP = 23, BTN_VOL_DOWN = 22, BTN_PUSH = 27 }; static const char * const in_gp2x_prefix = IN_PREFIX; -static const char * const in_gp2x_keys[IN_GP2X_NBUTTONS] = { +static const char *in_gp2x_keys[IN_GP2X_NBUTTONS] = { [0 ... IN_GP2X_NBUTTONS-1] = NULL, - [BTN_UP] = "UP", [BTN_LEFT] = "LEFT", [BTN_DOWN] = "DOWN", [BTN_RIGHT] = "RIGHT", - [BTN_START] = "START", [BTN_SELECT] = "SELECT", [BTN_L] = "L", [BTN_R] = "R", + [BTN_UP] = "Up", [BTN_LEFT] = "Left", [BTN_DOWN] = "Down", [BTN_RIGHT] = "Right", + [BTN_START] = "Start", [BTN_SELECT] = "Select", [BTN_L] = "L", [BTN_R] = "R", [BTN_A] = "A", [BTN_B] = "B", [BTN_X] = "X", [BTN_Y] = "Y", [BTN_VOL_DOWN]= "VOL DOWN", [BTN_VOL_UP] = "VOL UP", [BTN_PUSH] = "PUSH" @@ -55,8 +55,8 @@ static int in_gp2x_get_mmsp2_bits(void) static int in_gp2x_get_wiz_bits(void) { - int value = 0; - read(gpiodev, &value, 4); + int r, value = 0; + r = read(gpiodev, &value, 4); if (value & 0x02) value |= 0x05; if (value & 0x08) @@ -80,6 +80,9 @@ static int in_gp2x_get_wiz_bits(void) } #ifdef FAKE_IN_GP2X +volatile unsigned short *gp2x_memregs; +int gp2x_dev_id = -1; + static int in_gp2x_get_fake_bits(void) { extern int current_keys; @@ -89,15 +92,12 @@ static int in_gp2x_get_fake_bits(void) static void in_gp2x_probe(void) { - gp2x_soc_t soc; - - soc = soc_detect(); - switch (soc) + switch (gp2x_dev_id) { - case SOCID_MMSP2: + case GP2X_DEV_GP2X: in_gp2x_get_bits = in_gp2x_get_mmsp2_bits; break; - case SOCID_POLLUX: + case GP2X_DEV_WIZ: gpiodev = open("/dev/GPIO", O_RDONLY); if (gpiodev < 0) { perror("in_gp2x: couldn't open /dev/GPIO"); @@ -105,6 +105,7 @@ static void in_gp2x_probe(void) } in_gp2x_get_bits = in_gp2x_get_wiz_bits; break; + // we'll use evdev for Caanoo default: #ifdef FAKE_IN_GP2X in_gp2x_get_bits = in_gp2x_get_fake_bits; @@ -114,7 +115,7 @@ static void in_gp2x_probe(void) } in_register(IN_PREFIX "GP2X pad", IN_DRVID_GP2X, -1, (void *)1, - IN_GP2X_NBUTTONS, 1); + IN_GP2X_NBUTTONS, in_gp2x_keys, 1); } static void in_gp2x_free(void *drv_data) @@ -197,7 +198,7 @@ static const struct { #define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0])) -static int in_gp2x_menu_translate(int keycode) +static int in_gp2x_menu_translate(void *drv_data, int keycode) { int i; if (keycode < 0) @@ -218,30 +219,6 @@ static int in_gp2x_menu_translate(int keycode) return 0; } -static int in_gp2x_get_key_code(const char *key_name) -{ - int i; - - for (i = 0; i < IN_GP2X_NBUTTONS; i++) { - const char *k = in_gp2x_keys[i]; - if (k != NULL && strcasecmp(k, key_name) == 0) - return i; - } - - return -1; -} - -static const char *in_gp2x_get_key_name(int keycode) -{ - const char *name = NULL; - if (keycode >= 0 && keycode < IN_GP2X_NBUTTONS) - name = in_gp2x_keys[keycode]; - if (name == NULL) - name = "Unkn"; - - return name; -} - static const struct { short code; char btype; @@ -258,7 +235,7 @@ static const struct { { BTN_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */ { BTN_START, IN_BINDTYPE_PLAYER12, 7 }, { BTN_SELECT, IN_BINDTYPE_EMU, PEVB_MENU }, - { BTN_Y, IN_BINDTYPE_EMU, PEVB_SWITCH_RND }, +// { BTN_Y, IN_BINDTYPE_EMU, PEVB_SWITCH_RND }, { BTN_L, IN_BINDTYPE_EMU, PEVB_STATE_SAVE }, { BTN_R, IN_BINDTYPE_EMU, PEVB_STATE_LOAD }, { BTN_VOL_UP, IN_BINDTYPE_EMU, PEVB_VOL_UP }, @@ -318,6 +295,9 @@ void in_gp2x_init(void *vdrv) { in_drv_t *drv = vdrv; + if (gp2x_dev_id == GP2X_DEV_WIZ) + in_gp2x_keys[BTN_START] = "MENU"; + in_gp2x_combo_keys = in_gp2x_combo_acts = 0; drv->prefix = in_gp2x_prefix; @@ -327,8 +307,6 @@ void in_gp2x_init(void *vdrv) drv->get_def_binds = in_gp2x_get_def_binds; drv->clean_binds = in_gp2x_clean_binds; drv->menu_translate = in_gp2x_menu_translate; - drv->get_key_code = in_gp2x_get_key_code; - drv->get_key_name = in_gp2x_get_key_name; drv->update_keycode = in_gp2x_update_keycode; }