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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2005-01-23 04:36:29 +0300
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2005-01-23 04:36:29 +0300
commita1f0f165e42982fb5ef45dea54f3ebc48cbca892 (patch)
tree09d843f18ce514a76779d90767145dba7c8c8ad6 /source/gameengine/Converter/KX_ConvertSensors.cpp
parenta572d196e655e60c68c622adcb28cf45138c4d15 (diff)
Added Joystick sensor (from snailrose)
Diffstat (limited to 'source/gameengine/Converter/KX_ConvertSensors.cpp')
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 8818762bfab..396d633043c 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -65,7 +65,7 @@ probably misplaced */
#include "KX_NearSensor.h"
#include "KX_RadarSensor.h"
#include "KX_MouseFocusSensor.h"
-
+#include "SCA_JoystickSensor.h"
#include "KX_NetworkMessageSensor.h"
#include "SCA_PropertySensor.h"
@@ -548,7 +548,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
// this sumoObject is not deleted by a gameobj, so delete it ourself
// later (memleaks)!
MT_Scalar smallmargin = 0.0;
- MT_Scalar largemargin = 0.1;
+ MT_Scalar largemargin = 0.0;
bool bFindMaterial = false;
gamesensor = new KX_RadarSensor(
@@ -611,6 +611,62 @@ void BL_ConvertSensors(struct Object* blenderobject,
}
break;
}
+ case SENS_JOYSTICK:
+ {
+ int joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_NODEF;
+
+ bJoystickSensor* bjoy = (bJoystickSensor*) sens->data;
+
+ SCA_JoystickManager *eventmgr
+ = (SCA_JoystickManager*) logicmgr->FindEventManager(SCA_EventManager::JOY_EVENTMGR);
+ if (eventmgr)
+ {
+ int axis =0;
+ int axisf =0;
+ int button =0;
+ int buttonf =0;
+ int hat =0;
+ int hatf =0;
+ int prec =0;
+
+ switch(bjoy->type)
+ {
+ case SENS_JOY_AXIS:
+ axis = bjoy->axis;
+ axisf = bjoy->axisf;
+ prec = bjoy->precision;
+ joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_AXIS;
+ break;
+ case SENS_JOY_BUTTON:
+ button = bjoy->button;
+ buttonf = bjoy->buttonf;
+ joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_BUTTON;
+ break;
+ case SENS_JOY_HAT:
+ hat = bjoy->hat;
+ hatf = bjoy->hatf;
+ joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_HAT;
+ break;
+ default:
+ printf("Error: bad case statement\n");
+ break;
+ }
+ gamesensor = new SCA_JoystickSensor(
+ eventmgr,
+ gameobj,
+ joysticktype,
+ axis,axisf,
+ prec,
+ button,buttonf,
+ hat,hatf);
+ }
+ else
+ {
+ printf("Error there was a problem finding the event manager\n");
+ }
+
+ break;
+ }
default:
{
}