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:
authorMitchell Stokes <mogurijin@gmail.com>2012-12-21 06:28:59 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-12-21 06:28:59 +0400
commitf2f2b6153a2a818ca940a4df5b7dafc743ef2d2f (patch)
treea6562a6c389b7f3e99461dda1245b1037b78a020 /source/gameengine/Ketsji/KX_PythonInitTypes.cpp
parent26752e8b3a367a7c5161ad7418e910bb2ce6ee5d (diff)
BGE: Adding a Python interface for handling joysticks without needing logic bricks. These new SCA_PythonJoystick objects can be accessed using bge.logic.joysticks, which is a list of joysticks. The length of the list is the number of maximum supported joysticks, and indexes that do not have a joystick available are set to None. This means joysticks can be checked for using something like:
if bge.logic.joysticks[0]: activate_player_one() if bge.logic.joysticks[1]: activate_player_two() etc.. The interface exposed by SCA_PythonJoystick is very similar to the joystick logic brick except for one key difference: axis values are normalized to a -1.0 to 1.0 range instead of -32767 to 32767, which is what the logic brick exposed.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInitTypes.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
index 971730672db..10c210cf16e 100644
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
@@ -81,6 +81,7 @@
#include "SCA_RandomSensor.h"
#include "SCA_XNORController.h"
#include "SCA_XORController.h"
+#include "SCA_PythonJoystick.h"
#include "SCA_PythonKeyboard.h"
#include "SCA_PythonMouse.h"
#include "KX_IpoActuator.h"
@@ -250,6 +251,7 @@ void initPyTypes(void)
PyType_Ready_Attr(dict, SCA_XNORController, init_getset);
PyType_Ready_Attr(dict, SCA_XORController, init_getset);
PyType_Ready_Attr(dict, SCA_IController, init_getset);
+ PyType_Ready_Attr(dict, SCA_PythonJoystick, init_getset);
PyType_Ready_Attr(dict, SCA_PythonKeyboard, init_getset);
PyType_Ready_Attr(dict, SCA_PythonMouse, init_getset);
}