Reuse Sdl2Factory.InputDriver in Sdl2NativeWindow
authorStefanos A <stapostol@gmail.com>
Sun, 22 Dec 2013 22:54:55 +0000 (23:54 +0100)
committerthefiddler <stapostol@gmail.com>
Tue, 24 Dec 2013 16:18:01 +0000 (17:18 +0100)
Source/OpenTK/Platform/SDL2/Sdl2Factory.cs
Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs

index 9f2447baeccc83ba9ca90f87bdc16244b994ff22..4c39156fe040216ff359a4de5b63dcad1e59f87b 100644 (file)
@@ -34,7 +34,7 @@ namespace OpenTK.Platform.SDL2
 {
     class Sdl2Factory : IPlatformFactory
     {
-        readonly IInputDriver2 InputDriver = new Sdl2InputDriver();
+        readonly Sdl2InputDriver InputDriver = new Sdl2InputDriver();
         bool disposed;
 
         /// <summary>
@@ -58,7 +58,7 @@ namespace OpenTK.Platform.SDL2
 
         public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
         {
-            return new Sdl2NativeWindow(x, y, width, height, title, options, device);
+            return new Sdl2NativeWindow(x, y, width, height, title, options, device, InputDriver);
         }
 
         public IDisplayDeviceDriver CreateDisplayDeviceDriver()
index dd26d534d62c7c71064885ecaf88d73fb70827f6..9f24fdf7441401619bf68aee82d5fbbc7912473a 100644 (file)
@@ -70,7 +70,7 @@ namespace OpenTK.Platform.SDL2
         // Argument for KeyDown and KeyUp events (allocated once to avoid runtime allocations)
         readonly KeyboardKeyEventArgs key_args = new KeyboardKeyEventArgs();
 
-        readonly IInputDriver input_driver = new Sdl2InputDriver();
+        readonly IInputDriver input_driver;
 
         readonly EventFilter EventFilterDelegate_GCUnsafe = FilterEvents;
         readonly IntPtr EventFilterDelegate;
@@ -81,10 +81,13 @@ namespace OpenTK.Platform.SDL2
         static readonly Sdl2KeyMap map = new Sdl2KeyMap();
 
         public Sdl2NativeWindow(int x, int y, int width, int height,
-            string title, GameWindowFlags options, DisplayDevice device)
+            string title, GameWindowFlags options, DisplayDevice device,
+            IInputDriver input_driver)
         {
             lock (sync)
             {
+                this.input_driver = input_driver;
+
                 var bounds = device.Bounds;
                 var flags = TranslateFlags(options);
                 flags |= WindowFlags.OPENGL;