From 2df0496c44129a37b5ffd900f2fff23f92b32092 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Fri, 12 Sep 2014 08:43:20 +0200 Subject: [PATCH] [SDL] Correctly byteswap Guid Fixes an issue where GamePad Guids would fail to be matched with the Guids in the configuration database. --- Source/OpenTK/Platform/SDL2/Sdl2.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2.cs b/Source/OpenTK/Platform/SDL2/Sdl2.cs index a987c3bf..4690e7d9 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2.cs @@ -1542,6 +1542,16 @@ namespace OpenTK.Platform.SDL2 } } + // The Guid(byte[]) constructor swaps the first 4+2+2 bytes. + // Compensate for that, otherwise we will not be able to match + // the Guids in the configuration database. + if (BitConverter.IsLittleEndian) + { + Array.Reverse(data, 0, 4); + Array.Reverse(data, 4, 2); + Array.Reverse(data, 6, 2); + } + return new Guid(data); } }