diff --git a/command_event.c b/command_event.c index 2b0b8b5834..2de4eaeb91 100644 --- a/command_event.c +++ b/command_event.c @@ -330,6 +330,7 @@ static void event_init_controllers(void) for (i = 0; i < MAX_USERS; i++) { + retro_ctx_controller_info_t pad; const char *ident = NULL; bool set_controller = false; const struct retro_controller_description *desc = NULL; @@ -379,16 +380,14 @@ static void event_init_controllers(void) } if (set_controller) - core.retro_set_controller_port_device(i, device); + { + pad.device = device; + pad.i = i + 1; + core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); + } } } -static void event_deinit_core_interfaces(void) -{ - video_driver_callback_destroy_context(); - video_driver_unset_callback(); -} - static void event_deinit_core(bool reinit) { #ifdef HAVE_CHEEVOS @@ -396,7 +395,8 @@ static void event_deinit_core(bool reinit) cheevos_unload(); #endif - event_deinit_core_interfaces(); + video_driver_callback_destroy_context(); + video_driver_unset_callback(); core_ctl(CORE_CTL_RETRO_UNLOAD_GAME, NULL); core_ctl(CORE_CTL_RETRO_DEINIT, NULL); diff --git a/libretro_version_1.c b/libretro_version_1.c index 38aa65069b..3eff8ee0ef 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -174,6 +174,14 @@ bool core_ctl(enum core_ctl_state state, void *data) switch (state) { + case CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE: + { + retro_ctx_controller_info_t *pad = (retro_ctx_controller_info_t*)data; + if (!pad) + return false; + core.retro_set_controller_port_device(pad->i, pad->device); + } + break; case CORE_CTL_RETRO_GET_MEMORY: { retro_ctx_memory_info_t *info = (retro_ctx_memory_info_t*)data; diff --git a/libretro_version_1.h b/libretro_version_1.h index fd525bf5b7..15825517cd 100644 --- a/libretro_version_1.h +++ b/libretro_version_1.h @@ -92,9 +92,17 @@ enum core_ctl_state CORE_CTL_RETRO_GET_SYSTEM_INFO, - CORE_CTL_RETRO_LOAD_GAME + CORE_CTL_RETRO_LOAD_GAME, + + CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE }; +typedef struct retro_ctx_controller_info +{ + unsigned i; + unsigned device; +} retro_ctx_controller_info_t; + typedef struct retro_ctx_memory_info { void *data;