Skip to content

Commit e011603

Browse files
committed
Fixes for movement issues on Windows
1 parent 99df170 commit e011603

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

engine/Orbit.Input/GameControllers/GameControllerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ public partial class GameControllerOptions
88
/// <summary>
99
/// Gets the threshold to use when comparing floats together in order to handle the inaccuracies that come with floats.
1010
/// </summary>
11-
public float ComparisonThreshold { get; } = 5f;
11+
public float ComparisonThreshold { get; set; } = 0.001f;
1212
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,10 @@ private GameControllerManager()
1515
public partial Task StartDiscovery()
1616
{
1717
Gamepad.GamepadAdded += OnGamepadAdded;
18-
RawGameController.RawGameControllerAdded += OnRawGameControllerAdded;
1918

2019
return Task.CompletedTask;
2120
}
2221

23-
private void OnRawGameControllerAdded(object? sender, RawGameController rawGameController)
24-
{
25-
var barry = new bool[rawGameController.ButtonCount];
26-
var sarry = new GameControllerSwitchPosition[rawGameController.SwitchCount];
27-
var aarry = new double[rawGameController.AxisCount];
28-
rawGameController.GetCurrentReading(barry, sarry, aarry);
29-
30-
//var controller = new GameController(rawGameController);
31-
//gameControllers.Add(controller);
32-
//GameControllerConnected?.Invoke(this, new GameControllerConnectedEventArgs(controller));
33-
}
34-
3522
private void OnGamepadAdded(object? sender, Gamepad gamepad)
3623
{
3724
var controller = new GameController(gamepad);

games/Platformer/MainPage.xaml.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Orbit.Engine;
1+
using System.Diagnostics;
2+
3+
using Orbit.Engine;
24
using Orbit.Input;
35

46
using Platformer.GameScenes;
@@ -102,14 +104,24 @@ private void GameControllerOnValueChanged(object? sender, GameControllerValueCha
102104

103105
if (e.ButtonName == gameController.LeftStick.XAxis.Name)
104106
{
105-
if (e.Value < 0.0000001f)
107+
if (e.Value == 0)
108+
{
109+
this.playerStateManager.State = CharacterState.Idle;
110+
}
111+
else if (e.Value < -0.001f)
106112
{
107113
this.playerStateManager.State = CharacterState.MovingLeft;
108114
}
109-
else if (e.Value > 0.0000001f)
115+
else if (e.Value > 0.001f)
110116
{
111117
this.playerStateManager.State = CharacterState.MovingRight;
112118
}
119+
else
120+
{
121+
this.playerStateManager.State = CharacterState.Idle;
122+
}
123+
124+
Debug.WriteLine($"e.Value = {e.Value} {this.playerStateManager.State}");
113125
}
114126
}
115127

0 commit comments

Comments
 (0)