From 69bd4420cb381213e82028814e3d21117b6c3b3c Mon Sep 17 00:00:00 2001 From: Sebastien Pellizzari Date: Tue, 14 Feb 2017 09:17:41 +0100 Subject: [PATCH] XInputGetStateEx obtained through ordinal --- src/OpenTK/Platform/Windows/XInputJoystick.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/OpenTK/Platform/Windows/XInputJoystick.cs b/src/OpenTK/Platform/Windows/XInputJoystick.cs index 6b718def..357bfd28 100644 --- a/src/OpenTK/Platform/Windows/XInputJoystick.cs +++ b/src/OpenTK/Platform/Windows/XInputJoystick.cs @@ -371,8 +371,8 @@ namespace OpenTK.Platform.Windows // Load the entry points we are interested in from that dll GetCapabilities = (XInputGetCapabilities)Load("XInputGetCapabilities", typeof(XInputGetCapabilities)); GetState = - // undocumented XInputGetStateEx with support for the "Guide" button (requires XINPUT_1_3+) - (XInputGetState)Load("XInputGetStateEx", typeof(XInputGetState)) ?? + // undocumented XInputGetStateEx (Ordinal 100) with support for the "Guide" button (requires XINPUT_1_3+) + (XInputGetState)Load(100, typeof(XInputGetState)) ?? // documented XInputGetState (no support for the "Guide" button) (XInputGetState)Load("XInputGetState", typeof(XInputGetState)); SetState = (XInputSetState)Load("XInputSetState", typeof(XInputSetState)); @@ -380,6 +380,14 @@ namespace OpenTK.Platform.Windows #region Private Members + Delegate Load(ushort ordinal, Type type) + { + IntPtr pfunc = Functions.GetProcAddress(dll, (IntPtr)ordinal); + if (pfunc != IntPtr.Zero) + return Marshal.GetDelegateForFunctionPointer(pfunc, type); + return null; + } + Delegate Load(string name, Type type) { IntPtr pfunc = Functions.GetProcAddress(dll, name);