From 8649e4a044f16e52465dccf200b353b209a6f781 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Thu, 2 Jan 2014 19:52:00 +0100 Subject: [PATCH] [Input] Added SetVibration() API skeleton --- Source/OpenTK/Input/GamePad.cs | 17 +++++++++++++++++ Source/OpenTK/Input/IGamePadDriver.cs | 2 ++ Source/OpenTK/Platform/MappedGamePadDriver.cs | 5 +++++ .../OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs | 5 +++++ .../OpenTK/Platform/Windows/XInputJoystick.cs | 7 ++++++- Source/OpenTK/Platform/X11/X11Joystick.cs | 17 +++++++++++------ 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Source/OpenTK/Input/GamePad.cs b/Source/OpenTK/Input/GamePad.cs index 8f8468d1..50df2667 100644 --- a/Source/OpenTK/Input/GamePad.cs +++ b/Source/OpenTK/Input/GamePad.cs @@ -65,5 +65,22 @@ namespace OpenTK.Input { return driver.GetState(index); } + + /// + /// Sets the vibration intensity for the left and right motors of this + /// + /// + /// true, if vibration was set, false otherwise. This method can return false + /// if the GamePad hardware does not support vibration or if it cannot respond to + /// the command for any reason. Do not loop until this becomes true, but rather ignore + /// a return value of false. + /// + /// A zero-based device index for the GamePad device to affect + /// The vibration intensity for the left motor, between 0.0 and 1.0. + /// The vibration intensity for the right motor, between 0.0 and 1.0. + public static bool SetVibration(int index, float left, float right) + { + return driver.SetVibration(index, left, right); + } } } diff --git a/Source/OpenTK/Input/IGamePadDriver.cs b/Source/OpenTK/Input/IGamePadDriver.cs index fc24c8f8..6852dedf 100644 --- a/Source/OpenTK/Input/IGamePadDriver.cs +++ b/Source/OpenTK/Input/IGamePadDriver.cs @@ -19,5 +19,7 @@ namespace OpenTK.Input /// /// If no device exists at the specified index, the return value is . string GetName(int index); + + bool SetVibration(int index, float left, float right); } } diff --git a/Source/OpenTK/Platform/MappedGamePadDriver.cs b/Source/OpenTK/Platform/MappedGamePadDriver.cs index 20da30a8..12f918c9 100644 --- a/Source/OpenTK/Platform/MappedGamePadDriver.cs +++ b/Source/OpenTK/Platform/MappedGamePadDriver.cs @@ -168,6 +168,11 @@ namespace OpenTK.Platform return name; } + public bool SetVibration(int index, float left, float right) + { + return false; + } + #region Private Members GamePadConfiguration GetConfiguration(Guid guid) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs b/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs index faff9226..8a08151a 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2JoystickDriver.cs @@ -567,6 +567,11 @@ namespace OpenTK.Platform.SDL2 { return gamepad_driver.GetName(index); } + + public bool SetVibration(int index, float left, float right) + { + return false; + } #endif #endregion diff --git a/Source/OpenTK/Platform/Windows/XInputJoystick.cs b/Source/OpenTK/Platform/Windows/XInputJoystick.cs index 23710df0..910a7f01 100644 --- a/Source/OpenTK/Platform/Windows/XInputJoystick.cs +++ b/Source/OpenTK/Platform/Windows/XInputJoystick.cs @@ -87,7 +87,12 @@ namespace OpenTK.Platform.Windows public string GetName(int index) { - throw new NotImplementedException(); + return String.Empty; + } + + public bool SetVibration(int index, float left, float right) + { + return false; } #endregion diff --git a/Source/OpenTK/Platform/X11/X11Joystick.cs b/Source/OpenTK/Platform/X11/X11Joystick.cs index 5f76dd54..cbab7099 100644 --- a/Source/OpenTK/Platform/X11/X11Joystick.cs +++ b/Source/OpenTK/Platform/X11/X11Joystick.cs @@ -263,17 +263,22 @@ namespace OpenTK.Platform.X11 public GamePadCapabilities GetCapabilities(int index) { - throw new NotImplementedException(); + return new GamePadCapabilities(); } public GamePadState GetState(int index) { - throw new NotImplementedException(); + return new GamePadState(); } public string GetName(int index) { - throw new NotImplementedException(); + return String.Empty; + } + + public bool SetVibration(int index, float left, float right) + { + return false; } #endregion @@ -282,17 +287,17 @@ namespace OpenTK.Platform.X11 JoystickState IJoystickDriver2.GetState(int index) { - throw new NotImplementedException(); + return new JoystickState(); } JoystickCapabilities IJoystickDriver2.GetCapabilities(int index) { - throw new NotImplementedException(); + return new JoystickCapabilities(); } Guid IJoystickDriver2.GetGuid(int index) { - throw new NotImplementedException(); + return new Guid(); } #endregion