mirror of
https://github.com/libretro/fuse-libretro.git
synced 2024-11-23 08:49:55 +00:00
Proper joystick management for snapshot
This commit is contained in:
parent
3f9344ddf8
commit
9aea3c45ae
@ -296,8 +296,10 @@ joystick_enabled_snapshot( libspectrum_snap *snap )
|
||||
}
|
||||
|
||||
if( settings_current.joystick_keyboard_output != fuse_type &&
|
||||
#ifndef __LIBRETRO__
|
||||
settings_current.joystick_1_output != fuse_type &&
|
||||
settings_current.joystick_2_output != fuse_type &&
|
||||
#endif
|
||||
!rzx_playback ) {
|
||||
switch( ui_confirm_joystick( libspectrum_snap_joystick_list(snap,i),
|
||||
libspectrum_snap_joystick_inputs(snap,i)) ) {
|
||||
@ -318,7 +320,9 @@ joystick_enabled_snapshot( libspectrum_snap *snap )
|
||||
/* If the snap was configured for a Kempston joystick, enable
|
||||
our Kempston emulation in case the snap was reading from
|
||||
the joystick to prevent things going haywire */
|
||||
#ifndef __LIBRETRO__
|
||||
if( fuse_type == JOYSTICK_TYPE_KEMPSTON )
|
||||
#endif
|
||||
settings_current.joy_kempston = 1;
|
||||
}
|
||||
}
|
||||
|
@ -756,6 +756,11 @@ ui_confirm_joystick( libspectrum_joystick libspectrum_type, int inputs )
|
||||
int error;
|
||||
char title[80];
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
if(( !settings_current.joy_prompt ) && (inputs & LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_1))
|
||||
return UI_CONFIRM_JOYSTICK_JOYSTICK_1;
|
||||
#endif
|
||||
|
||||
if( !settings_current.joy_prompt ) return UI_CONFIRM_JOYSTICK_NONE;
|
||||
|
||||
snprintf( title, sizeof( title ), "Configure %s joystick",
|
||||
|
@ -396,6 +396,11 @@ read_header( const libspectrum_byte *buffer, libspectrum_snap *snap,
|
||||
*version = 1;
|
||||
|
||||
libspectrum_snap_set_joystick_active_count( snap, 1 );
|
||||
#ifdef __LIBRETRO__
|
||||
libspectrum_snap_set_joystick_inputs( snap, 0,
|
||||
LIBSPECTRUM_JOYSTICK_INPUT_KEYBOARD |
|
||||
LIBSPECTRUM_JOYSTICK_INPUT_JOYSTICK_1 );
|
||||
#endif
|
||||
error = get_joystick_type_v1( snap, ( header[29] & 0xc0 ) >> 6 );
|
||||
if( error ) return error;
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#define RETRO_DEVICE_SPECTRUM_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 0)
|
||||
|
||||
#define RETRO_DEVICE_AUTO_CFG RETRO_DEVICE_JOYPAD
|
||||
|
||||
#define RETRO_DEVICE_CURSOR_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
|
||||
#define RETRO_DEVICE_KEMPSTON_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
||||
#define RETRO_DEVICE_SINCLAIR1_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 2)
|
||||
|
@ -25,8 +25,10 @@ int settings_init(int *first_arg, int argc, char **argv)
|
||||
|
||||
settings_current.joy_kempston = 1;
|
||||
settings_current.fuller = 1;
|
||||
#ifndef __LIBRETRO__
|
||||
settings_current.joystick_1_output = 1;
|
||||
settings_current.joystick_2_output = 2;
|
||||
#endif
|
||||
|
||||
update_variables(1);
|
||||
return res;
|
||||
|
@ -549,14 +549,15 @@ void retro_set_environment(retro_environment_t cb)
|
||||
env_cb = cb;
|
||||
|
||||
static const struct retro_controller_description controllers_and_kb[] = {
|
||||
{ "Cursor Joystick", RETRO_DEVICE_CURSOR_JOYSTICK },
|
||||
{ "Kempston Joystick", RETRO_DEVICE_KEMPSTON_JOYSTICK },
|
||||
{ "Core defined Input", RETRO_DEVICE_AUTO_CFG },
|
||||
{ "Cursor Joystick", RETRO_DEVICE_CURSOR_JOYSTICK },
|
||||
{ "Kempston Joystick", RETRO_DEVICE_KEMPSTON_JOYSTICK },
|
||||
{ "Sinclair 1 Joystick", RETRO_DEVICE_SINCLAIR1_JOYSTICK },
|
||||
{ "Sinclair 2 Joystick", RETRO_DEVICE_SINCLAIR2_JOYSTICK },
|
||||
{ "Timex 1 Joystick", RETRO_DEVICE_TIMEX1_JOYSTICK },
|
||||
{ "Timex 2 Joystick", RETRO_DEVICE_TIMEX2_JOYSTICK },
|
||||
{ "Fuller Joystick", RETRO_DEVICE_FULLER_JOYSTICK },
|
||||
{ "Sinclair Keyboard", RETRO_DEVICE_SPECTRUM_KEYBOARD }
|
||||
{ "Timex 1 Joystick", RETRO_DEVICE_TIMEX1_JOYSTICK },
|
||||
{ "Timex 2 Joystick", RETRO_DEVICE_TIMEX2_JOYSTICK },
|
||||
{ "Fuller Joystick", RETRO_DEVICE_FULLER_JOYSTICK },
|
||||
{ "Sinclair Keyboard", RETRO_DEVICE_SPECTRUM_KEYBOARD }
|
||||
};
|
||||
|
||||
static const struct retro_controller_info ports[MAX_PADS + 1] = {
|
||||
@ -594,7 +595,7 @@ void retro_init(void)
|
||||
active_cheats = NULL;
|
||||
|
||||
// Set default controllers
|
||||
retro_set_controller_port_device( 0, RETRO_DEVICE_CURSOR_JOYSTICK );
|
||||
retro_set_controller_port_device( 0, RETRO_DEVICE_CURSOR_JOYSTICK );
|
||||
retro_set_controller_port_device( 1, RETRO_DEVICE_KEMPSTON_JOYSTICK );
|
||||
retro_set_controller_port_device( 2, RETRO_DEVICE_SPECTRUM_KEYBOARD );
|
||||
}
|
||||
@ -1081,6 +1082,10 @@ void retro_deinit(void)
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
log_cb(RETRO_LOG_INFO, "port %u device %08x\n", port, device);
|
||||
|
||||
if (device == RETRO_DEVICE_AUTO_CFG)
|
||||
return;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_CURSOR_JOYSTICK:
|
||||
|
Loading…
Reference in New Issue
Block a user