2018-11-19 13:20:46 -05:00
|
|
|
#include "PH_GenericInput.h"
|
|
|
|
|
|
|
|
void CPH_GenericInput::Update(uint8* ram)
|
|
|
|
{
|
2023-10-30 21:58:23 +00:00
|
|
|
std::map<unsigned int, std::pair<uint8, uint8>> vibrationMap;
|
2023-10-31 19:50:26 +00:00
|
|
|
for(auto* interface : m_interfaces)
|
2018-11-19 13:20:46 -05:00
|
|
|
{
|
2020-09-15 09:24:04 -04:00
|
|
|
for(unsigned int pad = 0; pad < CInputBindingManager::MAX_PADS; pad++)
|
2018-11-19 13:20:46 -05:00
|
|
|
{
|
2020-09-15 09:24:04 -04:00
|
|
|
for(unsigned int buttonIdx = 0; buttonIdx < PS2::CControllerInfo::MAX_BUTTONS; buttonIdx++)
|
2018-11-19 13:20:46 -05:00
|
|
|
{
|
2020-09-15 09:24:04 -04:00
|
|
|
auto button = static_cast<PS2::CControllerInfo::BUTTON>(buttonIdx);
|
|
|
|
const auto& binding = m_bindingManager.GetBinding(pad, button);
|
|
|
|
if(!binding) continue;
|
|
|
|
uint32 value = binding->GetValue();
|
2021-09-11 13:27:24 -04:00
|
|
|
if(PS2::CControllerInfo::IsAxis(button))
|
2020-09-15 09:24:04 -04:00
|
|
|
{
|
2023-10-31 19:50:26 +00:00
|
|
|
interface->SetAxisState(pad, button, value & 0xFF, ram);
|
2020-09-15 09:24:04 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-31 19:50:26 +00:00
|
|
|
interface->SetButtonState(pad, button, value != 0, ram);
|
2020-09-15 09:24:04 -04:00
|
|
|
}
|
2018-11-19 13:20:46 -05:00
|
|
|
}
|
2023-10-30 21:58:23 +00:00
|
|
|
// Only Sio2 currently provides vibration information
|
|
|
|
auto& [largeMotor, smallMotor] = vibrationMap[pad];
|
|
|
|
interface->GetVibration(pad, largeMotor, smallMotor);
|
2018-11-19 13:20:46 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-30 22:11:10 +00:00
|
|
|
|
|
|
|
for(auto& [pad, motorInfo] : vibrationMap)
|
|
|
|
{
|
|
|
|
auto motorBinding = m_bindingManager.GetMotorBinding(pad);
|
|
|
|
if(!motorBinding) continue;
|
|
|
|
auto& [largeMotor, smallMotor] = motorInfo;
|
|
|
|
motorBinding->ProcessEvent(largeMotor, smallMotor);
|
|
|
|
}
|
2018-11-19 13:20:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
CInputBindingManager& CPH_GenericInput::GetBindingManager()
|
|
|
|
{
|
|
|
|
return m_bindingManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
CPadHandler::FactoryFunction CPH_GenericInput::GetFactoryFunction()
|
|
|
|
{
|
2018-11-28 22:32:27 -05:00
|
|
|
return []() { return new CPH_GenericInput(); };
|
2018-11-19 13:20:46 -05:00
|
|
|
}
|