From: thefiddler Date: Mon, 21 Jul 2014 14:49:24 +0000 (+0200) Subject: Cleaned up the remaining obsolete warnings X-Git-Tag: 2.0-0~107^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0a3b73130dc0bd5ce03aa5e536dd1558569ea26;p=platform%2Fcore%2Fcsapi%2Fopentk.git Cleaned up the remaining obsolete warnings --- diff --git a/Source/OpenTK/DisplayDevice.cs b/Source/OpenTK/DisplayDevice.cs index 0078947..bfd3960 100644 --- a/Source/OpenTK/DisplayDevice.cs +++ b/Source/OpenTK/DisplayDevice.cs @@ -78,11 +78,13 @@ namespace OpenTK object id) : this() { -#warning "Consolidate current resolution with bounds? Can they fall out of sync right now?" + // Todo: Consolidate current resolution with bounds? Can they fall out of sync right now? this.current_resolution = currentResolution; IsPrimary = primary; this.available_resolutions.AddRange(availableResolutions); + #pragma warning disable 612,618 this.bounds = bounds == Rectangle.Empty ? currentResolution.Bounds : bounds; + #pragma warning restore 612,618 this.Id = id; } diff --git a/Source/OpenTK/DisplayResolution.cs b/Source/OpenTK/DisplayResolution.cs index 02fd04f..4341940 100644 --- a/Source/OpenTK/DisplayResolution.cs +++ b/Source/OpenTK/DisplayResolution.cs @@ -153,7 +153,9 @@ namespace OpenTK /// A System.String representing this DisplayResolution. public override string ToString() { + #pragma warning disable 612,618 return String.Format("{0}x{1}@{2}Hz", Bounds, bits_per_pixel, refresh_rate); + #pragma warning restore 612,618 } #endregion @@ -187,7 +189,9 @@ namespace OpenTK /// A System.Int32 that may serve as a hash code for this resolution. public override int GetHashCode() { + #pragma warning disable 612,618 return Bounds.GetHashCode() ^ bits_per_pixel ^ refresh_rate.GetHashCode(); + #pragma warning restore 612,618 } #endregion diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index f9a1562..cfab224 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -599,6 +599,7 @@ namespace OpenTK /// /// Gets the primary Keyboard device, or null if no Keyboard exists. /// + [Obsolete("Use KeyDown, KeyUp and KeyPress events or OpenTK.Input.Keyboard instead.")] public KeyboardDevice Keyboard { get { return InputDriver.Keyboard.Count > 0 ? InputDriver.Keyboard[0] : null; } @@ -611,6 +612,7 @@ namespace OpenTK /// /// Gets the primary Mouse device, or null if no Mouse exists. /// + [Obsolete("Use MouseMove, MouseDown, MouseUp and MouseWheel events or OpenTK.Input.Mouse, instead.")] public MouseDevice Mouse { get { return InputDriver.Mouse.Count > 0 ? InputDriver.Mouse[0] : null; } diff --git a/Source/OpenTK/Platform/Factory.cs b/Source/OpenTK/Platform/Factory.cs index 031dcf8..a195429 100644 --- a/Source/OpenTK/Platform/Factory.cs +++ b/Source/OpenTK/Platform/Factory.cs @@ -155,7 +155,9 @@ namespace OpenTK.Platform [Obsolete] public IJoystickDriver CreateLegacyJoystickDriver() { + #pragma warning disable 612,618 return default_implementation.CreateLegacyJoystickDriver(); + #pragma warning restore 612,618 } class UnsupportedPlatform : PlatformFactoryBase diff --git a/Source/OpenTK/Platform/LegacyJoystickDriver.cs b/Source/OpenTK/Platform/LegacyJoystickDriver.cs index b58c21f..202b998 100644 --- a/Source/OpenTK/Platform/LegacyJoystickDriver.cs +++ b/Source/OpenTK/Platform/LegacyJoystickDriver.cs @@ -33,6 +33,7 @@ using OpenTK.Input; namespace OpenTK.Platform { + [Obsolete] internal class LegacyJoystickDriver : IJoystickDriver { static readonly string ConnectedName = "Connected Joystick"; diff --git a/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs b/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs index 71ab3ee..41726c6 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs @@ -32,7 +32,7 @@ using OpenTK.Input; namespace OpenTK.Platform.SDL2 { - class Sdl2JoystickDriver : IJoystickDriver, IJoystickDriver2, IGamePadDriver, IDisposable + class Sdl2JoystickDriver : IJoystickDriver2, IGamePadDriver, IDisposable { const float RangeMultiplier = 1.0f / 32768.0f; readonly MappedGamePadDriver gamepad_driver = new MappedGamePadDriver(); @@ -55,9 +55,6 @@ namespace OpenTK.Platform.SDL2 readonly List joysticks = new List(4); readonly Dictionary sdl_instanceid_to_joysticks = new Dictionary(); - // For IJoystickDriver implementation - IList joysticks_readonly; - #if USE_SDL2_GAMECONTROLLER class Sdl2GamePad { @@ -78,7 +75,6 @@ namespace OpenTK.Platform.SDL2 public Sdl2JoystickDriver() { - joysticks_readonly = joysticks.AsReadOnly(); } #region Private Members @@ -548,23 +544,6 @@ namespace OpenTK.Platform.SDL2 #endregion - #region IJoystickDriver Members - - public IList Joysticks - { - get - { - return joysticks_readonly; - } - } - - public void Poll() - { - // Do nothing - } - - #endregion - #region IGamePadDriver Members #if USE_SDL2_GAMECONTOLLER diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index 0e576e9..a49dea1 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -943,7 +943,7 @@ namespace OpenTK.Platform.SDL2 if (manual) { Debug.Print("Disposing {0}", GetType()); - InputDriver.Dispose(); + if (Exists) { DestroyWindow(); diff --git a/Source/OpenTK/Platform/Windows/WinDisplayDevice.cs b/Source/OpenTK/Platform/Windows/WinDisplayDevice.cs index fc594b6..8ea67e0 100644 --- a/Source/OpenTK/Platform/Windows/WinDisplayDevice.cs +++ b/Source/OpenTK/Platform/Windows/WinDisplayDevice.cs @@ -156,12 +156,14 @@ namespace OpenTK.Platform.Windows // Construct the OpenTK DisplayDevice through the accumulated parameters. // The constructor will automatically add the DisplayDevice to the list // of available devices. + #pragma warning disable 612,618 opentk_dev = new DisplayDevice( opentk_dev_current_res, opentk_dev_primary, opentk_dev_available_res, opentk_dev_current_res.Bounds, dev1.DeviceName); + #pragma warning restore 612,618 // Set the original resolution if the DisplayDevice was previously available. foreach (DisplayDevice existingDevice in previousDevices) diff --git a/Source/OpenTK/Platform/Windows/WinMMJoystick.cs b/Source/OpenTK/Platform/Windows/WinMMJoystick.cs index adcdf1d..b8bd79a 100644 --- a/Source/OpenTK/Platform/Windows/WinMMJoystick.cs +++ b/Source/OpenTK/Platform/Windows/WinMMJoystick.cs @@ -36,7 +36,7 @@ using OpenTK.Input; namespace OpenTK.Platform.Windows { - sealed class WinMMJoystick : IJoystickDriver, IJoystickDriver2 + sealed class WinMMJoystick : IJoystickDriver2 { #region Fields @@ -228,111 +228,6 @@ namespace OpenTK.Platform.Windows #endregion - #region IJoystickDriver - - public int DeviceCount - { - get { return sticks.Count; } - } - - public IList Joysticks - { - get { return sticks_readonly; } - } - - public void Poll() - { - lock (sync) - { - foreach (JoystickDevice js in sticks) - { - JoyInfoEx info = new JoyInfoEx(); - info.Size = JoyInfoEx.SizeInBytes; - info.Flags = JoystickFlags.All; - UnsafeNativeMethods.joyGetPosEx(js.Id, ref info); - - int num_axes = js.Axis.Count; - if ((js.Details.PovType & PovType.Exists) != 0) - num_axes -= 2; // Because the last two axis are used for POV input. - - int axis = 0; - if (axis < num_axes) - { js.SetAxis((JoystickAxis)axis, js.Details.CalculateOffset((float)info.XPos, axis)); axis++; } - if (axis < num_axes) - { js.SetAxis((JoystickAxis)axis, js.Details.CalculateOffset((float)info.YPos, axis)); axis++; } - if (axis < num_axes) - { js.SetAxis((JoystickAxis)axis, js.Details.CalculateOffset((float)info.ZPos, axis)); axis++; } - if (axis < num_axes) - { js.SetAxis((JoystickAxis)axis, js.Details.CalculateOffset((float)info.RPos, axis)); axis++; } - if (axis < num_axes) - { js.SetAxis((JoystickAxis)axis, js.Details.CalculateOffset((float)info.UPos, axis)); axis++; } - if (axis < num_axes) - { js.SetAxis((JoystickAxis)axis, js.Details.CalculateOffset((float)info.VPos, axis)); axis++; } - - if ((js.Details.PovType & PovType.Exists) != 0) - { - float x = 0, y = 0; - - // A discrete POV returns specific values for left, right, etc. - // A continuous POV returns an integer indicating an angle in degrees * 100, e.g. 18000 == 180.00 degrees. - // The vast majority of joysticks have discrete POVs, so we'll treat all of them as discrete for simplicity. - if ((JoystickPovPosition)info.Pov != JoystickPovPosition.Centered) - { - if (info.Pov > (int)JoystickPovPosition.Left || info.Pov < (int)JoystickPovPosition.Right) - { y = 1; } - if ((info.Pov > (int)JoystickPovPosition.Forward) && (info.Pov < (int)JoystickPovPosition.Backward)) - { x = 1; } - if ((info.Pov > (int)JoystickPovPosition.Right) && (info.Pov < (int)JoystickPovPosition.Left)) - { y = -1; } - if (info.Pov > (int)JoystickPovPosition.Backward) - { x = -1; } - } - //if ((js.Details.PovType & PovType.Discrete) != 0) - //{ - // if ((JoystickPovPosition)info.Pov == JoystickPovPosition.Centered) - // { x = 0; y = 0; } - // else if ((JoystickPovPosition)info.Pov == JoystickPovPosition.Forward) - // { x = 0; y = -1; } - // else if ((JoystickPovPosition)info.Pov == JoystickPovPosition.Left) - // { x = -1; y = 0; } - // else if ((JoystickPovPosition)info.Pov == JoystickPovPosition.Backward) - // { x = 0; y = 1; } - // else if ((JoystickPovPosition)info.Pov == JoystickPovPosition.Right) - // { x = 1; y = 0; } - //} - //else if ((js.Details.PovType & PovType.Continuous) != 0) - //{ - // if ((JoystickPovPosition)info.Pov == JoystickPovPosition.Centered) - // { - // // This approach moves the hat on a circle, not a square as it should. - // float angle = (float)(System.Math.PI * info.Pov / 18000.0 + System.Math.PI / 2); - // x = (float)System.Math.Cos(angle); - // y = (float)System.Math.Sin(angle); - // if (x < 0.001) - // x = 0; - // if (y < 0.001) - // y = 0; - // } - //} - //else - // throw new NotImplementedException("Please post an issue report at http://www.opentk.com/issues"); - - js.SetAxis((JoystickAxis)axis++, x); - js.SetAxis((JoystickAxis)axis++, y); - } - - int button = 0; - while (button < js.Button.Count) - { - js.SetButton((JoystickButton)button, (info.Buttons & (1 << button)) != 0); - button++; - } - } - } - } - - #endregion - #region IJoystickDriver2 Members public JoystickCapabilities GetCapabilities(int player_index)