1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 00:55:20 +02:00

Add Joystick type detection and Xbox controller support

* Add joystick type detection (with joystick_type setting to override it)
* Fix multiple joysticks from interfering with each other by only reading from one (add joystick_id setting)
* Add support for Xbox controllers
This commit is contained in:
rubenwardy
2017-04-02 23:00:34 +01:00
committed by Auke Kok
parent 351cc2e79a
commit bce0d458d8
8 changed files with 146 additions and 37 deletions

View File

@@ -98,6 +98,9 @@ class JoystickController {
public:
JoystickController();
void onJoystickConnect(const std::vector<irr::SJoystickInfo> &joystick_infos);
bool handleEvent(const irr::SEvent::SJoystickEvent &ev);
void clear();
@@ -146,10 +149,14 @@ public:
f32 doubling_dtime;
private:
const JoystickLayout *m_layout;
void setLayoutFromControllerName(std::string name);
JoystickLayout m_layout;
s16 m_axes_vals[JA_COUNT];
u8 m_joystick_id;
std::bitset<KeyType::INTERNAL_ENUM_COUNT> m_pressed_keys;
f32 m_internal_time;