[Win] Separate keyboard/mouse & joystick drivers
Keyboard/mouse support comes through WinRawInput; joystick support through CombinedJoystickDriver. These drivers are now instantiated separately.
This commit is contained in:
parent
5cfde8ff0f
commit
06e63946cc
1 changed files with 36 additions and 10 deletions
|
@ -40,7 +40,12 @@ namespace OpenTK.Platform.Windows
|
||||||
class WinFactory : PlatformFactoryBase
|
class WinFactory : PlatformFactoryBase
|
||||||
{
|
{
|
||||||
readonly object SyncRoot = new object();
|
readonly object SyncRoot = new object();
|
||||||
IInputDriver2 inputDriver;
|
|
||||||
|
// The input drivers must be constructed lazily, *after* the
|
||||||
|
// WinFactory constructor has finished running. The reason is
|
||||||
|
// that they call WinFactory methods internally.
|
||||||
|
WinRawInput rawinput_driver; // For keyboard and mouse input
|
||||||
|
WinCombinedJoystick joystick_driver; // For joystick input
|
||||||
|
|
||||||
internal static IntPtr OpenGLHandle { get; private set; }
|
internal static IntPtr OpenGLHandle { get; private set; }
|
||||||
const string OpenGLName = "OPENGL32.DLL";
|
const string OpenGLName = "OPENGL32.DLL";
|
||||||
|
@ -112,41 +117,61 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
public override OpenTK.Input.IKeyboardDriver2 CreateKeyboardDriver()
|
public override OpenTK.Input.IKeyboardDriver2 CreateKeyboardDriver()
|
||||||
{
|
{
|
||||||
return InputDriver.KeyboardDriver;
|
return RawInputDriver.KeyboardDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override OpenTK.Input.IMouseDriver2 CreateMouseDriver()
|
public override OpenTK.Input.IMouseDriver2 CreateMouseDriver()
|
||||||
{
|
{
|
||||||
return InputDriver.MouseDriver;
|
return RawInputDriver.MouseDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override OpenTK.Input.IGamePadDriver CreateGamePadDriver()
|
public override OpenTK.Input.IGamePadDriver CreateGamePadDriver()
|
||||||
{
|
{
|
||||||
return InputDriver.GamePadDriver;
|
return new MappedGamePadDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IJoystickDriver2 CreateJoystickDriver()
|
public override IJoystickDriver2 CreateJoystickDriver()
|
||||||
{
|
{
|
||||||
return InputDriver.JoystickDriver;
|
return CombinedJoystickDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
IInputDriver2 InputDriver
|
#region Private Members
|
||||||
|
|
||||||
|
WinRawInput RawInputDriver
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (inputDriver == null)
|
if (rawinput_driver == null)
|
||||||
{
|
{
|
||||||
inputDriver = new WinRawInput();
|
rawinput_driver = new WinRawInput();
|
||||||
}
|
}
|
||||||
return inputDriver;
|
return rawinput_driver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WinCombinedJoystick CombinedJoystickDriver
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
if (joystick_driver == null)
|
||||||
|
{
|
||||||
|
joystick_driver = new WinCombinedJoystick(
|
||||||
|
new XInputJoystick(), new WinMMJoystick());
|
||||||
|
}
|
||||||
|
return joystick_driver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
||||||
protected override void Dispose(bool manual)
|
protected override void Dispose(bool manual)
|
||||||
|
@ -155,7 +180,8 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
InputDriver.Dispose();
|
rawinput_driver.Dispose();
|
||||||
|
joystick_driver.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Dispose(manual);
|
base.Dispose(manual);
|
||||||
|
|
Loading…
Reference in a new issue