diff options
| author | Ryan Houdek <Sonicadvance1@Gmail.com> | 2012-10-27 17:22:48 -0500 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@Gmail.com> | 2012-10-27 17:22:48 -0500 |
| commit | c1fd640964272e68301b4f2c39e36b4f550785b6 (patch) | |
| tree | 321788bd412bd805ad1432925e6457b07b10927a /Source/Core/InputCommon/Src/ControllerInterface | |
| parent | 5a6a2b2bec29e71efd8dda61bf6fb5aad4a45020 (diff) | |
| parent | 7006cd12170c3b3dc3c6179a66945b5183995156 (diff) | |
Rebase immediate-removal on master
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface')
5 files changed, 135 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp index a995ae415a..82cfe2469e 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp @@ -18,7 +18,10 @@ #include "Thread.h" -#define INPUT_DETECT_THRESHOLD 0.85f +namespace +{ +const float INPUT_DETECT_THRESHOLD = 0.55f; +} ControllerInterface g_controller_interface; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp index e09bd2fdd9..c23e9df17e 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp @@ -51,9 +51,9 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device) if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph))) { - const int size = WideCharToMultiByte(CP_ACP, 0, str.wsz, -1, NULL, 0, NULL, NULL); + const int size = WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, NULL, 0, NULL, NULL); char* const data = new char[size]; - if (size == WideCharToMultiByte(CP_ACP, 0, str.wsz, -1, data, size, NULL, NULL)) + if (size == WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, data, size, NULL, NULL)) out.assign(data); delete[] data; } diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp index d37d1eb2ba..08d62bcfc1 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp @@ -241,7 +241,7 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI { // each hat gets 4 input instances associated with it, (up down left right) for (u8 d = 0; d != 4; ++d) - AddInput(new Hat(i, m_state_in.rgdwPOV[m_index], d)); + AddInput(new Hat(i, m_state_in.rgdwPOV[i], d)); } // get up to 6 axes and 2 sliders diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp index 429fe8cb78..c7c6898ecd 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp @@ -113,6 +113,27 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi m_state_out.push_back(EffectIDState()); AddOutput(new RampEffect(m_state_out.back())); } + + // sine effect + if (supported_effects & SDL_HAPTIC_SINE) + { + m_state_out.push_back(EffectIDState()); + AddOutput(new SineEffect(m_state_out.back())); + } + + // square effect + if (supported_effects & SDL_HAPTIC_SQUARE) + { + m_state_out.push_back(EffectIDState()); + AddOutput(new SquareEffect(m_state_out.back())); + } + + // triangle effect + if (supported_effects & SDL_HAPTIC_TRIANGLE) + { + m_state_out.push_back(EffectIDState()); + AddOutput(new TriangleEffect(m_state_out.back())); + } } #endif @@ -151,6 +172,21 @@ std::string Joystick::RampEffect::GetName() const return "Ramp"; } +std::string Joystick::SineEffect::GetName() const +{ + return "Sine"; +} + +std::string Joystick::SquareEffect::GetName() const +{ + return "Square"; +} + +std::string Joystick::TriangleEffect::GetName() const +{ + return "Triangle"; +} + void Joystick::ConstantEffect::SetState(const ControlState state) { if (state) @@ -176,12 +212,72 @@ void Joystick::RampEffect::SetState(const ControlState state) } else m_effect.effect.type = 0; - + const Sint16 old = m_effect.effect.ramp.start; m_effect.effect.ramp.start = state * 0x7FFF; if (old != m_effect.effect.ramp.start) m_effect.changed = true; } + +void Joystick::SineEffect::SetState(const ControlState state) +{ + if (state) + { + m_effect.effect.type = SDL_HAPTIC_SINE; + m_effect.effect.periodic.length = 250; + } + else { + m_effect.effect.type = 0; + } + + const Sint16 old = m_effect.effect.periodic.magnitude; + m_effect.effect.periodic.period = 5; + m_effect.effect.periodic.magnitude = state * 0x5000; + m_effect.effect.periodic.attack_length = 0; + m_effect.effect.periodic.fade_length = 500; + if (old != m_effect.effect.periodic.magnitude) + m_effect.changed = true; +} + +void Joystick::SquareEffect::SetState(const ControlState state) +{ + if (state) + { + m_effect.effect.type = SDL_HAPTIC_SQUARE; + m_effect.effect.periodic.length = 250; + } + else { + m_effect.effect.type = 0; + } + + const Sint16 old = m_effect.effect.periodic.magnitude; + m_effect.effect.periodic.period = 5; + m_effect.effect.periodic.magnitude = state * 0x5000; + m_effect.effect.periodic.attack_length = 0; + m_effect.effect.periodic.fade_length = 100; + if (old != m_effect.effect.periodic.magnitude) + m_effect.changed = true; +} + +void Joystick::TriangleEffect::SetState(const ControlState state) +{ + if (state) + { + m_effect.effect.type = SDL_HAPTIC_TRIANGLE; + m_effect.effect.periodic.length = 250; + } + else { + m_effect.effect.type = 0; + } + + const Sint16 old = m_effect.effect.periodic.magnitude; + m_effect.effect.periodic.period = 5; + m_effect.effect.periodic.magnitude = state * 0x5000; + m_effect.effect.periodic.attack_length = 0; + m_effect.effect.periodic.fade_length = 100; + if (old != m_effect.effect.periodic.magnitude) + m_effect.changed = true; +} #endif bool Joystick::UpdateInput() diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h index 5edc171dc4..139e9f232d 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h @@ -16,12 +16,12 @@ #endif #ifdef USE_SDL_HAPTIC - #define SDL_INIT_FLAGS SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC #ifdef _WIN32 #include <SDL_haptic.h> #else #include <SDL/SDL_haptic.h> #endif + #define SDL_INIT_FLAGS SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC #else #define SDL_INIT_FLAGS SDL_INIT_JOYSTICK #endif @@ -103,6 +103,36 @@ private: private: EffectIDState& m_effect; }; + + class SineEffect : public Output + { + public: + std::string GetName() const; + SineEffect(EffectIDState& effect) : m_effect(effect) {} + void SetState(const ControlState state); + private: + EffectIDState& m_effect; + }; + + class SquareEffect : public Output + { + public: + std::string GetName() const; + SquareEffect(EffectIDState& effect) : m_effect(effect) {} + void SetState(const ControlState state); + private: + EffectIDState& m_effect; + }; + + class TriangleEffect : public Output + { + public: + std::string GetName() const; + TriangleEffect(EffectIDState& effect) : m_effect(effect) {} + void SetState(const ControlState state); + private: + EffectIDState& m_effect; + }; #endif public: |
