XInputGetStateEx obtained through ordinal

This commit is contained in:
Sebastien Pellizzari 2017-02-14 09:17:41 +01:00
parent ae9c076748
commit 69bd4420cb

View file

@ -371,8 +371,8 @@ namespace OpenTK.Platform.Windows
// Load the entry points we are interested in from that dll // Load the entry points we are interested in from that dll
GetCapabilities = (XInputGetCapabilities)Load("XInputGetCapabilities", typeof(XInputGetCapabilities)); GetCapabilities = (XInputGetCapabilities)Load("XInputGetCapabilities", typeof(XInputGetCapabilities));
GetState = GetState =
// undocumented XInputGetStateEx with support for the "Guide" button (requires XINPUT_1_3+) // undocumented XInputGetStateEx (Ordinal 100) with support for the "Guide" button (requires XINPUT_1_3+)
(XInputGetState)Load("XInputGetStateEx", typeof(XInputGetState)) ?? (XInputGetState)Load(100, typeof(XInputGetState)) ??
// documented XInputGetState (no support for the "Guide" button) // documented XInputGetState (no support for the "Guide" button)
(XInputGetState)Load("XInputGetState", typeof(XInputGetState)); (XInputGetState)Load("XInputGetState", typeof(XInputGetState));
SetState = (XInputSetState)Load("XInputSetState", typeof(XInputSetState)); SetState = (XInputSetState)Load("XInputSetState", typeof(XInputSetState));
@ -380,6 +380,14 @@ namespace OpenTK.Platform.Windows
#region Private Members #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) Delegate Load(string name, Type type)
{ {
IntPtr pfunc = Functions.GetProcAddress(dll, name); IntPtr pfunc = Functions.GetProcAddress(dll, name);