From 085ae52ce4a471d8351799a0b3bef305dbe6edf6 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 19 Oct 2007 20:01:41 +0000 Subject: [PATCH] InputDriver now checks for pre-XP windows versions, and instantiates the WMInput driver. --- Source/OpenTK/InputDriver.cs | 40 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/Source/OpenTK/InputDriver.cs b/Source/OpenTK/InputDriver.cs index f4715fa4..89a319e4 100644 --- a/Source/OpenTK/InputDriver.cs +++ b/Source/OpenTK/InputDriver.cs @@ -24,22 +24,32 @@ namespace OpenTK if (parent == null) throw new ArgumentException("A valid window (IWindowInfo) must be specified to construct an InputDriver"); - if (Environment.OSVersion.Version.Major > 5 || - (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1)) + switch (Environment.OSVersion.Platform) { - inputDriver = new OpenTK.Platform.Windows.WinRawInput(parent.WindowInfo); - } - else if (Environment.OSVersion.Platform == PlatformID.Unix) - { - //inputDriver = new OpenTK.Platform.X11.X11Input( - // parent is OpenTK.Platform.X11.WindowInfo ? (OpenTK.Platform.X11.WindowInfo)parent : - // parent is OpenTK.Platform.WindowInfo ? (OpenTK.Platform.X11.WindowInfo)(parent as OpenTK.Platform.WindowInfo) : null); - inputDriver = new OpenTK.Platform.X11.X11Input(parent.WindowInfo); - } - else - { - throw new PlatformNotSupportedException( - "Input handling is not supported on the current platform. Please report the problem to http://opentk.sourceforge.net"); + 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(parent.WindowInfo); + } + else + { + // Legacy or unknown windows version: + inputDriver = new OpenTK.Platform.Windows.WMInput(parent.WindowInfo); + } + break; + + case PlatformID.Unix: + 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"); + } }