forked from bartvdbraak/blender
BGE bug [#4839] fixed: joystick keeps working after an overlay scene is removed
This commit is contained in:
parent
b46ef6ecb3
commit
1bdc909555
@ -55,6 +55,34 @@ SCA_Joystick::~SCA_Joystick()
|
||||
delete m_private;
|
||||
}
|
||||
|
||||
SCA_Joystick *SCA_Joystick::m_instance = NULL;
|
||||
int SCA_Joystick::m_refCount = 0;
|
||||
|
||||
SCA_Joystick *SCA_Joystick::GetInstance()
|
||||
{
|
||||
if (m_instance == 0)
|
||||
{
|
||||
m_instance = new SCA_Joystick();
|
||||
m_instance->CreateJoystickDevice();
|
||||
m_refCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_refCount++;
|
||||
}
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void SCA_Joystick::ReleaseInstance()
|
||||
{
|
||||
if (--m_refCount == 0)
|
||||
{
|
||||
DestroyJoystickDevice();
|
||||
delete m_instance;
|
||||
m_instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SCA_Joystick::CreateJoystickDevice()
|
||||
{
|
||||
|
@ -71,12 +71,16 @@
|
||||
/*
|
||||
|
||||
* Basic Joystick class
|
||||
|
||||
* I will make this class a singleton because there should be only one joystick
|
||||
* even if there are more than one scene using it and count how many scene are using it.
|
||||
* The underlying joystick should only be removed when the last scene is removed
|
||||
*/
|
||||
|
||||
class SCA_Joystick
|
||||
|
||||
{
|
||||
static SCA_Joystick *m_instance;
|
||||
static int m_refCount;
|
||||
|
||||
class PrivateData;
|
||||
|
||||
@ -258,20 +262,22 @@ class SCA_Joystick
|
||||
|
||||
int pGetHat(int direction);
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
SCA_Joystick();
|
||||
|
||||
~SCA_Joystick();
|
||||
|
||||
|
||||
|
||||
bool CreateJoystickDevice(void);
|
||||
|
||||
void DestroyJoystickDevice(void);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static SCA_Joystick *GetInstance();
|
||||
|
||||
void ReleaseInstance();
|
||||
|
||||
|
||||
void HandleEvents();
|
||||
|
||||
/*
|
||||
|
@ -43,15 +43,13 @@ SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr)
|
||||
: SCA_EventManager(JOY_EVENTMGR),
|
||||
m_logicmgr(logicmgr)
|
||||
{
|
||||
m_joystick = new SCA_Joystick();
|
||||
m_joystick->CreateJoystickDevice();
|
||||
m_joystick = SCA_Joystick::GetInstance();
|
||||
}
|
||||
|
||||
|
||||
SCA_JoystickManager::~SCA_JoystickManager()
|
||||
{
|
||||
m_joystick->DestroyJoystickDevice();
|
||||
delete m_joystick;
|
||||
m_joystick->ReleaseInstance();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user