mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-19 23:28:42 +02:00
Correct the threshold for control stick buttons (#1483)
This was tested against HW with https://github.com/Xpl0itR/Input-Test/tree/master/Input-Test and a few changes to record the minimum value axis value when the stick buttons were marked as pressed.
This commit is contained in:
parent
2ce59c44bc
commit
4b1bed1b05
1 changed files with 9 additions and 8 deletions
|
@ -87,17 +87,18 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
|
||||||
public ControllerKeys UpdateStickButtons(JoystickPosition leftStick, JoystickPosition rightStick)
|
public ControllerKeys UpdateStickButtons(JoystickPosition leftStick, JoystickPosition rightStick)
|
||||||
{
|
{
|
||||||
|
const int stickButtonThreshold = short.MaxValue / 2;
|
||||||
ControllerKeys result = 0;
|
ControllerKeys result = 0;
|
||||||
|
|
||||||
result |= (leftStick.Dx < 0) ? ControllerKeys.LStickLeft : result;
|
result |= (leftStick.Dx < -stickButtonThreshold) ? ControllerKeys.LStickLeft : result;
|
||||||
result |= (leftStick.Dx > 0) ? ControllerKeys.LStickRight : result;
|
result |= (leftStick.Dx > stickButtonThreshold) ? ControllerKeys.LStickRight : result;
|
||||||
result |= (leftStick.Dy < 0) ? ControllerKeys.LStickDown : result;
|
result |= (leftStick.Dy < -stickButtonThreshold) ? ControllerKeys.LStickDown : result;
|
||||||
result |= (leftStick.Dy > 0) ? ControllerKeys.LStickUp : result;
|
result |= (leftStick.Dy > stickButtonThreshold) ? ControllerKeys.LStickUp : result;
|
||||||
|
|
||||||
result |= (rightStick.Dx < 0) ? ControllerKeys.RStickLeft : result;
|
result |= (rightStick.Dx < -stickButtonThreshold) ? ControllerKeys.RStickLeft : result;
|
||||||
result |= (rightStick.Dx > 0) ? ControllerKeys.RStickRight : result;
|
result |= (rightStick.Dx > stickButtonThreshold) ? ControllerKeys.RStickRight : result;
|
||||||
result |= (rightStick.Dy < 0) ? ControllerKeys.RStickDown : result;
|
result |= (rightStick.Dy < -stickButtonThreshold) ? ControllerKeys.RStickDown : result;
|
||||||
result |= (rightStick.Dy > 0) ? ControllerKeys.RStickUp : result;
|
result |= (rightStick.Dy > stickButtonThreshold) ? ControllerKeys.RStickUp : result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue