mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-23 09:09:45 +00:00
Add back RemapControllerButtons and SwapButtons - needed by some VS games
This commit is contained in:
parent
a03ff76e33
commit
4026a25a99
@ -256,3 +256,17 @@ MouseMovement BaseControlDevice::GetMovement()
|
|||||||
SetCoordinates({ 0, 0 });
|
SetCoordinates({ 0, 0 });
|
||||||
return { pos.X, pos.Y };
|
return { pos.X, pos.Y };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseControlDevice::SwapButtons(shared_ptr<BaseControlDevice> state1, uint8_t button1, shared_ptr<BaseControlDevice> state2, uint8_t button2)
|
||||||
|
{
|
||||||
|
bool pressed1 = state1->IsPressed(button1);
|
||||||
|
bool pressed2 = state2->IsPressed(button2);
|
||||||
|
|
||||||
|
state1->ClearBit(button1);
|
||||||
|
state2->ClearBit(button2);
|
||||||
|
|
||||||
|
if(pressed1)
|
||||||
|
state2->SetBit(button2);
|
||||||
|
if(pressed2)
|
||||||
|
state1->SetBit(button1);
|
||||||
|
}
|
||||||
|
@ -78,4 +78,6 @@ public:
|
|||||||
|
|
||||||
virtual uint8_t ReadRAM(uint16_t addr) = 0;
|
virtual uint8_t ReadRAM(uint16_t addr) = 0;
|
||||||
virtual void WriteRAM(uint16_t addr, uint8_t value) = 0;
|
virtual void WriteRAM(uint16_t addr, uint8_t value) = 0;
|
||||||
|
|
||||||
|
void static SwapButtons(std::shared_ptr<BaseControlDevice> state1, uint8_t button1, std::shared_ptr<BaseControlDevice> state2, uint8_t button2);
|
||||||
};
|
};
|
||||||
|
@ -229,6 +229,11 @@ uint8_t ControlManager::GetOpenBusMask(uint8_t port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlManager::RemapControllerButtons()
|
||||||
|
{
|
||||||
|
//Used by VS System games
|
||||||
|
}
|
||||||
|
|
||||||
void ControlManager::UpdateInputState()
|
void ControlManager::UpdateInputState()
|
||||||
{
|
{
|
||||||
if(_isLagging)
|
if(_isLagging)
|
||||||
@ -256,6 +261,9 @@ void ControlManager::UpdateInputState()
|
|||||||
device->OnAfterSetState();
|
device->OnAfterSetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Used by VS System games
|
||||||
|
RemapControllerButtons();
|
||||||
|
|
||||||
_pollCounter++;
|
_pollCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ protected:
|
|||||||
|
|
||||||
virtual void StreamState(bool saving) override;
|
virtual void StreamState(bool saving) override;
|
||||||
virtual ControllerType GetControllerType(uint8_t port);
|
virtual ControllerType GetControllerType(uint8_t port);
|
||||||
|
virtual void RemapControllerButtons();
|
||||||
virtual uint8_t GetOpenBusMask(uint8_t port);
|
virtual uint8_t GetOpenBusMask(uint8_t port);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -52,6 +52,43 @@ uint8_t VsControlManager::GetPrgChrSelectBit()
|
|||||||
return _prgChrSelectBit;
|
return _prgChrSelectBit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VsControlManager::RemapControllerButtons()
|
||||||
|
{
|
||||||
|
std::shared_ptr<StandardController> controllers[2];
|
||||||
|
controllers[0] = std::dynamic_pointer_cast<StandardController>(GetControlDevice(0));
|
||||||
|
controllers[1] = std::dynamic_pointer_cast<StandardController>(GetControlDevice(1));
|
||||||
|
|
||||||
|
if(!controllers[0] || !controllers[1]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameInputType inputType = _console->GetRomInfo().InputType;
|
||||||
|
if(inputType == GameInputType::VsSystemSwapped) {
|
||||||
|
//Swap controllers 1 & 2
|
||||||
|
ControlDeviceState port1State = controllers[0]->GetRawState();
|
||||||
|
ControlDeviceState port2State = controllers[1]->GetRawState();
|
||||||
|
controllers[0]->SetRawState(port2State);
|
||||||
|
controllers[1]->SetRawState(port1State);
|
||||||
|
|
||||||
|
//But don't swap the start/select buttons
|
||||||
|
BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::Start, controllers[1], StandardController::Buttons::Start);
|
||||||
|
BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::Select, controllers[1], StandardController::Buttons::Select);
|
||||||
|
} else if(inputType == GameInputType::VsSystemSwapAB) {
|
||||||
|
//Swap buttons P1 A & P2 B (Pinball (Japan))
|
||||||
|
BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::B, controllers[1], StandardController::Buttons::A);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Swap Start/Select for all configurations (makes it more intuitive)
|
||||||
|
BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::Start, controllers[0], StandardController::Buttons::Select);
|
||||||
|
BaseControlDevice::SwapButtons(controllers[1], StandardController::Buttons::Start, controllers[1], StandardController::Buttons::Select);
|
||||||
|
|
||||||
|
if(_vsSystemType == VsSystemType::RaidOnBungelingBayProtection || _vsSystemType == VsSystemType::IceClimberProtection) {
|
||||||
|
//Bit 3 of the input status must always be on
|
||||||
|
controllers[0]->SetBit(StandardController::Buttons::Start);
|
||||||
|
controllers[1]->SetBit(StandardController::Buttons::Start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t VsControlManager::GetOpenBusMask(uint8_t port)
|
uint8_t VsControlManager::GetOpenBusMask(uint8_t port)
|
||||||
{
|
{
|
||||||
return 0x00;
|
return 0x00;
|
||||||
|
@ -44,6 +44,7 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
ControllerType GetControllerType(uint8_t port) override;
|
ControllerType GetControllerType(uint8_t port) override;
|
||||||
|
void RemapControllerButtons() override;
|
||||||
uint8_t GetOpenBusMask(uint8_t port) override;
|
uint8_t GetOpenBusMask(uint8_t port) override;
|
||||||
|
|
||||||
void UpdateSlaveMasterBit(uint8_t slaveMasterBit);
|
void UpdateSlaveMasterBit(uint8_t slaveMasterBit);
|
||||||
|
Loading…
Reference in New Issue
Block a user