[Input] Added IJoystickDriver2.GetGuid() API

This commit is contained in:
thefiddler 2013-12-31 14:09:17 +01:00
parent cd143af60a
commit b9a8e365de
6 changed files with 44 additions and 1 deletions

View file

@ -37,5 +37,6 @@ namespace OpenTK.Input
{
JoystickState GetState(int index);
JoystickCapabilities GetCapabilities(int index);
Guid GetGuid(int index);
}
}

View file

@ -48,6 +48,11 @@ namespace OpenTK.Input
return implementation.GetState(index);
}
internal static Guid GetGuid(int index)
{
return implementation.GetGuid(index);
}
//public string GetName(int index)
//{
// return implementation.GetName(index);

View file

@ -381,6 +381,11 @@ namespace OpenTK.Platform.MacOS
return new JoystickCapabilities();
}
Guid IJoystickDriver2.GetGuid(int index)
{
return new Guid();
}
#endregion
#region NativeMethods

View file

@ -38,9 +38,10 @@ namespace OpenTK.Platform.SDL2
readonly MappedGamePadDriver gamepad_driver = new MappedGamePadDriver();
bool disposed;
struct Sdl2JoystickDetails
class Sdl2JoystickDetails
{
public IntPtr Handle { get; set; }
public Guid Guid { get; set; }
public int HatCount { get; set; }
public int BallCount { get; set; }
public bool IsConnected { get; set; }
@ -99,6 +100,7 @@ namespace OpenTK.Platform.SDL2
joystick = new JoystickDevice<Sdl2JoystickDetails>(id, num_axes, num_buttons);
joystick.Description = SDL.JoystickName(handle);
joystick.Details.Handle = handle;
joystick.Details.Guid = SDL.JoystickGetGUID(handle).ToGuid();
joystick.Details.HatCount = num_hats;
joystick.Details.BallCount = num_balls;
@ -606,6 +608,19 @@ namespace OpenTK.Platform.SDL2
return new JoystickCapabilities();
}
Guid IJoystickDriver2.GetGuid(int index)
{
Guid guid = new Guid();
if (IsJoystickValid(index))
{
JoystickDevice<Sdl2JoystickDetails> joystick =
(JoystickDevice<Sdl2JoystickDetails>)joysticks[index];
return joystick.Details.Guid;
}
return guid;
}
#endregion
#region IDisposable Members

View file

@ -333,6 +333,18 @@ namespace OpenTK.Platform.Windows
return state;
}
public Guid GetGuid(int index)
{
Guid guid = new Guid();
if (IsValid(index))
{
// Todo: implement WinMM Guid retrieval
}
return guid;
}
#endregion
#region IDisposable

View file

@ -290,6 +290,11 @@ namespace OpenTK.Platform.X11
throw new NotImplementedException();
}
Guid IJoystickDriver2.GetGuid(int index)
{
throw new NotImplementedException();
}
#endregion
}
}