From 2060fd9cbe587d7e8ffe0cecdd67925f13a56c05 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 27 May 2016 08:35:07 +0200 Subject: Initial Gamepad support Adds initial ingame gamepad support to minetest. Full Formspec support is not implemented yet and can be added by a later change. --- src/client/inputhandler.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/client/inputhandler.h') diff --git a/src/client/inputhandler.h b/src/client/inputhandler.h index 73e507fdc..824b0da2e 100644 --- a/src/client/inputhandler.h +++ b/src/client/inputhandler.h @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define INPUT_HANDLER_H #include "irrlichttypes_extrabloated.h" +#include "joystick_controller.h" class MyEventReceiver : public IEventReceiver { @@ -62,6 +63,14 @@ public: return true; } #endif + + if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) { + /* TODO add a check like: + if (event.JoystickEvent != joystick_we_listen_for) + return false; + */ + return joystick->handleEvent(event.JoystickEvent); + } // handle mouse events if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) { if (noMenuActive() == false) { @@ -172,6 +181,8 @@ public: s32 mouse_wheel; + JoystickController *joystick; + #ifdef HAVE_TOUCHSCREENGUI TouchScreenGUI* m_touchscreengui; #endif @@ -202,6 +213,7 @@ public: m_receiver(receiver), m_mousepos(0,0) { + m_receiver->joystick = &joystick; } virtual bool isKeyDown(const KeyPress &keyCode) { @@ -288,6 +300,7 @@ public: void clear() { + joystick.clear(); m_receiver->clearInput(); } private: -- cgit v1.2.3