00001 #region --- License ---
00002
00003
00004
00005 #endregion
00006
00007 using System;
00008 using System.Collections.Generic;
00009 using System.Text;
00010
00011 using OpenTK.Input;
00012 using OpenTK.Platform;
00013
00014 namespace OpenTK
00015 {
00016 internal class InputDriver : IInputDriver
00017 {
00018 private IInputDriver inputDriver;
00019
00020 #region --- Constructors ---
00021
00022 public InputDriver(GameWindow parent)
00023 {
00024 if (parent == null)
00025 throw new ArgumentException("A valid window (IWindowInfo) must be specified to construct an InputDriver");
00026
00027 switch (Environment.OSVersion.Platform)
00028 {
00029 case PlatformID.Win32Windows:
00030 case PlatformID.Win32NT:
00031 case PlatformID.Win32S:
00032 case PlatformID.WinCE:
00033 if (Environment.OSVersion.Version.Major > 5 ||
00034 (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
00035 {
00036 inputDriver = new OpenTK.Platform.Windows.WinRawInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
00037 }
00038 else
00039 {
00040
00041 inputDriver = new OpenTK.Platform.Windows.WMInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
00042 }
00043 break;
00044
00045 case PlatformID.Unix:
00046
00047
00048
00049 break;
00050
00051 default:
00052 throw new PlatformNotSupportedException(
00053 "Input handling is not supported on the current platform. Please report the problem to http://opentk.sourceforge.net");
00054
00055 }
00056 }
00057
00058 #endregion
00059
00060 #region --- IInputDriver Members ---
00061
00062 public void Poll()
00063 {
00064 inputDriver.Poll();
00065 }
00066
00067 #endregion
00068
00069 #region --- IKeyboardDriver Members ---
00070
00071 public IList<KeyboardDevice> Keyboard
00072 {
00073 get { return inputDriver.Keyboard; }
00074 }
00075
00076 #endregion
00077
00078 #region --- IMouseDriver Members ---
00079
00080 public IList<MouseDevice> Mouse
00081 {
00082 get { return inputDriver.Mouse; }
00083 }
00084
00085 #endregion
00086
00087 #region --- IJoystickDriver Members ---
00088
00089 public IList<JoystickDevice> Joysticks
00090 {
00091 get { return inputDriver.Joysticks; }
00092 }
00093
00094 #endregion
00095
00096 #region --- IDisposable Members ---
00097
00098 private bool disposed;
00099
00100 public void Dispose()
00101 {
00102 this.Dispose(true);
00103 GC.SuppressFinalize(this);
00104 }
00105
00106 private void Dispose(bool manual)
00107 {
00108 if (!disposed)
00109 {
00110 if (manual)
00111 {
00112 inputDriver.Dispose();
00113 }
00114
00115 disposed = true;
00116 }
00117 }
00118
00119 ~InputDriver()
00120 {
00121 this.Dispose(false);
00122 }
00123
00124 #endregion
00125 }
00126 }