From 1cc5bfbc12f9b7cdd7500dbadd5e440232014304 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 28 Jan 2016 04:13:31 +0100 Subject: [PATCH] use callbacks --- command_event.c | 2 +- libretro_version_1.c | 2 +- libretro_version_1.h | 2 +- menu/menu_setting.c | 20 +++++++++++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/command_event.c b/command_event.c index fea8685c1f..c1e433596f 100644 --- a/command_event.c +++ b/command_event.c @@ -385,7 +385,7 @@ static void event_init_controllers(void) if (set_controller) { pad.device = device; - pad.i = i + 1; + pad.port = i + 1; core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); } } diff --git a/libretro_version_1.c b/libretro_version_1.c index 9e32819a98..95bd7730ba 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -188,7 +188,7 @@ bool core_ctl(enum core_ctl_state state, void *data) 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); + core.retro_set_controller_port_device(pad->port, pad->device); } break; case CORE_CTL_RETRO_GET_MEMORY: diff --git a/libretro_version_1.h b/libretro_version_1.h index a9faffd287..131ca000f7 100644 --- a/libretro_version_1.h +++ b/libretro_version_1.h @@ -101,7 +101,7 @@ enum core_ctl_state typedef struct retro_ctx_controller_info { - unsigned i; + unsigned port; unsigned device; } retro_ctx_controller_info_t; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 051f65fa13..552867ff90 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2183,6 +2183,7 @@ static int setting_action_start_analog_dpad_mode(void *data) static int setting_action_start_libretro_device_type(void *data) { + retro_ctx_controller_info_t pad; unsigned index_offset, current_device; unsigned devices[128], types = 0, port = 0; const struct retro_controller_info *desc = NULL; @@ -2226,7 +2227,10 @@ static int setting_action_start_libretro_device_type(void *data) current_device = RETRO_DEVICE_JOYPAD; settings->input.libretro_device[port] = current_device; - core.retro_set_controller_port_device(port, current_device); + + pad.port = port; + pad.device = current_device; + core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); return 0; } @@ -2330,6 +2334,7 @@ static int setting_action_right_analog_dpad_mode(void *data, bool wraparound) static int setting_action_left_libretro_device_type( void *data, bool wraparound) { + retro_ctx_controller_info_t pad; unsigned current_device, current_idx, i, devices[128], types = 0, port = 0; const struct retro_controller_info *desc = NULL; @@ -2382,7 +2387,11 @@ static int setting_action_left_libretro_device_type( [(current_idx + types - 1) % types]; settings->input.libretro_device[port] = current_device; - core.retro_set_controller_port_device(port, current_device); + + pad.port = port; + pad.device = current_device; + + core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); return 0; } @@ -2390,6 +2399,7 @@ static int setting_action_left_libretro_device_type( static int setting_action_right_libretro_device_type( void *data, bool wraparound) { + retro_ctx_controller_info_t pad; unsigned current_device, current_idx, i, devices[128], types = 0, port = 0; const struct retro_controller_info *desc = NULL; @@ -2442,7 +2452,11 @@ static int setting_action_right_libretro_device_type( [(current_idx + 1) % types]; settings->input.libretro_device[port] = current_device; - core.retro_set_controller_port_device(port, current_device); + + pad.port = port; + pad.device = current_device; + + core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); return 0; }