mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-27 03:31:49 +01:00
[libretro] fixed new input controller & multitap support
This commit is contained in:
parent
8acb663868
commit
75d0baea86
@ -15,13 +15,12 @@
|
|||||||
|
|
||||||
#define RETRO_DEVICE_MDPAD_3B RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
|
#define RETRO_DEVICE_MDPAD_3B RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
|
||||||
#define RETRO_DEVICE_MDPAD_6B RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
#define RETRO_DEVICE_MDPAD_6B RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
||||||
#define RETRO_DEVICE_SMSPAD_2B RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 2)
|
#define RETRO_DEVICE_MSPAD_2B RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 2)
|
||||||
#define RETRO_DEVICE_PORT_NONE RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 3)
|
#define RETRO_DEVICE_MDPAD_3B_WAYPLAY RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 3)
|
||||||
#define RETRO_DEVICE_MDPAD_3B_WAYPLAY RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 4)
|
#define RETRO_DEVICE_MDPAD_6B_WAYPLAY RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 4)
|
||||||
#define RETRO_DEVICE_MDPAD_6B_WAYPLAY RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 5)
|
#define RETRO_DEVICE_MDPAD_3B_TEAMPLAYER RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 5)
|
||||||
#define RETRO_DEVICE_MDPAD_3B_TEAMPLAYER RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 6)
|
#define RETRO_DEVICE_MDPAD_6B_TEAMPLAYER RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 6)
|
||||||
#define RETRO_DEVICE_MDPAD_6B_TEAMPLAYER RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 7)
|
#define RETRO_DEVICE_MSPAD_2B_MASTERTAP RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 7)
|
||||||
#define RETRO_DEVICE_SMSPAD_4P RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 8)
|
|
||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "libretro.h"
|
#include "libretro.h"
|
||||||
@ -267,6 +266,14 @@ static void config_default(void)
|
|||||||
config.gg_extra = 0;
|
config.gg_extra = 0;
|
||||||
config.ntsc = 0;
|
config.ntsc = 0;
|
||||||
config.render = 0;
|
config.render = 0;
|
||||||
|
|
||||||
|
/* input options */
|
||||||
|
input.system[0] = SYSTEM_GAMEPAD;
|
||||||
|
input.system[1] = SYSTEM_GAMEPAD;
|
||||||
|
for (i=0; i<MAX_INPUTS; i++)
|
||||||
|
{
|
||||||
|
config.input[i].padtype = DEVICE_PAD2B | DEVICE_PAD3B | DEVICE_PAD6B;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bram_load(void)
|
static void bram_load(void)
|
||||||
@ -745,41 +752,41 @@ void retro_set_environment(retro_environment_t cb)
|
|||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const struct retro_controller_description port_1[] = {
|
static const struct retro_controller_description port_1[] = {
|
||||||
|
{ "Joypad Auto", RETRO_DEVICE_JOYPAD },
|
||||||
|
{ "Joypad Port Empty", RETRO_DEVICE_NONE },
|
||||||
{ "MD Joypad 3 Button", RETRO_DEVICE_MDPAD_3B },
|
{ "MD Joypad 3 Button", RETRO_DEVICE_MDPAD_3B },
|
||||||
{ "MD Joypad 6 Button", RETRO_DEVICE_MDPAD_6B },
|
{ "MD Joypad 6 Button", RETRO_DEVICE_MDPAD_6B },
|
||||||
{ "Joypad Auto", RETRO_DEVICE_JOYPAD },
|
{ "MS Joypad 2 Button", RETRO_DEVICE_MSPAD_2B },
|
||||||
{ "Joypad Port Empty", RETRO_DEVICE_PORT_NONE },
|
{ "MD Joypad 3 Button + 4-WayPlay", RETRO_DEVICE_MDPAD_3B_WAYPLAY },
|
||||||
{ "SMS Joypad 2 Button", RETRO_DEVICE_SMSPAD_2B },
|
{ "MD Joypad 6 Button + 4-WayPlay", RETRO_DEVICE_MDPAD_6B_WAYPLAY },
|
||||||
{ "MD Joypad 3 Button + WayPlay", RETRO_DEVICE_MDPAD_3B_WAYPLAY },
|
|
||||||
{ "MD Joypad 6 Button + WayPlay", RETRO_DEVICE_MDPAD_6B_WAYPLAY },
|
|
||||||
{ "MD Joypad 3 Button + Teamplayer", RETRO_DEVICE_MDPAD_3B_TEAMPLAYER },
|
{ "MD Joypad 3 Button + Teamplayer", RETRO_DEVICE_MDPAD_3B_TEAMPLAYER },
|
||||||
{ "MD Joypad 6 Button + Teamplayer", RETRO_DEVICE_MDPAD_6B_TEAMPLAYER },
|
{ "MD Joypad 6 Button + Teamplayer", RETRO_DEVICE_MDPAD_6B_TEAMPLAYER },
|
||||||
{ "SMS Joypad 4 Player", RETRO_DEVICE_SMSPAD_4P },
|
{ "MS Joypad 2 Button + Master Tap", RETRO_DEVICE_MSPAD_2B_MASTERTAP },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct retro_controller_description port_2[] = {
|
static const struct retro_controller_description port_2[] = {
|
||||||
|
{ "Joypad Auto", RETRO_DEVICE_JOYPAD },
|
||||||
|
{ "Joypad Port Empty", RETRO_DEVICE_NONE },
|
||||||
{ "MD Joypad 3 Button", RETRO_DEVICE_MDPAD_3B },
|
{ "MD Joypad 3 Button", RETRO_DEVICE_MDPAD_3B },
|
||||||
{ "MD Joypad 6 Button", RETRO_DEVICE_MDPAD_6B },
|
{ "MD Joypad 6 Button", RETRO_DEVICE_MDPAD_6B },
|
||||||
{ "Joypad Auto", RETRO_DEVICE_JOYPAD },
|
{ "MS Joypad 2 Button", RETRO_DEVICE_MSPAD_2B },
|
||||||
{ "Joypad Port Empty", RETRO_DEVICE_PORT_NONE },
|
{ "MD Joypad 3 Button + 4-WayPlay", RETRO_DEVICE_MDPAD_3B_WAYPLAY },
|
||||||
{ "SMS Joypad 2 Button", RETRO_DEVICE_SMSPAD_2B },
|
{ "MD Joypad 6 Button + 4-WayPlay", RETRO_DEVICE_MDPAD_6B_WAYPLAY },
|
||||||
{ "MD Joypad 3 Button + WayPlay", RETRO_DEVICE_MDPAD_3B_WAYPLAY },
|
|
||||||
{ "MD Joypad 6 Button + WayPlay", RETRO_DEVICE_MDPAD_6B_WAYPLAY },
|
|
||||||
{ "MD Joypad 3 Button + Teamplayer", RETRO_DEVICE_MDPAD_3B_TEAMPLAYER },
|
{ "MD Joypad 3 Button + Teamplayer", RETRO_DEVICE_MDPAD_3B_TEAMPLAYER },
|
||||||
{ "MD Joypad 6 Button + Teamplayer", RETRO_DEVICE_MDPAD_6B_TEAMPLAYER },
|
{ "MD Joypad 6 Button + Teamplayer", RETRO_DEVICE_MDPAD_6B_TEAMPLAYER },
|
||||||
|
{ "MS Joypad 2 Button + Master Tap", RETRO_DEVICE_MSPAD_2B_MASTERTAP },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct retro_controller_info ports[] = {
|
static const struct retro_controller_info ports[] = {
|
||||||
{ port_1, 10 },
|
{ port_1, 10 },
|
||||||
{ port_2, 9 },
|
{ port_2, 10 },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
environ_cb = cb;
|
environ_cb = cb;
|
||||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
||||||
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
|
void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
|
||||||
@ -812,60 +819,83 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
|
|||||||
{
|
{
|
||||||
switch(device)
|
switch(device)
|
||||||
{
|
{
|
||||||
|
case RETRO_DEVICE_NONE:
|
||||||
|
input.system[port] = NO_SYSTEM;
|
||||||
|
break;
|
||||||
case RETRO_DEVICE_MDPAD_3B:
|
case RETRO_DEVICE_MDPAD_3B:
|
||||||
config.input[port].padtype = DEVICE_PAD3B;
|
config.input[port*4].padtype = DEVICE_PAD3B;
|
||||||
input.dev[port] = DEVICE_PAD3B;
|
|
||||||
input.system[port] = SYSTEM_GAMEPAD;
|
input.system[port] = SYSTEM_GAMEPAD;
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_MDPAD_6B:
|
case RETRO_DEVICE_MDPAD_6B:
|
||||||
config.input[port].padtype = DEVICE_PAD6B;
|
config.input[port*4].padtype = DEVICE_PAD6B;
|
||||||
input.dev[port] = DEVICE_PAD6B;
|
|
||||||
input.system[port] = SYSTEM_GAMEPAD;
|
input.system[port] = SYSTEM_GAMEPAD;
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_PORT_NONE:
|
case RETRO_DEVICE_MSPAD_2B:
|
||||||
config.input[port].padtype = 0;
|
config.input[port*4].padtype = DEVICE_PAD2B;
|
||||||
input.dev[port] = 0;
|
|
||||||
input.system[port] = NO_SYSTEM;
|
|
||||||
break;
|
|
||||||
case RETRO_DEVICE_SMSPAD_2B:
|
|
||||||
config.input[port].padtype = DEVICE_PAD2B;
|
|
||||||
input.dev[port] = DEVICE_PAD2B;
|
|
||||||
input.system[port] = SYSTEM_GAMEPAD;
|
input.system[port] = SYSTEM_GAMEPAD;
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_MDPAD_3B_WAYPLAY:
|
case RETRO_DEVICE_MDPAD_3B_WAYPLAY:
|
||||||
config.input[port].padtype = DEVICE_PAD3B;
|
{
|
||||||
input.dev[port] = DEVICE_PAD3B;
|
int i;
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
config.input[port*4 + i].padtype = DEVICE_PAD3B;
|
||||||
|
}
|
||||||
input.system[0] = input.system[1] = SYSTEM_WAYPLAY;
|
input.system[0] = input.system[1] = SYSTEM_WAYPLAY;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RETRO_DEVICE_MDPAD_6B_WAYPLAY:
|
case RETRO_DEVICE_MDPAD_6B_WAYPLAY:
|
||||||
config.input[port].padtype = DEVICE_PAD6B;
|
{
|
||||||
input.dev[port] = DEVICE_PAD6B;
|
int i;
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
config.input[port*4 + i].padtype = DEVICE_PAD6B;
|
||||||
|
}
|
||||||
input.system[0] = input.system[1] = SYSTEM_WAYPLAY;
|
input.system[0] = input.system[1] = SYSTEM_WAYPLAY;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RETRO_DEVICE_MDPAD_3B_TEAMPLAYER:
|
case RETRO_DEVICE_MDPAD_3B_TEAMPLAYER:
|
||||||
config.input[port].padtype = DEVICE_PAD3B;
|
{
|
||||||
input.dev[port] = DEVICE_PAD3B;
|
int i;
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
config.input[port*4 + i].padtype = DEVICE_PAD3B;
|
||||||
|
}
|
||||||
input.system[port] = SYSTEM_TEAMPLAYER;
|
input.system[port] = SYSTEM_TEAMPLAYER;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RETRO_DEVICE_MDPAD_6B_TEAMPLAYER:
|
case RETRO_DEVICE_MDPAD_6B_TEAMPLAYER:
|
||||||
config.input[port].padtype = DEVICE_PAD6B;
|
{
|
||||||
input.dev[port] = DEVICE_PAD6B;
|
int i;
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
config.input[port*4 + i].padtype = DEVICE_PAD6B;
|
||||||
|
}
|
||||||
input.system[port] = SYSTEM_TEAMPLAYER;
|
input.system[port] = SYSTEM_TEAMPLAYER;
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_SMSPAD_4P:
|
}
|
||||||
config.input[port].padtype = DEVICE_PAD2B;
|
case RETRO_DEVICE_MSPAD_2B_MASTERTAP:
|
||||||
input.dev[port] = DEVICE_PAD2B;
|
{
|
||||||
input.system[0] = SYSTEM_MASTERTAP;
|
int i;
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
config.input[port*4 + i].padtype = DEVICE_PAD2B;
|
||||||
|
}
|
||||||
|
input.system[port] = SYSTEM_MASTERTAP;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
default:
|
default:
|
||||||
config.input[port].padtype = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B;
|
config.input[port*4].padtype = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B;
|
||||||
input.dev[port] = DEVICE_PAD2B | DEVICE_PAD6B | DEVICE_PAD3B;
|
|
||||||
input.system[port] = SYSTEM_GAMEPAD;
|
input.system[port] = SYSTEM_GAMEPAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_init();
|
old_system[0] = input.system[0];
|
||||||
|
old_system[1] = input.system[1];
|
||||||
|
|
||||||
|
io_init();
|
||||||
|
input_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t retro_serialize_size(void) { return STATE_SIZE; }
|
size_t retro_serialize_size(void) { return STATE_SIZE; }
|
||||||
@ -948,9 +978,6 @@ bool retro_load_game(const struct retro_game_info *info)
|
|||||||
if (!load_rom((char *)info->path))
|
if (!load_rom((char *)info->path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
|
||||||
retro_set_controller_port_device(i, input.dev[i]);
|
|
||||||
|
|
||||||
audio_init(44100, vdp_pal ? pal_fps : ntsc_fps);
|
audio_init(44100, vdp_pal ? pal_fps : ntsc_fps);
|
||||||
system_init();
|
system_init();
|
||||||
system_reset();
|
system_reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user