[Mac] Fixed joystick Guid calculation
The result now matches the output of SDL2 as well as the entries in the GamePad configuration database.
This commit is contained in:
parent
41f1f92cdf
commit
d4c6b2e699
1 changed files with 12 additions and 1 deletions
|
@ -558,7 +558,18 @@ namespace OpenTK.Platform.MacOS
|
|||
guid_bytes.AddRange(name_bytes);
|
||||
}
|
||||
|
||||
return new Guid(guid_bytes.ToArray());
|
||||
// The Guid(byte[]) constructor performs byte-swapping on the first 4+2+2 bytes, while
|
||||
// the Guid(string) constructor does not. Since our database is using the string
|
||||
// constructor, we need to compensate for this difference or the database lookups
|
||||
// will fail.
|
||||
byte[] guid_array = guid_bytes.ToArray();
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(guid_array, 0, 4);
|
||||
Array.Reverse(guid_array, 4, 2);
|
||||
Array.Reverse(guid_array, 6, 2);
|
||||
}
|
||||
return new Guid(guid_array);
|
||||
}
|
||||
|
||||
JoystickData CreateJoystick(IntPtr sender, IntPtr device)
|
||||
|
|
Loading…
Reference in a new issue