SDL3MotionDriver: This calls "SDL_OpenSensor" in constructor, made disposable to call "SDL_CloseSensor" on dispose
This commit is contained in:
parent
f9caeb6b44
commit
93bfb604c5
1 changed files with 10 additions and 1 deletions
|
@ -7,7 +7,8 @@ using System.Numerics;
|
||||||
using static SDL3.SDL3;
|
using static SDL3.SDL3;
|
||||||
|
|
||||||
namespace Ryujinx.SDL3;
|
namespace Ryujinx.SDL3;
|
||||||
public unsafe class SDL3MotionDriver : IHandheld
|
|
||||||
|
public unsafe class SDL3MotionDriver : IHandheld, IDisposable
|
||||||
{
|
{
|
||||||
private Dictionary<SDL_SensorType, SDL_Sensor> sensors;
|
private Dictionary<SDL_SensorType, SDL_Sensor> sensors;
|
||||||
public SDL3MotionDriver()
|
public SDL3MotionDriver()
|
||||||
|
@ -16,6 +17,14 @@ public unsafe class SDL3MotionDriver : IHandheld
|
||||||
sensors = SDL_GetSensors().ToArray().ToDictionary(SDL_GetSensorTypeForID, SDL_OpenSensor);
|
sensors = SDL_GetSensors().ToArray().ToDictionary(SDL_GetSensorTypeForID, SDL_OpenSensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
foreach (var sensor in sensors.Values)
|
||||||
|
{
|
||||||
|
SDL_CloseSensor(sensor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 GetMotionData(MotionInputId gyroscope)
|
public Vector3 GetMotionData(MotionInputId gyroscope)
|
||||||
{
|
{
|
||||||
var data = stackalloc float[3];
|
var data = stackalloc float[3];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue