[Win] Improve WinMM.GetCapabilities performance
authorStefanos A <stapostol@gmail.com>
Thu, 16 Jan 2014 22:35:31 +0000 (23:35 +0100)
committerthefiddler <stapostol@gmail.com>
Thu, 11 Sep 2014 10:51:46 +0000 (12:51 +0200)
Polling joyGetCaps is very very slow, so we should not do that every
time GetCapabilities is called. Instead, we should call joyGetCaps once
and cache the results.

We need to find a different way to implement hotplugging.

Source/Examples/Main.cs
Source/OpenTK/Platform/Windows/WinCombinedJoystick.cs
Source/OpenTK/Platform/Windows/WinGLNative.cs

index 84dba6d..8e68e09 100644 (file)
@@ -101,6 +101,8 @@ namespace Examples
         public static void Main(string[] args)
         {
             Trace.Listeners.Add(new ConsoleTraceListener());
+            Tests.GameWindowStates.Main();
+            return;
 
             if (args.Length > 0)
             {
index 9a69666..77477eb 100644 (file)
@@ -50,6 +50,9 @@ namespace OpenTK.Platform.Windows
         readonly XInputJoystick xinput;
         readonly WinMMJoystick winmm;
 
+        readonly Dictionary<int, int> index_to_winmm =
+            new Dictionary<int, int>();
+
         #region Constructors
 
         public WinCombinedJoystick(XInputJoystick xinput, WinMMJoystick winmm)
index eb348c8..3320946 100644 (file)
@@ -82,6 +82,13 @@ namespace OpenTK.Platform.Windows
 
         const ClassStyle DefaultClassStyle = ClassStyle.OwnDC;
 
+        // Used for IInputDriver implementation
+        LegacyJoystickDriver joystick_driver = new LegacyJoystickDriver();
+        KeyboardDevice keyboard = new KeyboardDevice();
+        MouseDevice mouse = new MouseDevice();
+        IList<KeyboardDevice> keyboards = new List<KeyboardDevice>(1);
+        IList<MouseDevice> mice = new List<MouseDevice>(1);
+
         const long ExtendedBit = 1 << 24;           // Used to distinguish left and right control, alt and enter keys.
         
         public static readonly uint ShiftLeftScanCode = Functions.MapVirtualKey(VirtualKeys.LSHIFT, 0);