Project64-input: Get axis on GetKeys
This commit is contained in:
parent
7bbba05024
commit
64a3e69cce
|
@ -63,6 +63,8 @@ void CProject64Input::GetKeys(int32_t Control, BUTTONS * Keys)
|
|||
Keys->U_CBUTTON = m_DirectInput->IsButtonPressed(Controller.U_CBUTTON);
|
||||
Keys->R_TRIG = m_DirectInput->IsButtonPressed(Controller.R_TRIG);
|
||||
Keys->L_TRIG = m_DirectInput->IsButtonPressed(Controller.L_TRIG);
|
||||
Keys->Y_AXIS = m_DirectInput->AxisPos(Controller.U_ANALOG, Controller.D_ANALOG, Controller.Range);
|
||||
Keys->X_AXIS = m_DirectInput->AxisPos(Controller.R_ANALOG, Controller.L_ANALOG, Controller.Range);
|
||||
}
|
||||
|
||||
void CProject64Input::StartScanDevices(int32_t DisplayCtrlId)
|
||||
|
|
|
@ -230,6 +230,35 @@ bool CDirectInput::IsButtonPressed(BUTTON & Button)
|
|||
return false;
|
||||
}
|
||||
|
||||
int8_t CDirectInput::AxisPos(BUTTON & PosBtn, BUTTON & NegBtn, uint8_t Range)
|
||||
{
|
||||
int8_t Pos = 0;
|
||||
if (PosBtn.Device != nullptr)
|
||||
{
|
||||
DEVICE & Device = *(DEVICE *)PosBtn.Device;
|
||||
switch (PosBtn.BtnType)
|
||||
{
|
||||
case BTNTYPE_KEYBUTTON:
|
||||
Pos += (Device.State.Keyboard[PosBtn.Offset] & 0x80) != 0 ? 127 : 0;
|
||||
}
|
||||
}
|
||||
if (NegBtn.Device != nullptr)
|
||||
{
|
||||
DEVICE & Device = *(DEVICE *)NegBtn.Device;
|
||||
switch (NegBtn.BtnType)
|
||||
{
|
||||
case BTNTYPE_KEYBUTTON:
|
||||
Pos -= (Device.State.Keyboard[NegBtn.Offset] & 0x80) != 0 ? 127 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (Pos != 0)
|
||||
{
|
||||
Pos = (int8_t)(Pos * (Range / 100.0));
|
||||
}
|
||||
return Pos;
|
||||
}
|
||||
|
||||
void CDirectInput::UpdateDeviceData(void)
|
||||
{
|
||||
for (DEVICE_MAP::iterator itr = m_Devices.begin(); itr != m_Devices.end(); itr++)
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
ScanResult ScanDevices(BUTTON & Button);
|
||||
std::wstring ButtonAssignment(BUTTON & Button);
|
||||
bool IsButtonPressed(BUTTON & Button);
|
||||
int8_t AxisPos(BUTTON & PosBtn, BUTTON & NegBtn, uint8_t Range);
|
||||
void UpdateDeviceData(void);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue