Include 3D Pad mode switch setting in save state.

This commit is contained in:
David Walters 2017-11-12 11:39:29 +00:00
parent 341ac85ec9
commit 6c99f05cf7
3 changed files with 32 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include "mednafen/mednafen-types.h"
#include "mednafen/ss/ss.h"
#include "mednafen/ss/smpc.h"
#include "mednafen/state.h"
#include <math.h>
#include <stdio.h>
@ -38,7 +39,7 @@ static uint32_t input_type[ MAX_CONTROLLERS ] = {0};
#define INPUT_MODE_3D_PAD_DEFAULT INPUT_MODE_3D_PAD_ANALOG
// Mode switch for 3D Control Pad (per player)
static uint32_t input_mode[ MAX_CONTROLLERS ] = {0};
static uint16_t input_mode[ MAX_CONTROLLERS ] = {0};
@ -308,8 +309,8 @@ void input_update( retro_input_state_t input_state_cb )
{
// Handle MODE button as a switch
unsigned prev = ( input_mode[iplayer] & INPUT_MODE_3D_PAD_PREVIOUS_MASK );
unsigned held = input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, input_map_3d_pad_mode_switch )
uint16_t prev = ( input_mode[iplayer] & INPUT_MODE_3D_PAD_PREVIOUS_MASK );
uint16_t held = input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, input_map_3d_pad_mode_switch )
? INPUT_MODE_3D_PAD_PREVIOUS_MASK : 0;
// Rising edge trigger
@ -437,6 +438,22 @@ void input_update( retro_input_state_t input_state_cb )
}; // for each player
}
// save state function for input
int input_StateAction( StateMem* sm, const unsigned load, const bool data_only )
{
int success;
SFORMAT StateRegs[] =
{
SFARRAY16N( input_mode, sizeof( input_mode ), "mode" ),
SFEND
};
success = MDFNSS_StateAction( sm, load, data_only, StateRegs, "LRINPUT" );
// ok?
return success;
}
//------------------------------------------------------------------------------
// Libretro Interface

View File

@ -1,6 +1,9 @@
#ifndef __INPUT_H__
#define __INPUT_H__
#include "libretro.h"
#include "mednafen/state.h"
// These input routines tell libretro about Saturn peripherals
// and map input from the abstract 'retropad' into Saturn land.
@ -14,4 +17,7 @@ extern void input_set_deadzone_stick( int percent );
extern void input_update( retro_input_state_t input_state_cb );
// save state function for input
extern int input_StateAction( StateMem* sm, const unsigned load, const bool data_only );
#endif

View File

@ -2012,6 +2012,12 @@ MDFN_COLD int LibRetro_StateAction( StateMem* sm, const unsigned load, const boo
return 0;
}
success = input_StateAction( sm, load, data_only );
if ( success == 0 ) {
log_cb( RETRO_LOG_ERROR, "Input save-state failed.\n" );
return 0;
}
if ( load )
{
BackupRAM_Dirty = true;