Add GamepadDPadX/GamepadDPadY input axes for gamepad DPad

This commit is contained in:
Wojciech Figat
2022-07-25 10:32:48 +02:00
parent a4478b9497
commit 1f495205af
2 changed files with 22 additions and 3 deletions

View File

@@ -358,4 +358,14 @@ API_ENUM() enum class InputAxisType
/// The keyboard only mode. For key inputs.
/// </summary>
KeyboardOnly = 9,
/// <summary>
/// Pad X axis - left/right (DPad / Directional Pad).
/// </summary>
GamepadDPadX = 10,
/// <summary>
/// Pad Y axis - up/down (DPad / Directional Pad).
/// </summary>
GamepadDPadY = 11,
};

View File

@@ -862,7 +862,7 @@ void InputService::Update()
}
// Get axis raw value
float axisRawValue;
float axisRawValue = 0.0f;
switch (config.Axis)
{
case InputAxisType::MouseX:
@@ -892,8 +892,17 @@ void InputService::Update()
case InputAxisType::GamepadRightTrigger:
axisRawValue = Input::GetGamepadAxis(config.Gamepad, GamepadAxis::RightTrigger);
break;
default:
axisRawValue = 0.0f;
case InputAxisType::GamepadDPadX:
if (Input::GetGamepadButton(config.Gamepad, GamepadButton::DPadRight))
axisRawValue = 1;
else if (Input::GetGamepadButton(config.Gamepad, GamepadButton::DPadLeft))
axisRawValue = -1;
break;
case InputAxisType::GamepadDPadY:
if (Input::GetGamepadButton(config.Gamepad, GamepadButton::DPadUp))
axisRawValue = 1;
else if (Input::GetGamepadButton(config.Gamepad, GamepadButton::DPadDown))
axisRawValue = -1;
break;
}