Adds support for SDL joystick and game controllers.

This commit is contained in:
OTHGMars 2019-01-10 20:09:05 -05:00
parent bc8796773c
commit 4fd6dfeaf0
4 changed files with 1530 additions and 31 deletions

View file

@ -21,6 +21,7 @@
//-----------------------------------------------------------------------------
#include "windowManager/sdl/sdlWindowMgr.h"
#include "platformSDL/sdlInputManager.h"
#include "gfx/gfxDevice.h"
#include "core/util/journal/process.h"
#include "core/strings/unicode.h"
@ -269,6 +270,13 @@ void PlatformWindowManagerSDL::_process()
SDL_Event evt;
while( SDL_PollEvent(&evt) )
{
if (evt.type >= SDL_JOYAXISMOTION && evt.type <= SDL_CONTROLLERDEVICEREMAPPED)
{
SDLInputManager* mgr = static_cast<SDLInputManager*>(Input::getManager());
if (mgr)
mgr->processEvent(evt);
continue;
}
switch(evt.type)
{
case SDL_QUIT:
@ -356,15 +364,16 @@ void PlatformWindowManagerSDL::_process()
case(SDL_DROPCOMPLETE):
{
if (!Con::isFunction("onDropEnd"))
break;
Con::executef("onDropEnd");
if (Con::isFunction("onDropEnd"))
Con::executef("onDropEnd");
break;
}
default:
{
//Con::printf("Event: %d", evt.type);
#ifdef TORQUE_DEBUG
Con::warnf("Unhandled SDL input event: 0x%04x", evt.type);
#endif
}
}
}