From 1d61bd9dd2d14814c9f3cc93a35dc238400796c9 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Sun, 22 Dec 2013 23:54:55 +0100 Subject: [PATCH] Reuse Sdl2Factory.InputDriver in Sdl2NativeWindow --- Source/OpenTK/Platform/SDL2/Sdl2Factory.cs | 4 ++-- Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs b/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs index 9f2447ba..4c39156f 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs @@ -34,7 +34,7 @@ namespace OpenTK.Platform.SDL2 { class Sdl2Factory : IPlatformFactory { - readonly IInputDriver2 InputDriver = new Sdl2InputDriver(); + readonly Sdl2InputDriver InputDriver = new Sdl2InputDriver(); bool disposed; /// @@ -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() diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index dd26d534..9f24fdf7 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -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;