enable basic force feedback

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6413 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 5b935ffaf3eb9747f2dbe78ebf5188340cd377de
Former-commit-id: 8a2666bfe54ad87b143764fd92715f11eb15bcfa
This commit is contained in:
madbad 2016-06-02 15:07:43 +00:00
parent d42ae28f77
commit 3cfa514afe
2 changed files with 13 additions and 2 deletions

View file

@ -1160,6 +1160,17 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
}
car->_steerCmd = leftSteer + rightSteer;
/* Force feedback hack */
float force = car->_steerTq * 32760 * 5;
if (force > 32760) force = 32760;
if (force < -32760) force = -32760;
//GfOut("force = %d\n", car->_steerTq);
gfctrlJoyConstantForce(int((cmd[CMD_LEFTSTEER].val) / GFCTRL_JOY_NUMBER), abs((int)force), force < 0 ? 9000 : 27000 );
//gfctrlJoyRumble(int((cmd[CMD_LEFTSTEER].val) / GFCTRL_JOY_NUMBER), 0.9);
#define GLANCERATE 3 // speed at which the driver turns his head, ~1/3s to full glance
newGlance = car->_glance;

View file

@ -347,7 +347,7 @@ gfctrlJoyInit(void)
if (!Haptics[index]) {
GfLogInfo("Joystick %d does not support haptic\n", index);
break;
#if 0
#if 1
} else {
// add an CF effect on startup
gfctrlJoyConstantForce(index, 50000, 9000);
@ -358,7 +358,7 @@ gfctrlJoyInit(void)
if (SDL_HapticRumbleSupported(Haptics[index]) == SDL_TRUE) {
if (SDL_HapticRumbleInit(Haptics[index]) != 0)
GfLogError("Couldn't init rumble on joystick %d: %s\n", index, SDL_GetError());
#if 0
#if 1
else
gfctrlJoyRumble(index, 0.5);
#endif