Xbox360 controller support

This commit is contained in:
2014-05-13 00:55:32 +02:00
parent 38482431a1
commit d259811795
16 changed files with 552 additions and 163 deletions
+17 -1
View File
@@ -11,8 +11,12 @@
#include "Events/KeyDown.h"
#include "Events/MousePress.h"
#include "Events/MouseRelease.h"
#include "Events/GamepadAxis.h"
#include "Events/GamepadButton.h"
#include "Events/BindKey.h"
#include "Events/BindMouseButton.h"
#include "Events/BindGamepadAxis.h"
#include "Events/BindGamepadButton.h"
#include "Events/InputCommand.h"
namespace Systems
@@ -30,10 +34,12 @@ public:
void Update(double dt) override;
private:
std::unordered_map<std::string, float> m_CommandValues; // command string -> command current value
// Input binding tables
std::unordered_map<int, std::tuple<std::string, float>> m_KeyBindings; // GLFW_KEY... -> command string & value
std::unordered_map<std::string, float> m_KeyBindingValues; // command string -> command value
std::unordered_map<int, std::string> m_MouseButtonBindings; // GLFW_MOUSE_BUTTON... -> command string
std::unordered_map<Gamepad::Axis, std::tuple<std::string, float>> m_GamepadAxisBindings; // Gamepad::Axis -> command string & value
std::unordered_map<Gamepad::Button, std::tuple<std::string, float>> m_GamepadButtonBindings; // Gamepad::Button -> command string
// Input events
EventRelay<Events::KeyDown> m_EKeyDown;
@@ -44,11 +50,21 @@ private:
bool OnMousePress(const Events::MousePress &event);
EventRelay<Events::MouseRelease> m_EMouseRelease;
bool OnMouseRelease(const Events::MouseRelease &event);
EventRelay<Events::GamepadAxis> m_EGamepadAxis;
bool OnGamepadAxis(const Events::GamepadAxis &event);
EventRelay<Events::GamepadButtonDown> m_EGamepadButtonDown;
bool OnGamepadButtonDown(const Events::GamepadButtonDown &event);
EventRelay<Events::GamepadButtonUp> m_EGamepadButtonUp;
bool OnGamepadButtonUp(const Events::GamepadButtonUp &event);
// Input binding events
EventRelay<Events::BindKey> m_EBindKey;
bool OnBindKey(const Events::BindKey &event);
EventRelay<Events::BindMouseButton> m_EBindMouseButton;
bool OnBindMouseButton(const Events::BindMouseButton &event);
EventRelay<Events::BindGamepadAxis> m_EBindGamepadAxis;
bool OnBindGamepadAxis(const Events::BindGamepadAxis &event);
EventRelay<Events::BindGamepadButton> m_EBindGamepadButton;
bool OnBindGamepadButton(const Events::BindGamepadButton &event);
void PublishCommand(int playerID, std::string command, float value);
};