Merge pull request #487 from spellizzari/develop

XInputGetStateEx obtained through ordinal
This commit is contained in:
varon 2017-03-20 19:48:36 +02:00 committed by GitHub
commit f6af0d0f4a

View file

@ -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);