Added Game Controller support in InGameMessage

This commit is contained in:
Dimitris Panokostas 2018-01-04 14:16:27 +01:00
parent f2e4a16128
commit ee3279629d

View file

@ -8,6 +8,7 @@
#include <SDL_ttf.h> #include <SDL_ttf.h>
#include <guisan/sdl.hpp> #include <guisan/sdl.hpp>
#include <guisan/sdl/sdltruetypefont.hpp> #include <guisan/sdl/sdltruetypefont.hpp>
#include <guisan/gui.hpp>
#endif #endif
#include "SelectorEntry.hpp" #include "SelectorEntry.hpp"
@ -25,6 +26,7 @@
#include "inputdevice.h" #include "inputdevice.h"
#ifdef ANDROIDSDL #ifdef ANDROIDSDL
#include "androidsdl_event.h" #include "androidsdl_event.h"
#endif #endif
@ -84,6 +86,10 @@ void checkInput()
//------------------------------------------------- //-------------------------------------------------
// Check user input // Check user input
//------------------------------------------------- //-------------------------------------------------
if (SDL_NumJoysticks() > 0)
if (GUIjoy == nullptr)
GUIjoy = SDL_JoystickOpen(0);
while (SDL_PollEvent(&msg_event)) while (SDL_PollEvent(&msg_event))
{ {
if (msg_event.type == SDL_KEYDOWN) if (msg_event.type == SDL_KEYDOWN)
@ -121,6 +127,8 @@ void checkInput()
msg_input->pushInput(msg_event); msg_input->pushInput(msg_event);
#endif #endif
} }
if (GUIjoy)
SDL_JoystickClose(GUIjoy);
} }
void gui_init(const char* msg) void gui_init(const char* msg)