[Input] Added IJoystickDriver2.GetGuid() API
authorthefiddler <stapostol@gmail.com>
Tue, 31 Dec 2013 13:09:17 +0000 (14:09 +0100)
committerthefiddler <stapostol@gmail.com>
Tue, 31 Dec 2013 13:09:17 +0000 (14:09 +0100)
Source/OpenTK/Input/IJoystickDriver2.cs
Source/OpenTK/Input/Joystick.cs
Source/OpenTK/Platform/MacOS/HIDInput.cs
Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs
Source/OpenTK/Platform/Windows/WinMMJoystick.cs
Source/OpenTK/Platform/X11/X11Joystick.cs

index 1359d1d..8e536aa 100644 (file)
@@ -37,5 +37,6 @@ namespace OpenTK.Input
     {
         JoystickState GetState(int index);
         JoystickCapabilities GetCapabilities(int index);
+        Guid GetGuid(int index);
     }
 }
index 378b11f..2b10cfb 100644 (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);
index 0967afe..9090e70 100755 (executable)
@@ -381,6 +381,11 @@ namespace OpenTK.Platform.MacOS
             return new JoystickCapabilities();
         }
 
+        Guid IJoystickDriver2.GetGuid(int index)
+        {
+            return new Guid();
+        }
+
         #endregion
 
         #region NativeMethods
index 01c72b8..25b6b25 100644 (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
index fa84aba..313abdd 100644 (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
index 36fac9f..5f76dd5 100644 (file)
@@ -290,6 +290,11 @@ namespace OpenTK.Platform.X11
             throw new NotImplementedException();
         }
 
+        Guid IJoystickDriver2.GetGuid(int index)
+        {
+            throw new NotImplementedException();
+        }
+
         #endregion
     }
 }