mirror of https://github.com/snes9xgit/snes9x.git
fix controller assignment
This commit is contained in:
parent
c85d981201
commit
5a75d5dec8
libretro
|
@ -194,13 +194,15 @@ void retro_set_environment(retro_environment_t cb)
|
|||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
||||
|
||||
const struct retro_controller_description port_1[] = {
|
||||
static const struct retro_controller_description port_1[] = {
|
||||
{ "None", RETRO_DEVICE_NONE },
|
||||
{ "SNES Joypad", RETRO_DEVICE_JOYPAD },
|
||||
{ "SNES Mouse", RETRO_DEVICE_MOUSE },
|
||||
{ "Multitap", RETRO_DEVICE_JOYPAD_MULTITAP },
|
||||
};
|
||||
|
||||
const struct retro_controller_description port_2[] = {
|
||||
static const struct retro_controller_description port_2[] = {
|
||||
{ "None", RETRO_DEVICE_NONE },
|
||||
{ "SNES Joypad", RETRO_DEVICE_JOYPAD },
|
||||
{ "SNES Mouse", RETRO_DEVICE_MOUSE },
|
||||
{ "Multitap", RETRO_DEVICE_JOYPAD_MULTITAP },
|
||||
|
@ -208,10 +210,21 @@ void retro_set_environment(retro_environment_t cb)
|
|||
{ "Justifier", RETRO_DEVICE_LIGHTGUN_JUSTIFIER },
|
||||
};
|
||||
|
||||
const struct retro_controller_info ports[] = {
|
||||
{ port_1, 3 },
|
||||
{ port_2, 5 },
|
||||
{ 0, 0 },
|
||||
static const struct retro_controller_description port_3[] = {
|
||||
{ "None", RETRO_DEVICE_NONE },
|
||||
{ "SNES Joypad", RETRO_DEVICE_JOYPAD },
|
||||
};
|
||||
|
||||
static const struct retro_controller_info ports[] = {
|
||||
{ port_1, 4 },
|
||||
{ port_2, 6 },
|
||||
{ port_3, 2 },
|
||||
{ port_3, 2 },
|
||||
{ port_3, 2 },
|
||||
{ port_3, 2 },
|
||||
{ port_3, 2 },
|
||||
{ port_3, 2 },
|
||||
{},
|
||||
};
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
||||
|
@ -447,7 +460,7 @@ void retro_reset()
|
|||
static unsigned snes_devices[2];
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
if (port < 2)
|
||||
if (port < 8)
|
||||
{
|
||||
int offset = snes_devices[0] == RETRO_DEVICE_JOYPAD_MULTITAP ? 4 : 1;
|
||||
switch (device)
|
||||
|
@ -472,12 +485,15 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
|
|||
S9xSetController(port, CTL_JUSTIFIER, 0, 0, 0, 0);
|
||||
snes_devices[port] = RETRO_DEVICE_LIGHTGUN_JUSTIFIER;
|
||||
break;
|
||||
case RETRO_DEVICE_NONE:
|
||||
S9xSetController(port, CTL_NONE, 0, 0, 0, 0);
|
||||
snes_devices[port] = RETRO_DEVICE_NONE;
|
||||
break;
|
||||
default:
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_ERROR, "[libretro]: Invalid device (%d).\n", device);
|
||||
break;
|
||||
}
|
||||
if (!port)
|
||||
retro_set_controller_port_device(1, snes_devices[1]);
|
||||
}
|
||||
else if(device != RETRO_DEVICE_NONE)
|
||||
log_cb(RETRO_LOG_INFO, "[libretro]: Nonexistent Port (%d).\n", port);
|
||||
|
@ -1201,6 +1217,9 @@ static void report_buttons()
|
|||
S9xReportButton(MAKE_BUTTON(2, i), input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, i));
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_NONE:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_ERROR, "[libretro]: Unknown device...\n");
|
||||
|
|
Loading…
Reference in New Issue