Revision: 1535
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1535&view=rev
Author: rorthomas
Date: 2010-08-27 06:26:54 +0000 (Fri, 27 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-27 06:13:32 UTC (rev 1534)
+++ trunk/source/main/Beam.cpp 2010-08-27 06:26:54 UTC (rev 1535)
@@ -8629,7 +8629,7 @@
}
//need a maximum rate for analog devices, otherwise hydro beams
break
if (!hydroSpeedCoupling)
- rate=100;
+ rate=10;
if ( (hydrodircommand!=0 && hydroSpeedCoupling) ||
!hydroSpeedCoupling)
{
if (hydrodirstate > hydrodircommand)
@@ -8712,6 +8712,8 @@
if (beams[hydro[i]].hydroFlags & HYDRO_FLAG_REV_RUDDER)
{cstate-=hydrorudderstate;div++;}
if (beams[hydro[i]].hydroFlags & HYDRO_FLAG_REV_ELEVATOR)
{cstate-=hydroelevatorstate;div++;}
+ if (cstate>1.0) cstate=1.0;
+ if (cstate<-1.0) cstate=-1.0;
// Animators following, if no animator, skip all the tests...
int flagstate = beams[hydro[i]].animFlags;
if(flagstate)
Modified: trunk/source/main/InputEngine.cpp
===================================================================
--- trunk/source/main/InputEngine.cpp 2010-08-27 06:13:32 UTC (rev 1534)
+++ trunk/source/main/InputEngine.cpp 2010-08-27 06:26:54 UTC (rev 1535)
@@ -2132,7 +2132,7 @@
|| 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)
+ && getEventValue(eventID, true, 2)!=0.0)
{
return true;
}
@@ -2159,7 +2159,7 @@
#endif //0
}
-float InputEngine::getEventValue(int eventID, bool pure, bool onlyAnalog)
+float InputEngine::getEventValue(int eventID, bool pure, int valueSource)
{
float returnValue = 0;
std::vector<event_trigger_t> t_vec = events[eventID];
@@ -2168,7 +2168,7 @@
{
event_trigger_t t = *i;
- if (!onlyAnalog)
+ if (valueSource==0 || valueSource==1)
{
switch(t.eventtype)
{
@@ -2245,112 +2245,115 @@
}
}
- switch (t.eventtype)
+ if (valueSource==0 || valueSource==2)
{
- case ET_MouseAxisX:
- value = mouseState.X.abs / 32767;
- break;
- case ET_MouseAxisY:
- value = mouseState.Y.abs / 32767;
- break;
- case ET_MouseAxisZ:
- value = mouseState.Z.abs / 32767;
- break;
-
- case ET_JoystickAxisRel:
- case ET_JoystickAxisAbs:
- {
- if(t.joystickNumber > free_joysticks ||
!mJoy[t.joystickNumber])
+ switch (t.eventtype)
+ {
+ case ET_MouseAxisX:
+ value = mouseState.X.abs / 32767;
+ break;
+ case ET_MouseAxisY:
+ value = mouseState.Y.abs / 32767;
+ break;
+ case ET_MouseAxisZ:
+ value = mouseState.Z.abs / 32767;
+ break;
+
+ case ET_JoystickAxisRel:
+ case ET_JoystickAxisAbs:
{
- value=0;
- continue;
- }
- if(t.joystickAxisNumber >=
(int)joyState[t.joystickNumber].mAxes.size())
- {
-#ifndef NOOGRE
-
LogManager::getSingleton().logMessage("*** Joystick has not enough axis for
mapping: need axe "+StringConverter::toString(t.joystickAxisNumber) + ",
availabe axis:
"+StringConverter::toString(joyState[t.joystickNumber].mAxes.size()));
-#endif
- value=0;
- continue;
- }
- Axis axe =
joyState[t.joystickNumber].mAxes[t.joystickAxisNumber];
-
- if(t.eventtype == ET_JoystickAxisRel)
- {
- value = (float)axe.rel /
(float)mJoy[t.joystickNumber]->MAX_AXIS;
- }
- else
- {
- value = (float)axe.abs /
(float)mJoy[t.joystickNumber]->MAX_AXIS;
- switch(t.joystickAxisRegion)
+ if(t.joystickNumber >
free_joysticks || !mJoy[t.joystickNumber])
{
- case 0:
- // normal case, full
axis used
- value = (value + 1)/2;
- break;
- case -1:
- // lower range used
- if(value > 0)
- value = 0;
- else
- value = -value;
- break;
- case 1:
- // upper range used
- if(value < 0)
- value = 0;
- break;
+ value=0;
+ continue;
}
+ if(t.joystickAxisNumber >=
(int)joyState[t.joystickNumber].mAxes.size())
+ {
+ #ifndef NOOGRE
+
LogManager::getSingleton().logMessage("*** Joystick has not enough axis for
mapping: need axe "+StringConverter::toString(t.joystickAxisNumber) + ",
availabe axis:
"+StringConverter::toString(joyState[t.joystickNumber].mAxes.size()));
+ #endif
+ value=0;
+ continue;
+ }
+ Axis axe =
joyState[t.joystickNumber].mAxes[t.joystickAxisNumber];
- if(t.joystickAxisHalf)
+ if(t.eventtype ==
ET_JoystickAxisRel)
{
- // XXX: TODO: write this
- //float a =
(double)((value+1.0)/2.0);
- //float b =
(double)(1.0-(value+1.0)/2.0);
-
//LogManager::getSingleton().logMessage("half:
"+StringConverter::toString(value)+" / "+StringConverter::toString(a)+" /
"+StringConverter::toString(b));
- //no dead zone in half
axis
- value = (1.0 + value) /
2.0;
- if
(t.joystickAxisReverse)
- value = 1.0 -
value;
- if(!pure)
- value =
axisLinearity(value, t.joystickAxisLinearity);
- }else
+ value = (float)axe.rel
/ (float)mJoy[t.joystickNumber]->MAX_AXIS;
+ }
+ else
{
-
//LogManager::getSingleton().logMessage("not half:
"+StringConverter::toString(value)+" /
"+StringConverter::toString(deadZone(value, t.joystickAxisDeadzone)) +" /
"+StringConverter::toString(t.joystickAxisDeadzone) );
- if
(t.joystickAxisReverse)
- value = 1-value;
- if(!pure)
- // no deadzone
when using oure value
- value =
deadZone(value, t.joystickAxisDeadzone);
- if(!pure)
- value =
axisLinearity(value, t.joystickAxisLinearity);
+ value = (float)axe.abs
/ (float)mJoy[t.joystickNumber]->MAX_AXIS;
+
switch(t.joystickAxisRegion)
+ {
+ case 0:
+ // normal case,
full axis used
+ value = (value
+ 1)/2;
+ break;
+ case -1:
+ // lower range
used
+ if(value > 0)
+ value =
0;
+ else
+ value =
-value;
+ break;
+ case 1:
+ // upper range
used
+ if(value < 0)
+ value =
0;
+ break;
+ }
+
+ if(t.joystickAxisHalf)
+ {
+ // XXX: TODO:
write this
+ //float a =
(double)((value+1.0)/2.0);
+ //float b =
(double)(1.0-(value+1.0)/2.0);
+
//LogManager::getSingleton().logMessage("half:
"+StringConverter::toString(value)+" / "+StringConverter::toString(a)+" /
"+StringConverter::toString(b));
+ //no dead zone
in half axis
+ value = (1.0 +
value) / 2.0;
+ if
(t.joystickAxisReverse)
+ value =
1.0 - value;
+ if(!pure)
+ value =
axisLinearity(value, t.joystickAxisLinearity);
+ }else
+ {
+
//LogManager::getSingleton().logMessage("not half:
"+StringConverter::toString(value)+" /
"+StringConverter::toString(deadZone(value, t.joystickAxisDeadzone)) +" /
"+StringConverter::toString(t.joystickAxisDeadzone) );
+ if
(t.joystickAxisReverse)
+ value =
1-value;
+ if(!pure)
+ // no
deadzone when using oure value
+ value =
deadZone(value, t.joystickAxisDeadzone);
+ if(!pure)
+ value =
axisLinearity(value, t.joystickAxisLinearity);
+ }
+ // digital mapping of
analog axis
+
if(t.joystickAxisUseDigital)
+ if(value >= 0.5)
+ value =
1;
+ else
+ value =
0;
}
- // digital mapping of analog
axis
- if(t.joystickAxisUseDigital)
- if(value >= 0.5)
- value = 1;
- else
- value = 0;
}
- }
- break;
- case ET_JoystickSliderX:
- case ET_JoystickSliderY:
- {
- if(t.joystickNumber > free_joysticks ||
!mJoy[t.joystickNumber])
+ break;
+ case ET_JoystickSliderX:
+ case ET_JoystickSliderY:
{
- value=0;
- continue;
+ if(t.joystickNumber >
free_joysticks || !mJoy[t.joystickNumber])
+ {
+ value=0;
+ continue;
+ }
+ if(t.eventtype ==
ET_JoystickSliderX)
+ value =
(float)joyState[t.joystickNumber].mSliders[t.joystickSliderNumber].abX /
(float)mJoy[t.joystickNumber]->MAX_AXIS;
+ else if(t.eventtype ==
ET_JoystickSliderY)
+ value =
(float)joyState[t.joystickNumber].mSliders[t.joystickSliderNumber].abY /
(float)mJoy[t.joystickNumber]->MAX_AXIS;
+ value = (value + 1)/2; // full
axis
+ if(t.joystickSliderReverse)
+ value = 1.0 - value; //
reversed
}
- if(t.eventtype == ET_JoystickSliderX)
- value =
(float)joyState[t.joystickNumber].mSliders[t.joystickSliderNumber].abX /
(float)mJoy[t.joystickNumber]->MAX_AXIS;
- else if(t.eventtype ==
ET_JoystickSliderY)
- value =
(float)joyState[t.joystickNumber].mSliders[t.joystickSliderNumber].abY /
(float)mJoy[t.joystickNumber]->MAX_AXIS;
- value = (value + 1)/2; // full axis
- if(t.joystickSliderReverse)
- value = 1.0 - value; // reversed
- }
- break;
+ break;
+ }
}
// only return if grater zero, otherwise check all other
bombinations
if(value > returnValue)
Modified: trunk/source/main/InputEngine.h
===================================================================
--- trunk/source/main/InputEngine.h 2010-08-27 06:13:32 UTC (rev 1534)
+++ trunk/source/main/InputEngine.h 2010-08-27 06:26:54 UTC (rev 1535)
@@ -425,7 +425,8 @@
public:
static InputEngine & Instance();
void Capture();
- float getEventValue(int eventID, bool pure=false, bool
onlyAnalog=false);
+ //valueSource: 0=digital and analog devices, 1=only digital, 2=only
analog
+ float getEventValue(int eventID, bool pure=false, int valueSource=0);
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-27 06:13:32 UTC (rev
1534)
+++ trunk/source/main/RoRFrameListener.cpp 2010-08-27 06:26:54 UTC (rev
1535)
@@ -2920,14 +2920,22 @@
else // this else part is called
when we are NOT in replaymode
{
// steering
- float tmp_left =
INPUTENGINE.getEventValue(EV_TRUCK_STEER_LEFT);
- float tmp_right =
INPUTENGINE.getEventValue(EV_TRUCK_STEER_RIGHT);
- float sum = -tmp_left +
tmp_right;
+ float tmp_left_digital =
INPUTENGINE.getEventValue(EV_TRUCK_STEER_LEFT,false,1);
+ float tmp_right_digital =
INPUTENGINE.getEventValue(EV_TRUCK_STEER_RIGHT,false,1);
+ float tmp_left_analog =
INPUTENGINE.getEventValue(EV_TRUCK_STEER_LEFT,false,2);
+ float tmp_right_analog =
INPUTENGINE.getEventValue(EV_TRUCK_STEER_RIGHT,false,2);
+
+ float sum =
-max(tmp_left_digital,tmp_left_analog)+ max(tmp_right_digital,tmp_right_analog);
+
if(sum < -1) sum = -1;
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));
+
+ if
((tmp_left_digital<tmp_left_analog) || (tmp_right_digital<tmp_right_analog))
+
trucks[current_truck]->hydroSpeedCoupling=false;
+ else
+
trucks[current_truck]->hydroSpeedCoupling=true;
//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.
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel
