Skip to content

Commit

Permalink
use callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Jan 28, 2016
1 parent eb9be64 commit 1cc5bfb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion command_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libretro_version_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion libretro_version_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 17 additions & 3 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2382,14 +2387,19 @@ 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;
}

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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1cc5bfb

Please sign in to comment.