.menu_translate = in_sdl_menu_translate,
};
-void in_sdl_init(void)
+void in_sdl_init(const struct in_default_bind *defbinds)
{
- in_register_driver(&in_sdl_drv);
+ in_register_driver(&in_sdl_drv, defbinds);
}
-void in_sdl_init(void);
+struct in_default_bind;
+
+void in_sdl_init(const struct in_default_bind *defbinds);
static int *in_alloc_binds(int drv_id, int key_count)
{
+ const struct in_default_bind *defbinds;
int *binds;
+ int i;
binds = calloc(key_count * IN_BINDTYPE_COUNT * 2, sizeof(binds[0]));
if (binds == NULL)
return NULL;
- DRV(drv_id).get_def_binds(binds + key_count * IN_BINDTYPE_COUNT);
- memcpy(binds, binds + key_count * IN_BINDTYPE_COUNT,
- sizeof(binds[0]) * key_count * IN_BINDTYPE_COUNT);
+ defbinds = DRV(drv_id).defbinds;
+ if (defbinds != NULL) {
+ for (i = 0; ; i++) {
+ if (defbinds[i].bit == 0 && defbinds[i].code == 0)
+ break;
+ binds[IN_BIND_OFFS(defbinds[i].code, defbinds[i].btype)] =
+ 1 << defbinds[i].bit;
+ }
+
+ /* always have a copy of defbinds */
+ memcpy(binds + key_count * IN_BINDTYPE_COUNT, binds,
+ sizeof(binds[0]) * key_count * IN_BINDTYPE_COUNT);
+ }
return binds;
}
/* stubs for drivers that choose not to implement something */
static void in_def_free(void *drv_data) {}
-static void in_def_get_def_binds(int *binds) {}
static int in_def_clean_binds(void *drv_data, int *b, int *db) { return 1; }
static int in_def_get_config(void *drv_data, int what, int *val) { return -1; }
static int in_def_set_config(void *drv_data, int what, int val) { return -1; }
if (d.f == NULL) d.f = in_def_##f
/* to be called by drivers */
-int in_register_driver(const in_drv_t *drv)
+int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbinds)
{
int count_new = in_driver_count + 1;
in_drv_t *new_drivers;
memcpy(&new_drivers[in_driver_count], drv, sizeof(new_drivers[0]));
CHECK_ADD_STUB(new_drivers[in_driver_count], free);
- CHECK_ADD_STUB(new_drivers[in_driver_count], get_def_binds);
CHECK_ADD_STUB(new_drivers[in_driver_count], clean_binds);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_config);
CHECK_ADD_STUB(new_drivers[in_driver_count], set_config);
CHECK_ADD_STUB(new_drivers[in_driver_count], menu_translate);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_code);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_name);
+ if (defbinds != NULL)
+ new_drivers[in_driver_count].defbinds = defbinds;
in_drivers = new_drivers;
in_driver_count = count_new;
void (*free)(void *drv_data);
const char * const *
(*get_key_names)(int *count);
- void (*get_def_binds)(int *binds);
int (*clean_binds)(void *drv_data, int *binds, int *def_finds);
int (*get_config)(void *drv_data, int what, int *val);
int (*set_config)(void *drv_data, int what, int val);
int (*menu_translate)(void *drv_data, int keycode);
int (*get_key_code)(const char *key_name);
const char * (*get_key_name)(int keycode);
+
+ const struct in_default_bind *defbinds;
} in_drv_t;
struct in_default_bind {
};
/* to be called by drivers */
-int in_register_driver(const in_drv_t *drv);
+int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbinds);
void in_register(const char *nname, int drv_fd_hnd, void *drv_data,
int key_count, const char * const *key_names, int combos);
void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts);
};
#endif
-static void in_gp2x_get_def_binds(int *binds)
-{
- int i;
-
- for (i = 0; 1; i++) {
- if (in_gp2x_defbinds[i].bit == 0 && in_gp2x_defbinds[i].code == 0)
- break;
- binds[IN_BIND_OFFS(in_gp2x_defbinds[i].code, in_gp2x_defbinds[i].btype)] =
- 1 << in_gp2x_defbinds[i].bit;
- }
-}
-
/* remove binds of missing keys, count remaining ones */
static int in_gp2x_clean_binds(void *drv_data, int *binds, int *def_binds)
{
.probe = in_gp2x_probe,
.free = in_gp2x_free,
.get_key_names = in_gp2x_get_key_names,
- .get_def_binds = in_gp2x_get_def_binds,
.clean_binds = in_gp2x_clean_binds,
.update = in_gp2x_update,
.update_keycode = in_gp2x_update_keycode,
.menu_translate = in_gp2x_menu_translate,
};
-void in_gp2x_init(void)
+void in_gp2x_init(const struct in_default_bind *defbinds)
{
if (gp2x_dev_id == GP2X_DEV_WIZ)
in_gp2x_keys[GP2X_BTN_START] = "MENU";
in_gp2x_combo_keys = in_gp2x_combo_acts = 0;
- in_register_driver(&in_gp2x_drv);
+ in_register_driver(&in_gp2x_drv, defbinds);
}
-void in_gp2x_init(void);
+struct in_default_bind;
-/* to be set somewhere in platform code */
-extern struct in_default_bind in_gp2x_defbinds[];
+void in_gp2x_init(const struct in_default_bind *defbinds);
enum { GP2X_BTN_UP = 0, GP2X_BTN_LEFT = 2, GP2X_BTN_DOWN = 4, GP2X_BTN_RIGHT = 6,
GP2X_BTN_START = 8, GP2X_BTN_SELECT = 9, GP2X_BTN_L = 10, GP2X_BTN_R = 11,
void in_tsbutton_init(void)
{
tsbutton_down_id = last_tsbutton_id = -1;
- in_register_driver(&in_tsbutton_drv);
+ in_register_driver(&in_tsbutton_drv, NULL);
}
return 0;
}
-static void in_evdev_get_def_binds(int *binds)
-{
- int i;
-
- for (i = 0; ; i++) {
- if (in_evdev_defbinds[i].bit == 0 && in_evdev_defbinds[i].code == 0)
- break;
- binds[IN_BIND_OFFS(in_evdev_defbinds[i].code, in_evdev_defbinds[i].btype)] =
- 1 << in_evdev_defbinds[i].bit;
- }
-}
-
/* remove binds of missing keys, count remaining ones */
static int in_evdev_clean_binds(void *drv_data, int *binds, int *def_binds)
{
.probe = in_evdev_probe,
.free = in_evdev_free,
.get_key_names = in_evdev_get_key_names,
- .get_def_binds = in_evdev_get_def_binds,
.clean_binds = in_evdev_clean_binds,
.get_config = in_evdev_get_config,
.set_config = in_evdev_set_config,
.menu_translate = in_evdev_menu_translate,
};
-void in_evdev_init(void)
+void in_evdev_init(const struct in_default_bind *defbinds)
{
- in_register_driver(&in_evdev_drv);
+ in_register_driver(&in_evdev_drv, defbinds);
}
+struct in_default_bind;
extern int in_evdev_allow_abs_only;
-void in_evdev_init(void);
-
-/* to be set somewhere in platform code */
-extern struct in_default_bind in_evdev_defbinds[];
+void in_evdev_init(const struct in_default_bind *defbinds);
return 1;
// frontend stuff
+ // init input but leave probing to platform code,
+ // they add input drivers and may need to modify them after probe
in_init();
- in_evdev_init();
- //in_probe();
pl_init();
plat_init();
menu_init(); // loads config
* See the COPYING file in the top-level directory.
*/
-#include "common/input.h"
#include "plat.h"
-struct in_default_bind in_evdev_defbinds[] = {
- { 0, 0, 0 },
-};
-
void plat_video_menu_enter(int is_rom_loaded)
{
}
[KEY_MENU] = "Pandora",
};
-struct in_default_bind in_evdev_defbinds[] = {
+static const struct in_default_bind in_evdev_defbinds[] = {
{ KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
{ KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
{ KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
int plat_pandora_init(void)
{
+ in_evdev_init(in_evdev_defbinds);
in_probe();
in_set_config(in_name_to_id("evdev:gpio-keys"), IN_CFG_KEY_NAMES,
pandora_gpio_keys, sizeof(pandora_gpio_keys));
#include <linux/fb.h>
#include <sys/mman.h>
#include <linux/soundcard.h>
+#include <linux/input.h>
#include "common/input.h"
#include "gp2x/in_gp2x.h"
+#include "linux/in_evdev.h"
#include "common/menu.h"
#include "warm/warm.h"
#include "plugin_lib.h"
static int fb_offset_x, fb_offset_y;
static void caanoo_init(void);
+static void wiz_init(void);
+
+static const struct in_default_bind in_evdev_defbinds[] = {
+ { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
+ { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
+ { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
+ { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
+ { BTN_TOP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
+ { BTN_THUMB, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
+ { BTN_THUMB2, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
+ { BTN_TRIGGER, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
+ { BTN_BASE3, IN_BINDTYPE_PLAYER12, DKEY_START },
+ { BTN_BASE4, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
+ { BTN_TOP2, IN_BINDTYPE_PLAYER12, DKEY_L1 },
+ { BTN_PINKIE, IN_BINDTYPE_PLAYER12, DKEY_R1 },
+ { BTN_BASE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
+ { 0, 0, 0 },
+};
static void *fb_flip(void)
{
else {
printf("detected Wiz\n");
gp2x_dev_id = GP2X_DEV_WIZ;
- in_gp2x_init();
}
in_tsbutton_init();
- in_probe();
+ in_evdev_init(in_evdev_defbinds);
if (gp2x_dev_id == GP2X_DEV_CAANOO)
caanoo_init();
+ else
+ wiz_init();
mixerdev = open("/dev/mixer", O_RDWR);
if (mixerdev == -1)
}
/* Caanoo stuff, perhaps move later */
-#include <linux/input.h>
-
-struct in_default_bind in_evdev_defbinds[] = {
- { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
- { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
- { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
- { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
- { BTN_TOP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
- { BTN_THUMB, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
- { BTN_THUMB2, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
- { BTN_TRIGGER, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
- { BTN_BASE3, IN_BINDTYPE_PLAYER12, DKEY_START },
- { BTN_BASE4, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
- { BTN_TOP2, IN_BINDTYPE_PLAYER12, DKEY_L1 },
- { BTN_PINKIE, IN_BINDTYPE_PLAYER12, DKEY_R1 },
- { BTN_BASE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
- { 0, 0, 0 },
-};
-
static const char * const caanoo_keys[KEY_MAX + 1] = {
[0 ... KEY_MAX] = NULL,
[KEY_UP] = "Up",
ioctl(hapticdev, HAPTIC_PLAY_PATTERN, &haptic_seq[!!is_strong]);
}
+static void caanoo_init(void)
+{
+ in_probe();
+ in_set_config(in_name_to_id("evdev:pollux-analog"), IN_CFG_KEY_NAMES,
+ caanoo_keys, sizeof(caanoo_keys));
+}
+
/* Wiz stuff */
-struct in_default_bind in_gp2x_defbinds[] =
+static const struct in_default_bind in_gp2x_defbinds[] =
{
/* MXYZ SACB RLDU */
{ GP2X_BTN_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
// unused dummy for in_gp2x
volatile unsigned short *gp2x_memregs;
-static void caanoo_init(void)
+static void wiz_init(void)
{
- in_set_config(in_name_to_id("evdev:pollux-analog"), IN_CFG_KEY_NAMES,
- caanoo_keys, sizeof(caanoo_keys));
+ in_gp2x_init(in_gp2x_defbinds);
+ in_probe();
}
#include "common/input.h"
#include "common/in_sdl.h"
#include "common/menu.h"
+#include "plugin_lib.h"
+#include "main.h"
#include "plat.h"
#include "revision.h"
-// XXX
-struct in_default_bind in_evdev_defbinds[] = {
+static const struct in_default_bind in_sdl_defbinds[] = {
+ { SDLK_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
+ { SDLK_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
+ { SDLK_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
+ { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
+ { SDLK_d, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
+ { SDLK_z, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
+ { SDLK_x, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
+ { SDLK_s, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
+ { SDLK_v, IN_BINDTYPE_PLAYER12, DKEY_START },
+ { SDLK_c, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
+ { SDLK_w, IN_BINDTYPE_PLAYER12, DKEY_L1 },
+ { SDLK_r, IN_BINDTYPE_PLAYER12, DKEY_R1 },
+ { SDLK_e, IN_BINDTYPE_PLAYER12, DKEY_L2 },
+ { SDLK_t, IN_BINDTYPE_PLAYER12, DKEY_R2 },
+ { SDLK_ESCAPE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
{ 0, 0, 0 }
};
}
SDL_WM_SetCaption("PCSX-ReARMed " REV, NULL);
- in_sdl_init();
+ in_sdl_init(in_sdl_defbinds);
in_probe();
return;