mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-28 01:15:50 +00:00
86588ea60c
* Source/OpenTK/Platform/Factory.cs: * Source/OpenTK/Input/InputDriver.cs: * Source/OpenTK/Input/IMouseDriver.cs: * Source/OpenTK/Platform/X11/X11Input.cs: * Source/OpenTK/Platform/X11/X11Factory.cs: * Source/OpenTK/Platform/Windows/WMInput.cs: * Source/OpenTK/Platform/IPlatformFactory.cs: * Source/OpenTK/Platform/MacOS/CarbonInput.cs: * Source/OpenTK/Platform/Windows/WinFactory.cs: * Source/OpenTK/Platform/MacOS/MacOSFactory.cs: * Source/OpenTK/Platform/Windows/WinGLNative.cs: * Source/OpenTK/Platform/Windows/WinRawMouse.cs: * Source/OpenTK/Platform/Windows/WinRawInput.cs: Added new MouseDriver interface and added stub internal implementations.
147 lines
3.7 KiB
C#
147 lines
3.7 KiB
C#
#region --- License ---
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
* See license.txt for license info
|
|
*/
|
|
#endregion
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
using OpenTK.Input;
|
|
using OpenTK.Platform;
|
|
|
|
namespace OpenTK
|
|
{
|
|
internal class InputDriver : IInputDriver
|
|
{
|
|
private IInputDriver inputDriver;
|
|
|
|
#region --- Constructors ---
|
|
|
|
public InputDriver(GameWindow parent)
|
|
{
|
|
if (parent == null)
|
|
throw new ArgumentException("A valid window (IWindowInfo) must be specified to construct an InputDriver");
|
|
|
|
switch (Environment.OSVersion.Platform)
|
|
{
|
|
case PlatformID.Win32Windows:
|
|
case PlatformID.Win32NT:
|
|
case PlatformID.Win32S:
|
|
case PlatformID.WinCE:
|
|
if (Environment.OSVersion.Version.Major > 5 ||
|
|
(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
|
|
{
|
|
inputDriver = new OpenTK.Platform.Windows.WinRawInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
|
|
}
|
|
else
|
|
{
|
|
// Legacy or unknown windows version:
|
|
inputDriver = new OpenTK.Platform.Windows.WMInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
|
|
}
|
|
break;
|
|
|
|
case PlatformID.Unix:
|
|
// TODO: Input is currently handled asychronously by the driver in X11GLNative.
|
|
//inputDriver = new OpenTK.Platform.X11.X11Input(parent.WindowInfo);
|
|
|
|
break;
|
|
|
|
default:
|
|
throw new PlatformNotSupportedException(
|
|
"Input handling is not supported on the current platform. Please report the problem to http://opentk.sourceforge.net");
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- IInputDriver Members ---
|
|
|
|
public void Poll()
|
|
{
|
|
inputDriver.Poll();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- IKeyboardDriver Members ---
|
|
|
|
public IList<KeyboardDevice> Keyboard
|
|
{
|
|
get { return inputDriver.Keyboard; }
|
|
}
|
|
|
|
public KeyboardState GetState()
|
|
{
|
|
return (inputDriver as IKeyboardDriver).GetState();
|
|
}
|
|
|
|
public KeyboardState GetState(int index)
|
|
{
|
|
return (inputDriver as IKeyboardDriver).GetState(index);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- IMouseDriver Members ---
|
|
|
|
public IList<MouseDevice> Mouse
|
|
{
|
|
get { return inputDriver.Mouse; }
|
|
}
|
|
|
|
MouseState IMouseDriver.GetState()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
MouseState IMouseDriver.GetState(int index)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- IJoystickDriver Members ---
|
|
|
|
public IList<JoystickDevice> Joysticks
|
|
{
|
|
get { return inputDriver.Joysticks; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region --- IDisposable Members ---
|
|
|
|
private bool disposed;
|
|
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
private void Dispose(bool manual)
|
|
{
|
|
if (!disposed)
|
|
{
|
|
if (manual)
|
|
{
|
|
inputDriver.Dispose();
|
|
}
|
|
|
|
disposed = true;
|
|
}
|
|
}
|
|
|
|
~InputDriver()
|
|
{
|
|
this.Dispose(false);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|