class WinFactory : PlatformFactoryBase
{
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; }
const string OpenGLName = "OPENGL32.DLL";
public override OpenTK.Input.IKeyboardDriver2 CreateKeyboardDriver()
{
- return InputDriver.KeyboardDriver;
+ return RawInputDriver.KeyboardDriver;
}
public override OpenTK.Input.IMouseDriver2 CreateMouseDriver()
{
- return InputDriver.MouseDriver;
+ return RawInputDriver.MouseDriver;
}
public override OpenTK.Input.IGamePadDriver CreateGamePadDriver()
{
- return InputDriver.GamePadDriver;
+ return new MappedGamePadDriver();
}
public override IJoystickDriver2 CreateJoystickDriver()
{
- return InputDriver.JoystickDriver;
+ return CombinedJoystickDriver;
}
#endregion
- IInputDriver2 InputDriver
+ #region Private Members
+
+ WinRawInput RawInputDriver
{
get
{
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
protected override void Dispose(bool manual)
{
if (manual)
{
- InputDriver.Dispose();
+ rawinput_driver.Dispose();
+ joystick_driver.Dispose();
}
base.Dispose(manual);