Skip to content

Commit 99df170

Browse files
committed
Merge branch 'feature/game-controller-support' of github.com:bijington/orbit into feature/game-controller-support
2 parents 2ca611c + 8a38cbf commit 99df170

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

engine/Orbit.Input/Platforms/Windows/GameController.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Windows.Gaming.Input;
1+
using Microsoft.UI.Xaml.Controls.Primitives;
2+
3+
using Windows.Gaming.Input;
24

35
namespace Orbit.Input;
46

@@ -17,6 +19,12 @@ public GameController(Gamepad gamepad)
1719

1820
LeftShoulder = new Shoulder(this, nameof(LeftShoulder));
1921
RightShoulder = new Shoulder(this, nameof(RightShoulder));
22+
23+
North = new ButtonValue<bool>(this, nameof(North));
24+
South = new ButtonValue<bool>(this, nameof(South));
25+
East = new ButtonValue<bool>(this, nameof(East));
26+
West = new ButtonValue<bool>(this, nameof(West));
27+
Pause = new ButtonValue<bool>(this, nameof(Pause));
2028
}
2129

2230
public void StartUpdates(TimeSpan updateFrequency)
@@ -49,24 +57,24 @@ private void Update()
4957
{
5058
var reading = gamepad.GetCurrentReading();
5159

52-
LeftStick.XAxis = (float)reading.LeftThumbstickX;
53-
LeftStick.YAxis = (float)reading.LeftThumbstickY;
60+
LeftStick.XAxis.Value = (float)reading.LeftThumbstickX;
61+
LeftStick.YAxis.Value = (float)reading.LeftThumbstickY;
5462

55-
RightStick.XAxis = (float)reading.RightThumbstickX;
56-
RightStick.YAxis = (float)reading.RightThumbstickY;
63+
RightStick.XAxis.Value = (float)reading.RightThumbstickX;
64+
RightStick.YAxis.Value = (float)reading.RightThumbstickY;
5765

58-
LeftShoulder.Button = reading.Buttons.HasFlag(GamepadButtons.LeftShoulder);
59-
LeftShoulder.Trigger = (float)reading.LeftTrigger;
66+
LeftShoulder.Button.Value = reading.Buttons.HasFlag(GamepadButtons.LeftShoulder);
67+
LeftShoulder.Trigger.Value = (float)reading.LeftTrigger;
6068

61-
RightShoulder.Button = reading.Buttons.HasFlag(GamepadButtons.RightShoulder);
62-
RightShoulder.Trigger = (float)reading.RightTrigger;
69+
RightShoulder.Button.Value = reading.Buttons.HasFlag(GamepadButtons.RightShoulder);
70+
RightShoulder.Trigger.Value = (float)reading.RightTrigger;
6371

64-
ButtonNorth = reading.Buttons.HasFlag(GamepadButtons.Y);
65-
ButtonEast = reading.Buttons.HasFlag(GamepadButtons.B);
66-
ButtonSouth = reading.Buttons.HasFlag(GamepadButtons.A);
67-
ButtonWest = reading.Buttons.HasFlag(GamepadButtons.X);
72+
North.Value = reading.Buttons.HasFlag(GamepadButtons.Y);
73+
East.Value = reading.Buttons.HasFlag(GamepadButtons.B);
74+
South.Value = reading.Buttons.HasFlag(GamepadButtons.A);
75+
West.Value = reading.Buttons.HasFlag(GamepadButtons.X);
6876

69-
Dpad.XAxis = reading.Buttons.HasFlag(GamepadButtons.DPadRight) ? 1f : reading.Buttons.HasFlag(GamepadButtons.DPadLeft) ? -1f : 0f;
70-
Dpad.YAxis = reading.Buttons.HasFlag(GamepadButtons.DPadDown) ? 1f : reading.Buttons.HasFlag(GamepadButtons.DPadUp) ? -1f : 0f;
77+
Dpad.XAxis.Value = reading.Buttons.HasFlag(GamepadButtons.DPadRight) ? 1f : reading.Buttons.HasFlag(GamepadButtons.DPadLeft) ? -1f : 0f;
78+
Dpad.YAxis.Value = reading.Buttons.HasFlag(GamepadButtons.DPadDown) ? 1f : reading.Buttons.HasFlag(GamepadButtons.DPadUp) ? -1f : 0f;
7179
}
7280
}

0 commit comments

Comments
 (0)