Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-04-05 00:39:31 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-04-05 00:39:31 +0400
commit1bdc909555f3065a7a79b9c75e2fd828e2fc1e8c (patch)
tree9f41efd81cb062ddc6f8730162d547cddb00d000 /source/gameengine/GameLogic/Joystick
parentb46ef6ecb39fac633c9f9890fae2f07013696500 (diff)
BGE bug [#4839] fixed: joystick keeps working after an overlay scene is removed
Diffstat (limited to 'source/gameengine/GameLogic/Joystick')
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp28
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.h20
2 files changed, 41 insertions, 7 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index 071301514fb..79da15721f3 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -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()
{
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
index 2d2a713fe00..997e76615d3 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
@@ -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();
/*