mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 05:55:49 +00:00
[SDL2] Implemented PacketNumber property
This commit is contained in:
parent
1ccf7e5ad2
commit
b513e35ea8
|
@ -42,6 +42,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
{
|
{
|
||||||
public IntPtr Handle { get; set; }
|
public IntPtr Handle { get; set; }
|
||||||
public Guid Guid { get; set; }
|
public Guid Guid { get; set; }
|
||||||
|
public int PacketNumber { get; set; }
|
||||||
public int HatCount { get; set; }
|
public int HatCount { get; set; }
|
||||||
public int BallCount { get; set; }
|
public int BallCount { get; set; }
|
||||||
public bool IsConnected { get; set; }
|
public bool IsConnected { get; set; }
|
||||||
|
@ -73,7 +74,6 @@ namespace OpenTK.Platform.SDL2
|
||||||
readonly Dictionary<int, int> sdl_instanceid_to_controllers = new Dictionary<int, int>();
|
readonly Dictionary<int, int> sdl_instanceid_to_controllers = new Dictionary<int, int>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public Sdl2JoystickDriver()
|
public Sdl2JoystickDriver()
|
||||||
{
|
{
|
||||||
joysticks_readonly = joysticks.AsReadOnly();
|
joysticks_readonly = joysticks.AsReadOnly();
|
||||||
|
@ -339,6 +339,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
||||||
float value = ev.Value * RangeMultiplier;
|
float value = ev.Value * RangeMultiplier;
|
||||||
joystick.SetAxis((JoystickAxis)ev.Axis, value);
|
joystick.SetAxis((JoystickAxis)ev.Axis, value);
|
||||||
|
joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -354,6 +355,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
int index = sdl_instanceid_to_joysticks[id];
|
int index = sdl_instanceid_to_joysticks[id];
|
||||||
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
||||||
// Todo: does it make sense to support balls?
|
// Todo: does it make sense to support balls?
|
||||||
|
joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -369,6 +371,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
int index = sdl_instanceid_to_joysticks[id];
|
int index = sdl_instanceid_to_joysticks[id];
|
||||||
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
||||||
joystick.SetButton((JoystickButton)ev.Button, ev.State == State.Pressed);
|
joystick.SetButton((JoystickButton)ev.Button, ev.State == State.Pressed);
|
||||||
|
joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -384,6 +387,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
int index = sdl_instanceid_to_joysticks[id];
|
int index = sdl_instanceid_to_joysticks[id];
|
||||||
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
|
||||||
// Todo: map hat to an extra axis
|
// Todo: map hat to an extra axis
|
||||||
|
joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -588,6 +592,7 @@ namespace OpenTK.Platform.SDL2
|
||||||
}
|
}
|
||||||
|
|
||||||
state.SetIsConnected(joystick.Details.IsConnected);
|
state.SetIsConnected(joystick.Details.IsConnected);
|
||||||
|
state.SetPacketNumber(joystick.Details.PacketNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
Loading…
Reference in a new issue