1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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.
This commit is contained in:
est31 2016-05-27 08:35:07 +02:00
parent 1e86c89f36
commit 2060fd9cbe
17 changed files with 577 additions and 80 deletions

View file

@ -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: