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;
}
/// <returns>A System.String representing this DisplayResolution.</returns>
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
/// <returns>A System.Int32 that may serve as a hash code for this resolution.</returns>
public override int GetHashCode()
{
+ #pragma warning disable 612,618
return Bounds.GetHashCode() ^ bits_per_pixel ^ refresh_rate.GetHashCode();
+ #pragma warning restore 612,618
}
#endregion
/// <summary>
/// Gets the primary Keyboard device, or null if no Keyboard exists.
/// </summary>
+ [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; }
/// <summary>
/// Gets the primary Mouse device, or null if no Mouse exists.
/// </summary>
+ [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; }
[Obsolete]
public IJoystickDriver CreateLegacyJoystickDriver()
{
+ #pragma warning disable 612,618
return default_implementation.CreateLegacyJoystickDriver();
+ #pragma warning restore 612,618
}
class UnsupportedPlatform : PlatformFactoryBase
namespace OpenTK.Platform
{
+ [Obsolete]
internal class LegacyJoystickDriver : IJoystickDriver
{
static readonly string ConnectedName = "Connected Joystick";
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();
readonly List<JoystickDevice> joysticks = new List<JoystickDevice>(4);
readonly Dictionary<int, int> sdl_instanceid_to_joysticks = new Dictionary<int, int>();
- // For IJoystickDriver implementation
- IList<JoystickDevice> joysticks_readonly;
-
#if USE_SDL2_GAMECONTROLLER
class Sdl2GamePad
{
public Sdl2JoystickDriver()
{
- joysticks_readonly = joysticks.AsReadOnly();
}
#region Private Members
#endregion
- #region IJoystickDriver Members
-
- public IList<JoystickDevice> Joysticks
- {
- get
- {
- return joysticks_readonly;
- }
- }
-
- public void Poll()
- {
- // Do nothing
- }
-
- #endregion
-
#region IGamePadDriver Members
#if USE_SDL2_GAMECONTOLLER
if (manual)
{
Debug.Print("Disposing {0}", GetType());
- InputDriver.Dispose();
+
if (Exists)
{
DestroyWindow();
// 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)
namespace OpenTK.Platform.Windows
{
- sealed class WinMMJoystick : IJoystickDriver, IJoystickDriver2
+ sealed class WinMMJoystick : IJoystickDriver2
{
#region Fields
#endregion
- #region IJoystickDriver
-
- public int DeviceCount
- {
- get { return sticks.Count; }
- }
-
- public IList<JoystickDevice> Joysticks
- {
- get { return sticks_readonly; }
- }
-
- public void Poll()
- {
- lock (sync)
- {
- foreach (JoystickDevice<WinMMJoyDetails> 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)