static void in_sdl_probe(const in_drv_t *drv)
{
+ const struct in_pdata *pdata = drv->pdata;
+ const char * const * key_names = in_sdl_keys;
struct in_sdl_state *state;
SDL_Joystick *joy;
int i, joycount;
char name[256];
+ if (pdata->key_names)
+ key_names = pdata->key_names;
+
state = calloc(1, sizeof(*state));
if (state == NULL) {
fprintf(stderr, "in_sdl: OOM\n");
state->drv = drv;
in_register(IN_SDL_PREFIX "keys", -1, state, SDLK_LAST,
- in_sdl_keys, 0);
+ key_names, 0);
/* joysticks go here too */
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
state->drv = drv;
snprintf(name, sizeof(name), IN_SDL_PREFIX "%s", SDL_JoystickName(i));
- in_register(name, -1, state, SDLK_LAST, in_sdl_keys, 0);
+ in_register(name, -1, state, SDLK_LAST, key_names, 0);
}
if (joycount > 0)
}
static const char * const *
-in_sdl_get_key_names(int *count)
+in_sdl_get_key_names(const in_drv_t *drv, int *count)
{
+ const struct in_pdata *pdata = drv->pdata;
*count = SDLK_LAST;
+
+ if (pdata->key_names)
+ return pdata->key_names;
return in_sdl_keys;
}
{
struct in_sdl_state *state = drv_data;
const struct in_pdata *pdata = state->drv->pdata;
+ const char * const * key_names = in_sdl_keys;
const struct menu_keymap *map;
int map_len;
int ret = 0;
int i;
+ if (pdata->key_names)
+ key_names = pdata->key_names;
+
if (state->joy) {
map = pdata->joy_map;
map_len = pdata->jmap_size;
}
if (charcode != NULL && (unsigned int)keycode < SDLK_LAST &&
- in_sdl_keys[keycode] != NULL && in_sdl_keys[keycode][1] == 0)
+ key_names[keycode] != NULL && key_names[keycode][1] == 0)
{
ret |= PBTN_CHAR;
- *charcode = in_sdl_keys[keycode][0];
+ *charcode = key_names[keycode][0];
}
}
if (in_devices[i].name == NULL)
return -1;
- in_devices[i].key_names = DRV(drv_id).get_key_names(&in_devices[i].key_count);
+ in_devices[i].key_names = DRV(drv_id).get_key_names(&DRV(drv_id),
+ &in_devices[i].key_count);
in_devices[i].drv_id = drv_id;
if (i + 1 > in_dev_count)
void (*probe)(const in_drv_t *drv);
void (*free)(void *drv_data);
const char * const *
- (*get_key_names)(int *count);
+ (*get_key_names)(const in_drv_t *drv, int *count);
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);
size_t kmap_size;
const struct menu_keymap *joy_map;
size_t jmap_size;
+ const char * const *key_names;
};
/* to be called by drivers */