Reuse Sdl2Factory.InputDriver in Sdl2NativeWindow

This commit is contained in:
Stefanos A 2013-12-22 23:54:55 +01:00 committed by thefiddler
parent a72d70c3d0
commit 1d61bd9dd2
2 changed files with 7 additions and 4 deletions

View file

@ -34,7 +34,7 @@ namespace OpenTK.Platform.SDL2
{ {
class Sdl2Factory : IPlatformFactory class Sdl2Factory : IPlatformFactory
{ {
readonly IInputDriver2 InputDriver = new Sdl2InputDriver(); readonly Sdl2InputDriver InputDriver = new Sdl2InputDriver();
bool disposed; bool disposed;
/// <summary> /// <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) 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() public IDisplayDeviceDriver CreateDisplayDeviceDriver()

View file

@ -70,7 +70,7 @@ namespace OpenTK.Platform.SDL2
// Argument for KeyDown and KeyUp events (allocated once to avoid runtime allocations) // Argument for KeyDown and KeyUp events (allocated once to avoid runtime allocations)
readonly KeyboardKeyEventArgs key_args = new KeyboardKeyEventArgs(); readonly KeyboardKeyEventArgs key_args = new KeyboardKeyEventArgs();
readonly IInputDriver input_driver = new Sdl2InputDriver(); readonly IInputDriver input_driver;
readonly EventFilter EventFilterDelegate_GCUnsafe = FilterEvents; readonly EventFilter EventFilterDelegate_GCUnsafe = FilterEvents;
readonly IntPtr EventFilterDelegate; readonly IntPtr EventFilterDelegate;
@ -81,10 +81,13 @@ namespace OpenTK.Platform.SDL2
static readonly Sdl2KeyMap map = new Sdl2KeyMap(); static readonly Sdl2KeyMap map = new Sdl2KeyMap();
public Sdl2NativeWindow(int x, int y, int width, int height, 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) lock (sync)
{ {
this.input_driver = input_driver;
var bounds = device.Bounds; var bounds = device.Bounds;
var flags = TranslateFlags(options); var flags = TranslateFlags(options);
flags |= WindowFlags.OPENGL; flags |= WindowFlags.OPENGL;