svn merge -r 15392:15551 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / gameengine / GameLogic / SCA_JoystickSensor.cpp
index 8668c22f04484323b5a00222a654eeecdac58fa3..3fb439eb25bf91ae201e7f069ea0f871a66fb3dd 100644 (file)
@@ -70,6 +70,7 @@ std::cout << " hat flag "     << m_hatf               << std::endl;
 void SCA_JoystickSensor::Init()
 {
        m_istrig=(m_invert)?1:0;
+       m_reset = true;
 }
 
 SCA_JoystickSensor::~SCA_JoystickSensor()
@@ -79,9 +80,10 @@ SCA_JoystickSensor::~SCA_JoystickSensor()
 
 CValue* SCA_JoystickSensor::GetReplica()
 {
-       CValue* replica = new SCA_JoystickSensor(*this);
+       SCA_JoystickSensor* replica = new SCA_JoystickSensor(*this);
        // this will copy properties and so on...
        CValue::AddDataToReplica(replica);
+       replica->Init();
        return replica;
 }
 
@@ -99,7 +101,9 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
 {
        SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice();
        bool result = false;
+       bool reset = m_reset && m_level;
        
+       m_reset = false;
        switch(m_joymode)
        {
        case KX_JOYSENSORMODE_AXIS:
@@ -240,6 +244,8 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
        if(!js->IsTrig()){
                m_istrig = 0;
        }
+       if (reset)
+               result = true;
        return result;
 }