Revision: 1523
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1523&view=rev
Author: rorthomas
Date: 2010-08-21 09:11:32 +0000 (Sat, 21 Aug 2010)
Log Message:
-----------
ref #421
Modified Paths:
--------------
trunk/source/main/Beam.cpp
trunk/source/main/InputEngine.cpp
trunk/source/main/InputEngine.h
trunk/source/main/RoRFrameListener.cpp
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2010-08-19 18:29:09 UTC (rev 1522)
+++ trunk/source/main/Beam.cpp 2010-08-21 09:11:32 UTC (rev 1523)
@@ -8627,12 +8627,13 @@
//need a maximum rate for analog devices, otherwise hydro beams
break
if (!hydroSpeedCoupling)
rate=100;
-
- if (hydrodirstate > hydrodircommand)
- hydrodirstate -= dt * rate;
- else
- hydrodirstate += dt * rate;
-
+ if ( (hydrodircommand!=0 && hydroSpeedCoupling) ||
!hydroSpeedCoupling)
+ {
+ if (hydrodirstate > hydrodircommand)
+ hydrodirstate -= dt * rate;
+ else
+ hydrodirstate += dt * rate;
+ }
if(hydroSpeedCoupling)
{
float dirdelta=dt;
Modified: trunk/source/main/InputEngine.cpp
===================================================================
--- trunk/source/main/InputEngine.cpp 2010-08-19 18:29:09 UTC (rev 1522)
+++ trunk/source/main/InputEngine.cpp 2010-08-21 09:11:32 UTC (rev 1523)
@@ -2123,13 +2123,16 @@
//this means a analog device is always preferred over a digital
one
for (unsigned int i=0;i<t_vec.size();i++)
{
- if(t_vec[i].eventtype == ET_MouseAxisX \
+ if((t_vec[i].eventtype == ET_MouseAxisX \
|| t_vec[i].eventtype == ET_MouseAxisY \
|| t_vec[i].eventtype == ET_MouseAxisZ \
|| t_vec[i].eventtype == ET_JoystickAxisAbs \
|| t_vec[i].eventtype == ET_JoystickAxisRel \
|| t_vec[i].eventtype == ET_JoystickSliderX \
- || t_vec[i].eventtype == ET_JoystickSliderY)
+ || t_vec[i].eventtype == ET_JoystickSliderY) \
+ //check if value comes from analog device
+ //this way, only valid events (e.g. joystick
mapped, but unplugged) are recognized as analog events
+ && getEventValue(eventID, false, true)!=0.0)
{
return true;
}
@@ -2156,47 +2159,94 @@
#endif //0
}
-float InputEngine::getEventValue(int eventID, bool pure)
+float InputEngine::getEventValue(int eventID, bool pure, bool onlyAnalog)
{
float returnValue = 0;
std::vector<event_trigger_t> t_vec = events[eventID];
+ float value=0;
for(std::vector<event_trigger_t>::iterator i = t_vec.begin(); i !=
t_vec.end(); i++)
{
event_trigger_t t = *i;
- float value = 0;
- switch(t.eventtype)
+
+ if (!onlyAnalog)
{
- case ET_NONE:
- break;
- case ET_Keyboard:
- if(!keyState[t.keyCode])
+ switch(t.eventtype)
+ {
+ case ET_NONE:
break;
+ case ET_Keyboard:
+ if(!keyState[t.keyCode])
+ break;
- // only use explicite mapping, if two keys with
different modifiers exist, i.e. F1 and SHIFT+F1.
- // check for modificators
- if (t.explicite)
- {
- if(t.ctrl != (keyState[KC_LCONTROL] ||
keyState[KC_RCONTROL]))
- break;
- if(t.shift != (keyState[KC_LSHIFT] ||
keyState[KC_RSHIFT]))
- break;
- if(t.alt != (keyState[KC_LMENU] ||
keyState[KC_RMENU]))
- break;
- } else {
- if(t.ctrl && !(keyState[KC_LCONTROL] ||
keyState[KC_RCONTROL]))
- break;
- if(t.shift && !(keyState[KC_LSHIFT] ||
keyState[KC_RSHIFT]))
- break;
- if(t.alt && !(keyState[KC_LMENU] ||
keyState[KC_RMENU]))
- break;
- }
- value = 1;
- break;
- case ET_MouseButton:
- //if(t.mouseButtonNumber == 0)
- // TODO: FIXME
- value = mouseState.buttonDown(MB_Left);
- break;
+ // only use explicite mapping, if two
keys with different modifiers exist, i.e. F1 and SHIFT+F1.
+ // check for modificators
+ if (t.explicite)
+ {
+ if(t.ctrl !=
(keyState[KC_LCONTROL] || keyState[KC_RCONTROL]))
+ break;
+ if(t.shift !=
(keyState[KC_LSHIFT] || keyState[KC_RSHIFT]))
+ break;
+ if(t.alt != (keyState[KC_LMENU]
|| keyState[KC_RMENU]))
+ break;
+ } else {
+ if(t.ctrl &&
!(keyState[KC_LCONTROL] || keyState[KC_RCONTROL]))
+ break;
+ if(t.shift &&
!(keyState[KC_LSHIFT] || keyState[KC_RSHIFT]))
+ break;
+ if(t.alt &&
!(keyState[KC_LMENU] || keyState[KC_RMENU]))
+ break;
+ }
+ value = 1;
+ break;
+ case ET_MouseButton:
+ //if(t.mouseButtonNumber == 0)
+ // TODO: FIXME
+ value = mouseState.buttonDown(MB_Left);
+ break;
+ case ET_JoystickButton:
+ {
+ if(t.joystickNumber >
free_joysticks || !mJoy[t.joystickNumber])
+ {
+ value=0;
+ continue;
+ }
+ if(t.joystickButtonNumber >=
(int)mJoy[t.joystickNumber]->getNumberOfComponents(OIS_Button))
+ {
+#ifndef NOOGRE
+
LogManager::getSingleton().logMessage("*** Joystick has not enough buttons for
mapping: need button "+StringConverter::toString(t.joystickButtonNumber) + ",
availabe buttons:
"+StringConverter::toString(mJoy[t.joystickNumber]->getNumberOfComponents(OIS_Button)));
+#endif
+ value=0;
+ continue;
+ }
+ value =
joyState[t.joystickNumber].mButtons[t.joystickButtonNumber];
+ }
+ break;
+ case ET_JoystickPov:
+ {
+ if(t.joystickNumber >
free_joysticks || !mJoy[t.joystickNumber])
+ {
+ value=0;
+ continue;
+ }
+ if(t.joystickPovNumber >=
(int)mJoy[t.joystickNumber]->getNumberOfComponents(OIS_POV))
+ {
+#ifndef NOOGRE
+
LogManager::getSingleton().logMessage("*** Joystick has not enough POVs for
mapping: need POV "+StringConverter::toString(t.joystickPovNumber) + ",
availabe POVs:
"+StringConverter::toString(mJoy[t.joystickNumber]->getNumberOfComponents(OIS_POV)));
+#endif
+ value=0;
+ continue;
+ }
+
if(joyState[t.joystickNumber].mPOV[t.joystickPovNumber].direction &
t.joystickPovDirection)
+ value = 1;
+ else
+ value = 0;
+ }
+ break;
+ }
+
+ }
+ switch (t.eventtype)
+ {
case ET_MouseAxisX:
value = mouseState.X.abs / 32767;
break;
@@ -2206,24 +2256,7 @@
case ET_MouseAxisZ:
value = mouseState.Z.abs / 32767;
break;
- case ET_JoystickButton:
- {
- if(t.joystickNumber > free_joysticks ||
!mJoy[t.joystickNumber])
- {
- value=0;
- continue;
- }
- if(t.joystickButtonNumber >=
(int)mJoy[t.joystickNumber]->getNumberOfComponents(OIS_Button))
- {
-#ifndef NOOGRE
-
LogManager::getSingleton().logMessage("*** Joystick has not enough buttons for
mapping: need button "+StringConverter::toString(t.joystickButtonNumber) + ",
availabe buttons:
"+StringConverter::toString(mJoy[t.joystickNumber]->getNumberOfComponents(OIS_Button)));
-#endif
- value=0;
- continue;
- }
- value =
joyState[t.joystickNumber].mButtons[t.joystickButtonNumber];
- }
- break;
+
case ET_JoystickAxisRel:
case ET_JoystickAxisAbs:
{
@@ -2301,27 +2334,6 @@
}
}
break;
- case ET_JoystickPov:
- {
- if(t.joystickNumber > free_joysticks ||
!mJoy[t.joystickNumber])
- {
- value=0;
- continue;
- }
- if(t.joystickPovNumber >=
(int)mJoy[t.joystickNumber]->getNumberOfComponents(OIS_POV))
- {
-#ifndef NOOGRE
-
LogManager::getSingleton().logMessage("*** Joystick has not enough POVs for
mapping: need POV "+StringConverter::toString(t.joystickPovNumber) + ",
availabe POVs:
"+StringConverter::toString(mJoy[t.joystickNumber]->getNumberOfComponents(OIS_POV)));
-#endif
- value=0;
- continue;
- }
-
if(joyState[t.joystickNumber].mPOV[t.joystickPovNumber].direction &
t.joystickPovDirection)
- value = 1;
- else
- value = 0;
- }
- break;
case ET_JoystickSliderX:
case ET_JoystickSliderY:
{
Modified: trunk/source/main/InputEngine.h
===================================================================
--- trunk/source/main/InputEngine.h 2010-08-19 18:29:09 UTC (rev 1522)
+++ trunk/source/main/InputEngine.h 2010-08-21 09:11:32 UTC (rev 1523)
@@ -425,7 +425,7 @@
public:
static InputEngine & Instance();
void Capture();
- float getEventValue(int eventID, bool pure=false);
+ float getEventValue(int eventID, bool pure=false, bool
onlyAnalog=false);
bool getEventBoolValue(int eventID);
bool isEventAnalog(int eventID);
bool getEventBoolValueBounce(int eventID, float time=0.2f);
Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp 2010-08-19 18:29:09 UTC (rev
1522)
+++ trunk/source/main/RoRFrameListener.cpp 2010-08-21 09:11:32 UTC (rev
1523)
@@ -2882,7 +2882,7 @@
if(sum > 1) sum = 1;
trucks[current_truck]->hydrodircommand = sum;
-
trucks[current_truck]->hydroSpeedCoupling =
!(INPUTENGINE.isEventAnalog(EV_TRUCK_STEER_LEFT) &&
INPUTENGINE.isEventAnalog(EV_TRUCK_STEER_RIGHT));
+
trucks[current_truck]->hydroSpeedCoupling =
!(INPUTENGINE.isEventAnalog(EV_TRUCK_STEER_LEFT) ||
INPUTENGINE.isEventAnalog(EV_TRUCK_STEER_RIGHT));
//accelerate
float accval =
INPUTENGINE.getEventValue(EV_TRUCK_ACCELERATE);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel