Skip to content

Commit eeec378

Browse files
committed
Invert clamping of up down values for WebGLGamepad
We were clamping with the wrong values which would make the UI not react to up and down when using Gamepad sticks.
1 parent bb6a72d commit eeec378

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Assets/Tests/InputSystem/Plugins/WebGLTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ public void Devices_SupportsWebGLStandardGamepads()
4343
Assert.That(gamepad.leftTrigger.ReadUnprocessedValue(), Is.EqualTo(0.123).Within(0.0001));
4444
Assert.That(gamepad.rightTrigger.ReadUnprocessedValue(), Is.EqualTo(0.234).Within(0.0001));
4545

46-
AssertStickValues(gamepad.leftStick, new Vector2(0.345f, -0.456f), -0.456f, 0, 0, 0.345f);
47-
AssertStickValues(gamepad.rightStick, new Vector2(0.567f, -0.678f), -0.678f, 0, 0, 0.567f);
48-
46+
AssertStickValues(gamepad.leftStick, new Vector2(0.345f, -0.456f), 0, 0.456f, 0, 0.345f);
47+
AssertStickValues(gamepad.rightStick, new Vector2(0.567f, -0.678f), 0, 0.678f, 0, 0.567f);
4948

5049
InputSystem.QueueStateEvent(gamepad, new WebGLGamepadState
5150
{
@@ -54,9 +53,8 @@ public void Devices_SupportsWebGLStandardGamepads()
5453
});
5554
InputSystem.Update();
5655

57-
AssertStickValues(gamepad.leftStick, new Vector2(-0.345f, 0.456f), 0, -0.456f, 0.345f, 0);
58-
AssertStickValues(gamepad.rightStick, new Vector2(-0.567f, 0.678f), 0, -0.678f, 0.567f, 0);
59-
56+
AssertStickValues(gamepad.leftStick, new Vector2(-0.345f, 0.456f), 0.456f, 0, 0.345f, 0);
57+
AssertStickValues(gamepad.rightStick, new Vector2(-0.567f, 0.678f), 0.678f, 0, 0.567f, 0);
6058

6159
// Test all buttons.
6260
AssertButtonPress(gamepad, new WebGLGamepadState().WithButton(GamepadButton.South), gamepad[GamepadButton.South]);

Packages/com.unity.inputsystem/InputSystem/Plugins/WebGL/WebGLGamepad.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ internal unsafe struct WebGLGamepadState : IInputStateTypeInfo
1919
[InputControl(name = "leftStick", offset = 0)]
2020
[InputControl(name = "rightStick", offset = 8)]
2121
[InputControl(name = "leftStick/y", parameters = "invert")]
22-
[InputControl(name = "leftStick/up", parameters = "clamp=2,clampMin=0,clampMax=1,invert")]
23-
[InputControl(name = "leftStick/down", parameters = "clamp=2,clampMin=-1,clampMax=0,invert=false")]
22+
[InputControl(name = "leftStick/up", parameters = "clamp=2,clampMin=-1,clampMax=0,invert")]
23+
[InputControl(name = "leftStick/down", parameters = "clamp=2,clampMin=0,clampMax=1,invert=false")]
2424
[InputControl(name = "rightStick/y", parameters = "invert")]
25-
[InputControl(name = "rightStick/up", parameters = "clamp=2,clampMin=0,clampMax=1,invert")]
26-
[InputControl(name = "rightStick/down", parameters = "clamp=2,clampMin=-1,clampMax=0,invert=false")]
25+
[InputControl(name = "rightStick/up", parameters = "clamp=2,clampMin=-1,clampMax=0,invert")]
26+
[InputControl(name = "rightStick/down", parameters = "clamp=2,clampMin=0,clampMax=1,invert=false")]
2727
// All the buttons we need to bump from single bits to full floats and reset bit offsets.
2828
[InputControl(name = "buttonSouth", offset = ButtonOffset + 0 * 4, bit = 0, format = "FLT")]
2929
[InputControl(name = "buttonEast", offset = ButtonOffset + 1 * 4, bit = 0, format = "FLT")]

0 commit comments

Comments
 (0)