Removed obsolete legacy input driver.

This commit is contained in:
Jarl Gullberg 2017-06-20 15:52:16 +02:00
parent 094e79a570
commit 92141295cd
No known key found for this signature in database
GPG key ID: 750FF6F6BDA72D23
6 changed files with 35 additions and 226 deletions

View file

@ -6,7 +6,7 @@
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to // in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do // the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions: // so, subject to the following conditions:
@ -91,7 +91,7 @@ namespace OpenTK
double update_period, render_period; double update_period, render_period;
double target_update_period, target_render_period; double target_update_period, target_render_period;
double update_time; // length of last UpdateFrame event double update_time; // length of last UpdateFrame event
double render_time; // length of last RenderFrame event double render_time; // length of last RenderFrame event
@ -462,7 +462,7 @@ namespace OpenTK
while (elapsed > 0 && elapsed + update_epsilon >= TargetUpdatePeriod) while (elapsed > 0 && elapsed + update_epsilon >= TargetUpdatePeriod)
{ {
RaiseUpdateFrame(elapsed, ref timestamp); RaiseUpdateFrame(elapsed, ref timestamp);
// Calculate difference (positive or negative) between // Calculate difference (positive or negative) between
// actual elapsed time and target elapsed time. We must // actual elapsed time and target elapsed time. We must
// compensate for this difference. // compensate for this difference.
@ -594,38 +594,6 @@ namespace OpenTK
#endregion #endregion
#region Keyboard
#pragma warning disable 0612
/// <summary>
/// Gets the primary Keyboard device, or null if no Keyboard exists.
/// </summary>
public KeyboardDevice Keyboard
{
get { return InputDriver.Keyboard.Count > 0 ? InputDriver.Keyboard[0] : null; }
}
#pragma warning restore 0612
#endregion
#region Mouse
#pragma warning disable 0612
/// <summary>
/// Gets the primary Mouse device, or null if no Mouse exists.
/// </summary>
public MouseDevice Mouse
{
get { return InputDriver.Mouse.Count > 0 ? InputDriver.Mouse[0] : null; }
}
#pragma warning restore 0612
#endregion
#region --- GameWindow Timing --- #region --- GameWindow Timing ---
// TODO: Disabled because it is not reliable enough. Use vsync as a workaround. // TODO: Disabled because it is not reliable enough. Use vsync as a workaround.

View file

@ -6,7 +6,7 @@
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to // in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do // the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions: // so, subject to the following conditions:
@ -37,7 +37,7 @@ using OpenTK.Platform;
namespace OpenTK namespace OpenTK
{ {
/// <summary> /// <summary>
/// Defines the interface for a native window. /// Defines the interface for a native window.
/// </summary> /// </summary>
public interface INativeWindow : IDisposable public interface INativeWindow : IDisposable
{ {
@ -50,32 +50,32 @@ namespace OpenTK
/// Gets or sets the title of the window. /// Gets or sets the title of the window.
/// </summary> /// </summary>
string Title { get; set; } string Title { get; set; }
/// <summary> /// <summary>
/// Gets a System.Boolean that indicates whether this window has input focus. /// Gets a System.Boolean that indicates whether this window has input focus.
/// </summary> /// </summary>
bool Focused { get; } bool Focused { get; }
/// <summary> /// <summary>
/// Gets or sets a System.Boolean that indicates whether the window is visible. /// Gets or sets a System.Boolean that indicates whether the window is visible.
/// </summary> /// </summary>
bool Visible { get; set; } bool Visible { get; set; }
/// <summary> /// <summary>
/// Gets a System.Boolean that indicates whether the window has been created and has not been destroyed. /// Gets a System.Boolean that indicates whether the window has been created and has not been destroyed.
/// </summary> /// </summary>
bool Exists { get; } bool Exists { get; }
/// <summary> /// <summary>
/// Gets the <see cref="OpenTK.Platform.IWindowInfo"/> for this window. /// Gets the <see cref="OpenTK.Platform.IWindowInfo"/> for this window.
/// </summary> /// </summary>
IWindowInfo WindowInfo { get; } IWindowInfo WindowInfo { get; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="OpenTK.WindowState"/> for this window. /// Gets or sets the <see cref="OpenTK.WindowState"/> for this window.
/// </summary> /// </summary>
WindowState WindowState { get; set; } WindowState WindowState { get; set; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="OpenTK.WindowBorder"/> for this window. /// Gets or sets the <see cref="OpenTK.WindowBorder"/> for this window.
/// </summary> /// </summary>
@ -86,54 +86,48 @@ namespace OpenTK
/// External bounds include the title bar, borders and drawing area of the window. /// External bounds include the title bar, borders and drawing area of the window.
/// </summary> /// </summary>
Rectangle Bounds { get; set; } Rectangle Bounds { get; set; }
/// <summary> /// <summary>
/// Gets or sets a <see cref="System.Drawing.Point"/> structure that contains the location of this window on the desktop. /// Gets or sets a <see cref="System.Drawing.Point"/> structure that contains the location of this window on the desktop.
/// </summary> /// </summary>
Point Location { get; set; } Point Location { get; set; }
/// <summary> /// <summary>
/// Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the external size of this window. /// Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the external size of this window.
/// </summary> /// </summary>
Size Size { get; set; } Size Size { get; set; }
/// <summary> /// <summary>
/// Gets or sets the horizontal location of this window on the desktop. /// Gets or sets the horizontal location of this window on the desktop.
/// </summary> /// </summary>
int X { get; set; } int X { get; set; }
/// <summary> /// <summary>
/// Gets or sets the vertical location of this window on the desktop. /// Gets or sets the vertical location of this window on the desktop.
/// </summary> /// </summary>
int Y { get; set; } int Y { get; set; }
/// <summary> /// <summary>
/// Gets or sets the external width of this window. /// Gets or sets the external width of this window.
/// </summary> /// </summary>
int Width { get; set; } int Width { get; set; }
/// <summary> /// <summary>
/// Gets or sets the external height of this window. /// Gets or sets the external height of this window.
/// </summary> /// </summary>
int Height { get; set; } int Height { get; set; }
/// <summary> /// <summary>
/// Gets or sets a <see cref="System.Drawing.Rectangle"/> structure that contains the internal bounds of this window, in client coordinates. /// Gets or sets a <see cref="System.Drawing.Rectangle"/> structure that contains the internal bounds of this window, in client coordinates.
/// The internal bounds include the drawing area of the window, but exclude the titlebar and window borders. /// The internal bounds include the drawing area of the window, but exclude the titlebar and window borders.
/// </summary> /// </summary>
Rectangle ClientRectangle { get; set; } Rectangle ClientRectangle { get; set; }
/// <summary> /// <summary>
/// Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the internal size this window. /// Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the internal size this window.
/// </summary> /// </summary>
Size ClientSize { get; set; } Size ClientSize { get; set; }
/// <summary>
/// This property is deprecated and should not be used.
/// </summary>
[Obsolete("Use OpenTK.Input.Mouse/Keyboard/Joystick/GamePad instead.")]
OpenTK.Input.IInputDriver InputDriver { get; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="OpenTK.MouseCursor"/> for this window. /// Gets or sets the <see cref="OpenTK.MouseCursor"/> for this window.
/// </summary> /// </summary>
@ -154,14 +148,14 @@ namespace OpenTK
/// Closes this window. /// Closes this window.
/// </summary> /// </summary>
void Close(); void Close();
/// <summary> /// <summary>
/// Processes pending window events. /// Processes pending window events.
/// </summary> /// </summary>
void ProcessEvents(); void ProcessEvents();
/// <summary> /// <summary>
/// Transforms the specified point from screen to client coordinates. /// Transforms the specified point from screen to client coordinates.
/// </summary> /// </summary>
/// <param name="point"> /// <param name="point">
/// A <see cref="System.Drawing.Point"/> to transform. /// A <see cref="System.Drawing.Point"/> to transform.
@ -170,9 +164,9 @@ namespace OpenTK
/// The point transformed to client coordinates. /// The point transformed to client coordinates.
/// </returns> /// </returns>
Point PointToClient(Point point); Point PointToClient(Point point);
/// <summary> /// <summary>
/// Transforms the specified point from client to screen coordinates. /// Transforms the specified point from client to screen coordinates.
/// </summary> /// </summary>
/// <param name="point"> /// <param name="point">
/// A <see cref="System.Drawing.Point"/> to transform. /// A <see cref="System.Drawing.Point"/> to transform.
@ -183,32 +177,32 @@ namespace OpenTK
Point PointToScreen(Point point); Point PointToScreen(Point point);
/// <summary> /// <summary>
/// Occurs whenever the window is moved. /// Occurs whenever the window is moved.
/// </summary> /// </summary>
event EventHandler<EventArgs> Move; event EventHandler<EventArgs> Move;
/// <summary> /// <summary>
/// Occurs whenever the window is resized. /// Occurs whenever the window is resized.
/// </summary> /// </summary>
event EventHandler<EventArgs> Resize; event EventHandler<EventArgs> Resize;
/// <summary> /// <summary>
/// Occurs when the window is about to close. /// Occurs when the window is about to close.
/// </summary> /// </summary>
event EventHandler<CancelEventArgs> Closing; event EventHandler<CancelEventArgs> Closing;
/// <summary> /// <summary>
/// Occurs after the window has closed. /// Occurs after the window has closed.
/// </summary> /// </summary>
event EventHandler<EventArgs> Closed; event EventHandler<EventArgs> Closed;
/// <summary> /// <summary>
/// Occurs when the window is disposed. /// Occurs when the window is disposed.
/// </summary> /// </summary>
event EventHandler<EventArgs> Disposed; event EventHandler<EventArgs> Disposed;
/// <summary> /// <summary>
/// Occurs when the <see cref="Icon"/> property of the window changes. /// Occurs when the <see cref="Icon"/> property of the window changes.
/// </summary> /// </summary>
event EventHandler<EventArgs> IconChanged; event EventHandler<EventArgs> IconChanged;
@ -246,7 +240,7 @@ namespace OpenTK
/// Occurs whenever a character is typed. /// Occurs whenever a character is typed.
/// </summary> /// </summary>
event EventHandler<KeyPressEventArgs> KeyPress; event EventHandler<KeyPressEventArgs> KeyPress;
/// <summary> /// <summary>
/// Occurs whenever a keyboard key is released. /// Occurs whenever a keyboard key is released.
/// </summary> /// </summary>

View file

@ -6,7 +6,7 @@
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to // in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do // the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions: // so, subject to the following conditions:
@ -149,7 +149,7 @@ namespace OpenTK
#region PointToClient #region PointToClient
/// <summary> /// <summary>
/// Transforms the specified point from screen to client coordinates. /// Transforms the specified point from screen to client coordinates.
/// </summary> /// </summary>
/// <param name="point"> /// <param name="point">
/// A <see cref="System.Drawing.Point"/> to transform. /// A <see cref="System.Drawing.Point"/> to transform.
@ -367,23 +367,6 @@ namespace OpenTK
#endregion #endregion
#region InputDriver
/// <summary>
/// This property is deprecated.
/// </summary>
[Obsolete]
public IInputDriver InputDriver
{
get
{
EnsureUndisposed();
return implementation.InputDriver;
}
}
#endregion
#region Location #region Location
/// <summary> /// <summary>
@ -630,7 +613,7 @@ namespace OpenTK
public event EventHandler<EventArgs> FocusedChanged = delegate { }; public event EventHandler<EventArgs> FocusedChanged = delegate { };
/// <summary> /// <summary>
/// Occurs when the <see cref="Icon"/> property of the window changes. /// Occurs when the <see cref="Icon"/> property of the window changes.
/// </summary> /// </summary>
public event EventHandler<EventArgs> IconChanged = delegate { }; public event EventHandler<EventArgs> IconChanged = delegate { };
@ -658,7 +641,7 @@ namespace OpenTK
/// Occurs whenever the mouse cursor enters the window <see cref="Bounds"/>. /// Occurs whenever the mouse cursor enters the window <see cref="Bounds"/>.
/// </summary> /// </summary>
public event EventHandler<EventArgs> MouseEnter = delegate { }; public event EventHandler<EventArgs> MouseEnter = delegate { };
/// <summary> /// <summary>
/// Occurs whenever the mouse cursor leaves the window <see cref="Bounds"/>. /// Occurs whenever the mouse cursor leaves the window <see cref="Bounds"/>.
/// </summary> /// </summary>

View file

@ -736,7 +736,6 @@
<Compile Include="Platform\MacOS\Cocoa\NSOpenGLPixelFormatAttribute.cs" /> <Compile Include="Platform\MacOS\Cocoa\NSOpenGLPixelFormatAttribute.cs" />
<Compile Include="Platform\MacOS\Cocoa\NSOpenGLProfile.cs" /> <Compile Include="Platform\MacOS\Cocoa\NSOpenGLProfile.cs" />
<Compile Include="Platform\MacOS\Cocoa\NSOpenGLContextParameter.cs" /> <Compile Include="Platform\MacOS\Cocoa\NSOpenGLContextParameter.cs" />
<Compile Include="Platform\LegacyInputDriver.cs" />
<Compile Include="Platform\MacOS\Cocoa\NSEventType.cs" /> <Compile Include="Platform\MacOS\Cocoa\NSEventType.cs" />
<Compile Include="Platform\MacOS\Cocoa\NSEventModifierMask.cs" /> <Compile Include="Platform\MacOS\Cocoa\NSEventModifierMask.cs" />
<Compile Include="Platform\MacOS\Cocoa\NSTrackingAreaOptions.cs" /> <Compile Include="Platform\MacOS\Cocoa\NSTrackingAreaOptions.cs" />

View file

@ -1,119 +0,0 @@
#region License
//
// LegacyInputDriver.cs
//
// Author:
// Stefanos A. <stapostol@gmail.com>
//
// Copyright (c) 2006-2014 Stefanos Apostolopoulos
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#endregion
using System;
using System.Collections.Generic;
using OpenTK.Input;
namespace OpenTK.Platform
{
// IInputDriver implementation to satisfy INativeWindow
// while reducing code duplication.
[Obsolete]
class LegacyInputDriver : IInputDriver
{
List<KeyboardDevice> dummy_keyboard_list = new List<KeyboardDevice>(1);
List<MouseDevice> dummy_mice_list = new List<MouseDevice>(1);
readonly LegacyJoystickDriver JoystickDriver = new LegacyJoystickDriver();
internal LegacyInputDriver(INativeWindow window)
{
if (window == null)
throw new ArgumentNullException();
var mouse = new MouseDevice();
mouse.Description = "Standard Mouse";
mouse.NumberOfButtons = 3;
mouse.NumberOfWheels = 1;
dummy_mice_list.Add(mouse);
var keyboard = new KeyboardDevice();
keyboard.Description = "Standard Keyboard";
keyboard.NumberOfKeys = 101;
keyboard.NumberOfLeds = 3;
keyboard.NumberOfFunctionKeys = 12;
dummy_keyboard_list.Add(keyboard);
// Hook mouse events
window.MouseDown += mouse.HandleMouseDown;
window.MouseUp += mouse.HandleMouseUp;
window.MouseMove += mouse.HandleMouseMove;
window.MouseWheel += mouse.HandleMouseWheel;
// Hook keyboard events
window.KeyDown += keyboard.HandleKeyDown;
window.KeyUp += keyboard.HandleKeyUp;
}
#region IInputDriver Members
public void Poll()
{
}
#endregion
#region IKeyboardDriver Members
public IList<KeyboardDevice> Keyboard
{
get { return dummy_keyboard_list; }
}
#endregion
#region IMouseDriver Members
public IList<MouseDevice> Mouse
{
get { return dummy_mice_list; }
}
#endregion
#region IJoystickDriver Members
public IList<JoystickDevice> Joysticks
{
get { return JoystickDriver.Joysticks; }
}
#endregion
#region IDisposable Members
public void Dispose()
{
}
#endregion
}
}

View file

@ -40,10 +40,6 @@ namespace OpenTK.Platform
// Common base class for all INativeWindow implementations // Common base class for all INativeWindow implementations
abstract class NativeWindowBase : INativeWindow abstract class NativeWindowBase : INativeWindow
{ {
#pragma warning disable 612,618
readonly LegacyInputDriver LegacyInputDriver;
#pragma warning restore 612,618
readonly MouseButtonEventArgs MouseDownArgs = new MouseButtonEventArgs(); readonly MouseButtonEventArgs MouseDownArgs = new MouseButtonEventArgs();
readonly MouseButtonEventArgs MouseUpArgs = new MouseButtonEventArgs(); readonly MouseButtonEventArgs MouseUpArgs = new MouseButtonEventArgs();
readonly MouseMoveEventArgs MouseMoveArgs = new MouseMoveEventArgs(); readonly MouseMoveEventArgs MouseMoveArgs = new MouseMoveEventArgs();
@ -62,9 +58,6 @@ namespace OpenTK.Platform
internal NativeWindowBase() internal NativeWindowBase()
{ {
#pragma warning disable 612,618
LegacyInputDriver = new LegacyInputDriver(this);
#pragma warning restore 612,618
MouseState.SetIsConnected(true); MouseState.SetIsConnected(true);
KeyboardState.SetIsConnected(true); KeyboardState.SetIsConnected(true);
PreviousMouseState.SetIsConnected(true); PreviousMouseState.SetIsConnected(true);
@ -448,15 +441,6 @@ namespace OpenTK.Platform
public abstract Size ClientSize { get; set; } public abstract Size ClientSize { get; set; }
[Obsolete]
public virtual IInputDriver InputDriver
{
get
{
return LegacyInputDriver;
}
}
public abstract bool CursorVisible { get; set; } public abstract bool CursorVisible { get; set; }
public abstract MouseCursor Cursor { get; set; } public abstract MouseCursor Cursor { get; set; }