diff options
| author | Matthew Parlane <parlane@gmail.com> | 2013-01-01 23:28:46 +1300 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2013-01-01 23:28:46 +1300 |
| commit | e0c9a1fd09b9be953bf0ae41b9014485e750b07e (patch) | |
| tree | 059744e17a2a35ca58dd9b817cab620faee38611 /Source/Core/InputCommon | |
| parent | fe1fdc5e7b957312c906324134e42ca3484fa2d5 (diff) | |
| parent | c728ef2cd30ef803210d5db0a1ecab6b198a2c65 (diff) | |
Merge branch 'master' into wii-network
Conflicts:
Source/Core/Common/Src/CommonPaths.h
Source/Core/Core/CMakeLists.txt
Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp
Diffstat (limited to 'Source/Core/InputCommon')
3 files changed, 131 insertions, 3 deletions
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: diff --git a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp index 450080bfd2..c2030a059d 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp @@ -1,5 +1,7 @@ #include "Xlib.h" +#include <X11/XKBlib.h> + namespace ciface { namespace Xlib @@ -93,7 +95,7 @@ KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* key KeySym keysym = 0; do { - keysym = XKeycodeToKeysym(m_display, keycode, i); + keysym = XkbKeycodeToKeysym(m_display, keycode, i, 0); i++; } while (keysym == NoSymbol && i < 8); |
