mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Proper ~Joystick() dtor. Make haptics optional. Hopefully fixes #50.
This commit is contained in:
parent
1af3b0f220
commit
6f170de929
3 changed files with 18 additions and 2 deletions
|
@ -712,7 +712,8 @@ void Core::init()
|
|||
SDL_putenv((char *) "SDL_MOUSE_RELATIVE=0");
|
||||
#endif
|
||||
|
||||
if((SDL_Init(SDL_INIT_EVERYTHING))==-1)
|
||||
// Haptic is inited separately, in Jostick.cpp, when a joystick is actually plugged in
|
||||
if((SDL_Init(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC))==-1)
|
||||
{
|
||||
std::string msg("Failed to init SDL: ");
|
||||
msg.append(SDL_GetError());
|
||||
|
@ -2849,7 +2850,6 @@ void Core::onJoystickRemoved(int instanceID)
|
|||
if(Joystick *j = joysticks[i])
|
||||
if(j->getInstanceID() == instanceID)
|
||||
{
|
||||
j->shutdown();
|
||||
delete j;
|
||||
joysticks[i] = NULL;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "Joystick.h"
|
||||
#include "Core.h"
|
||||
#include "SDL.h"
|
||||
|
||||
unsigned Joystick::GetNumJoysticks()
|
||||
{
|
||||
|
@ -33,6 +34,9 @@ Joystick::Joystick()
|
|||
# ifdef BBGE_BUILD_SDL2
|
||||
sdl_controller = NULL;
|
||||
sdl_haptic = NULL;
|
||||
if(!SDL_WasInit(SDL_INIT_HAPTIC))
|
||||
if(SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0)
|
||||
debugLog("Failed to init haptic subsystem");
|
||||
# endif
|
||||
sdl_joy = NULL;
|
||||
buttonBitmask = 0;
|
||||
|
@ -51,6 +55,16 @@ Joystick::Joystick()
|
|||
enabled = false;
|
||||
}
|
||||
|
||||
Joystick::~Joystick()
|
||||
{
|
||||
shutdown();
|
||||
|
||||
#ifdef BBGE_BUILD_SDL2
|
||||
if(SDL_WasInit(SDL_INIT_HAPTIC))
|
||||
SDL_QuitSubSystem(SDL_INIT_HAPTIC);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *Joystick::getName() const
|
||||
{
|
||||
return name.c_str();
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
static unsigned GetNumJoysticks();
|
||||
|
||||
Joystick();
|
||||
~Joystick();
|
||||
|
||||
bool init(int stick=0);
|
||||
void shutdown();
|
||||
//Ranges from 0 to 1 (full speed).
|
||||
|
|
Loading…
Reference in a new issue