Libretro: Fixed issues with system actions (FDS/VS and reset button)

This commit is contained in:
Sour 2018-01-07 23:16:50 -05:00
parent 86eabc4055
commit efe60a082e
3 changed files with 34 additions and 11 deletions

View file

@ -189,7 +189,6 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
ResetComponents(false);
_rewindManager.reset(new RewindManager());
_controlManager->UpdateInputState();
VideoDecoder::GetInstance()->StartThread();
@ -378,6 +377,8 @@ void Console::ResetComponents(bool softReset)
debugger->Resume();
}
}
_controlManager->UpdateInputState();
}
void Console::Stop()

View file

@ -100,17 +100,21 @@ public:
void SwitchDiskSide()
{
shared_ptr<FDS> mapper = _mapper.lock();
if(mapper) {
InsertDisk(mapper->GetCurrentDisk() ^ 0x01);
if(!IsAutoInsertDiskEnabled()) {
shared_ptr<FDS> mapper = _mapper.lock();
if(mapper && mapper->IsDiskInserted()) {
InsertDisk(mapper->GetCurrentDisk() ^ 0x01);
}
}
}
void InsertNextDisk()
{
shared_ptr<FDS> mapper = _mapper.lock();
if(mapper) {
InsertDisk(((mapper->GetCurrentDisk() & 0xFE) + 2) % mapper->GetSideCount());
if(!IsAutoInsertDiskEnabled()) {
shared_ptr<FDS> mapper = _mapper.lock();
if(mapper) {
InsertDisk(((mapper->GetCurrentDisk() & 0xFE) + 2) % mapper->GetSideCount());
}
}
}

View file

@ -11,6 +11,21 @@ private:
retro_input_state_t _getInputState = nullptr;
retro_input_poll_t _pollInput = nullptr;
bool _mouseButtons[3] = { false, false, false };
bool _wasPushed[16] = { };
bool ProcessAction(uint32_t button)
{
if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button)) {
if(!_wasPushed[button]) {
//Newly pressed, process action
_wasPushed[button] = true;
return true;
}
} else {
_wasPushed[button] = false;
}
return false;
}
public:
LibretroKeyManager()
@ -59,18 +74,21 @@ public:
shared_ptr<FdsSystemActionManager> fdsSam = Console::GetInstance()->GetSystemActionManager<FdsSystemActionManager>();
if(fdsSam) {
if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L)) {
if(ProcessAction(RETRO_DEVICE_ID_JOYPAD_L)) {
fdsSam->InsertNextDisk();
} else if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R)) {
}
if(ProcessAction(RETRO_DEVICE_ID_JOYPAD_R)) {
fdsSam->SwitchDiskSide();
}
}
shared_ptr<VsSystemActionManager> vsSam = Console::GetInstance()->GetSystemActionManager<VsSystemActionManager>();
if(vsSam) {
if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2)) {
if(ProcessAction(RETRO_DEVICE_ID_JOYPAD_L2)) {
vsSam->InsertCoin(0);
} else if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2)) {
}
if(ProcessAction(RETRO_DEVICE_ID_JOYPAD_R2)) {
vsSam->InsertCoin(1);
}
}