Re #191 (Emergency/Parking Brake) : Non-customizable full brake power on the rear wheels for the moment

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

Former-commit-id: c6df9bb91475fb1fa8ed9e5ac021ff7004006eab
Former-commit-id: 4ae5dd776afb0bb6fb933f080beb9960038249cb
This commit is contained in:
pouillot 2010-10-09 20:56:16 +00:00
parent 93451c1113
commit 547226ab30
12 changed files with 71 additions and 43 deletions

View file

@ -851,6 +851,18 @@ common_drive(const int index, tCarElt* car, tSituation *s)
if (car->_clutchCmd != 0.0f)
HCtx[idx]->autoClutch = false;
// Ebrake here so that it can override the clutch control
if ((cmd[CMD_EBRAKE].type == GFCTRL_TYPE_JOY_BUT && joyInfo->levelup[cmd[CMD_EBRAKE].val])
|| (cmd[CMD_EBRAKE].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->button[cmd[CMD_EBRAKE].val])
|| (cmd[CMD_EBRAKE].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_EBRAKE].val)].state == GFUI_KEY_DOWN))
{
car->_ebrakeCmd = 1;
if (HCtx[idx]->autoClutch)
car->_clutchCmd = 1;
} else {
car->_ebrakeCmd = 0;
}
switch (cmd[CMD_THROTTLE].type) {
case GFCTRL_TYPE_JOY_AXIS:
throttle = joyInfo->ax[cmd[CMD_THROTTLE].val];

View file

@ -49,7 +49,8 @@ tControlCmd CmdControlRef[] = {
{HM_ATT_RIGHTSTEER, GFCTRL_TYPE_JOY_AXIS, 0, HM_ATT_RIGHTSTEER_MIN, 0.0, 0.0, HM_ATT_RIGHTSTEER_MAX, 1.0, HM_ATT_STEER_SENS, 2.0, HM_ATT_RIGHTSTEER_POW, 1.0, HM_ATT_STEER_SPD, 0.0, HM_ATT_STEER_DEAD, 0.0},
{HM_ATT_LIGHT1_CMD, GFCTRL_TYPE_NOT_AFFECTED, -1, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0},
{HM_ATT_CLUTCH, GFCTRL_TYPE_JOY_AXIS, 1, HM_ATT_CLUTCH_MIN, 0.0, 0.0, HM_ATT_CLUTCH_MAX, 1.0, HM_ATT_CLUTCH_SENS, 1.0, HM_ATT_CLUTCH_POW, 2.0, NULL, 0.0, NULL, 0.0},
{HM_ATT_SPDLIM_CMD, GFCTRL_TYPE_NOT_AFFECTED, -1, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0}
{HM_ATT_SPDLIM_CMD, GFCTRL_TYPE_NOT_AFFECTED, -1, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0},
{HM_ATT_EBRAKE_CMD, GFCTRL_TYPE_JOY_BUT, 19, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0}
};
const int NbCmdControl = sizeof(CmdControlRef) / sizeof(CmdControlRef[0]);

View file

@ -64,6 +64,7 @@ extern const std::string Yn[];
#define CMD_LIGHT1 16
#define CMD_CLUTCH 17
#define CMD_SPDLIM 18
#define CMD_EBRAKE 19
extern void HmReadPrefs(const int index);

View file

@ -14,7 +14,7 @@
<!DOCTYPE params SYSTEM "../../libs/tgf/params.dtd">
<params mode="mw" type="template" name="Player Pref" version="1.0">
<params mode="mw" type="template" name="Player Pref" version="1.1">
<section name="joystick">
<attstr name="up shift" val="BTN1-0"/>
@ -54,6 +54,7 @@
<attnum name="brake max" val="-1.1"/>
<attnum name="brake sensitivity" val="0.2"/>
<attnum name="brake power" val="1.2"/>
<attstr name="ebrake cmd" val=""/>
<attstr name="clutch" val="AXIS4-0"/>
<attnum name="clutch min" val="1.0"/>
@ -103,6 +104,7 @@
<attnum name="brake max" val="1"/>
<attnum name="brake sensitivity" val="1.0"/>
<attnum name="brake power" val="0"/>
<attstr name="ebrake cmd" val=""/>
</section>
<section name="Preferences">
@ -138,6 +140,7 @@
<attstr name="ASR cmd" val="t"/>
<attstr name="Speed Limiter" val="s"/>
<attstr name="Light1 cmd" val="l"/>
<attstr name="ebrake cmd" val=""/>
</section>
</section>
@ -166,6 +169,7 @@
<attnum name="brake max" val="1.2" min="-1.0" max="1.0"/>
<attnum name="brake sensitivity" val="1.0" min="0.1" max="2.0"/>
<attnum name="brake power" val="1.2" min="0.5" max="4.0"/>
<attstr name="ebrake cmd" val=""/>
</section>
<section name="joystick USB MsFFWheel">
@ -191,6 +195,7 @@
<attnum name="brake max" val="-1.1"/>
<attnum name="brake sensitivity" val="0.5"/>
<attnum name="brake power" val="0.8"/>
<attstr name="ebrake cmd" val=""/>
</section>
<section name="joystick digital (joypad)">
@ -222,6 +227,7 @@
<attnum name="throttle power" val="1.2"/>
<attnum name="brake sensitivity" val="0.5"/>
<attnum name="brake power" val="1.2"/>
<attstr name="ebrake cmd" val=""/>
</section>
</params>

View file

@ -73,7 +73,8 @@ tControlCmd CmdControlRef[] = {
{HM_ATT_RIGHTSTEER, GFCTRL_TYPE_JOY_AXIS, 0, HM_ATT_RIGHTSTEER_MIN, 0.0, 0.0, HM_ATT_RIGHTSTEER_MAX, 1.0, HM_ATT_STEER_SENS, 2.0, HM_ATT_RIGHTSTEER_POW, 1.0, HM_ATT_STEER_SPD, 0.0, HM_ATT_STEER_DEAD, 0.0},
{HM_ATT_LIGHT1_CMD, GFCTRL_TYPE_NOT_AFFECTED, -1, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0},
{HM_ATT_CLUTCH, GFCTRL_TYPE_JOY_AXIS, 1, HM_ATT_CLUTCH_MIN, 0.0, 0.0, HM_ATT_CLUTCH_MAX, 1.0, HM_ATT_CLUTCH_SENS, 1.0, HM_ATT_CLUTCH_POW, 2.0, NULL, 0.0, NULL, 0.0},
{HM_ATT_SPDLIM_CMD, GFCTRL_TYPE_NOT_AFFECTED, -1, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0}
{HM_ATT_SPDLIM_CMD, GFCTRL_TYPE_NOT_AFFECTED, -1, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0},
{HM_ATT_EBRAKE_CMD, GFCTRL_TYPE_JOY_BUT, 19, NULL, 0.0, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0, NULL, 0.0}
};
const int nbCmdControl = sizeof(CmdControlRef) / sizeof(CmdControlRef[0]);

View file

@ -397,6 +397,7 @@ typedef struct {
int lightCmd; /**< Lights command */
#define RM_LIGHT_HEAD1 0x00000001 /**< head light 1 */
#define RM_LIGHT_HEAD2 0x00000002 /**< head light 2 */
int ebrakeCmd; /**< Parking/Emergency Brake command */
} tCarCtrl;
#define _steerCmd ctrl.steer
#define _accelCmd ctrl.accelCmd
@ -407,6 +408,7 @@ typedef struct {
#define _msgCmd ctrl.msg
#define _msgColorCmd ctrl.msgColor
#define _lightCmd ctrl.lightCmd
#define _ebrakeCmd ctrl.ebrakeCmd
struct RobotItf;

View file

@ -41,6 +41,7 @@
#define HM_ATT_DN_SHFT "down shift"
#define HM_ATT_ASR_CMD "ASR cmd"
#define HM_ATT_ABS_CMD "ABS cmd"
#define HM_ATT_EBRAKE_CMD "ebrake cmd"
#define HM_ATT_LIGHT1_CMD "Light1 cmd"
#define HM_ATT_SPDLIM_CMD "Speed Limiter"
@ -92,6 +93,7 @@
#define HM_ATT_BRAKE_SENS "brake sensitivity"
#define HM_ATT_BRAKE_POW "brake power"
#define HM_ATT_BRAKE_DEAD "brake dead zone"
#define HM_ATT_EBRAKE "ebrake"
#define HM_ATT_CLUTCH "clutch"
#define HM_ATT_CLUTCH_MIN "clutch min"

View file

@ -24,8 +24,8 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
@ -39,11 +39,11 @@
#include "mouseconfig.h"
#include "joystickconfig.h"
static void *ScrHandle = NULL;
static void *ScrHandle = NULL;
static void *PrevScrHandle = NULL;
static void *PrefHdle = NULL;
static tCtrlMouseInfo MouseInfo;
static tCtrlMouseInfo MouseInfo;
static char CurrentSection[256];
/* Control command information */
@ -66,7 +66,8 @@ static tCmdInfo Cmd[] = {
{HM_ATT_GEAR_3, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{HM_ATT_GEAR_4, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{HM_ATT_GEAR_5, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{HM_ATT_GEAR_6, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 0, 1}
{HM_ATT_GEAR_6, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{HM_ATT_EBRAKE_CMD, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 0, 1}
};
static const int MaxCmd = sizeof(Cmd) / sizeof(Cmd[0]);
@ -77,29 +78,29 @@ static const int ICmdNeutralGear = 10;
typedef struct tCmdDispInfo
{
unsigned gearChangeModeMask;
int y;
} tCmdDispInfo;
static tCmdDispInfo CmdDispInfo[] = {
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 400 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 370 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 340 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 310 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 280 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 250 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 220 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 190 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 160 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 400 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID, 370 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ, 340 },
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ, 310 },
{ GEAR_MODE_GRID, 340 },
{ GEAR_MODE_GRID, 310 },
{ GEAR_MODE_GRID, 280 },
{ GEAR_MODE_GRID, 250 },
{ GEAR_MODE_GRID, 220 },
{ GEAR_MODE_GRID, 190 }
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // LEFTSTEER,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // RIGHTSTEER
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // THROTTLE,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // BRAKE,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // CLUTCH,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // ABS_CMD,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // ASR_CMD,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // SPDLIM_CMD
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // LIGHT1_CMD
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // GEAR_R,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID }, // GEAR_N,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ, }, // DN_SHFT,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ, }, // UP_SHFT,
{ GEAR_MODE_GRID }, // GEAR_1,
{ GEAR_MODE_GRID }, // GEAR_2,
{ GEAR_MODE_GRID }, // GEAR_3,
{ GEAR_MODE_GRID }, // GEAR_4,
{ GEAR_MODE_GRID }, // GEAR_5,
{ GEAR_MODE_GRID }, // GEAR_6,
{ GEAR_MODE_AUTO | GEAR_MODE_SEQ | GEAR_MODE_GRID } // EBRAKE_CMD
};
static jsJoystick *Joystick[GFCTRL_JOY_NUMBER];
@ -539,7 +540,7 @@ DevCalibrate(void * /* dummy */)
void *
ControlMenuInit(void *prevMenu, void *prefHdle, unsigned index, tGearChangeMode gearChangeMode)
{
int x, x2, i;
int i;
ReloadValues = 1;
@ -571,24 +572,14 @@ ControlMenuInit(void *prevMenu, void *prefHdle, unsigned index, tGearChangeMode
/* Default keyboard shortcuts */
GfuiMenuDefaultKeysAdd(ScrHandle);
/* Screen coordinates for labels, buttons, ... */
x = 10;
x2 = 210;
/* For each control (in Cmd array), create the associated label and editbox */
for (i = 0; i < MaxCmd; i++)
{
std::string strCmd = Cmd[i].name;
Cmd[i].labelId = CreateLabelControl(ScrHandle,param,strCmd.c_str());
std::string strCmdEdit = strCmd+" button";
Cmd[i].labelId = CreateLabelControl(ScrHandle,param,Cmd[i].name);
std::string strCmdEdit(Cmd[i].name);
strCmdEdit += " button";
Cmd[i].Id = CreateButtonControlEx(ScrHandle,param,strCmdEdit.c_str(),(void*)i,onPush,NULL,(tfuiCallback)NULL,onFocusLost);
/* If first column done, change to the second */
if (i == MaxCmd / 2 - 1) {
x = 320;
x2 = 220;
}
}
/* Steer Sensibility label and associated editbox */
CreateLabelControl(ScrHandle,param,"Steer Sensitivity");

View file

@ -460,7 +460,7 @@ void grUpdateCarlight(tCarElt *car,class cGrPerspCamera *curCam, int disp)
switch (theCarslight[car->index].lightType[i]) {
case LIGHT_TYPE_BRAKE:
case LIGHT_TYPE_BRAKE2:
if (car->_brakeCmd>0)
if (car->_brakeCmd>0 || car->_ebrakeCmd>0)
DoDraw = true;
break;
case LIGHT_TYPE_FRONT:

View file

@ -63,4 +63,8 @@ SimBrakeSystemUpdate(tCar *car)
ctrl *= brkSyst->coeff;
car->wheel[FRNT_RGT].brake.pressure = car->wheel[FRNT_LFT].brake.pressure = ctrl * brkSyst->rep;
car->wheel[REAR_RGT].brake.pressure = car->wheel[REAR_LFT].brake.pressure = ctrl * (1 - brkSyst->rep);
if (car->ctrl->ebrakeCmd > 0) {
car->wheel[REAR_RGT].brake.pressure = car->wheel[REAR_LFT].brake.pressure = brkSyst->coeff;
}
}

View file

@ -63,4 +63,8 @@ SimBrakeSystemUpdate(tCar *car)
ctrl *= brkSyst->coeff;
car->wheel[FRNT_RGT].brake.pressure = car->wheel[FRNT_LFT].brake.pressure = ctrl * brkSyst->rep;
car->wheel[REAR_RGT].brake.pressure = car->wheel[REAR_LFT].brake.pressure = ctrl * (1 - brkSyst->rep);
if (car->ctrl->ebrakeCmd > 0) {
car->wheel[REAR_RGT].brake.pressure = car->wheel[REAR_LFT].brake.pressure = brkSyst->coeff;
}
}

View file

@ -63,4 +63,8 @@ SimBrakeSystemUpdate(tCar *car)
ctrl *= brkSyst->coeff;
car->wheel[FRNT_RGT].brake.pressure = car->wheel[FRNT_LFT].brake.pressure = ctrl * brkSyst->rep;
car->wheel[REAR_RGT].brake.pressure = car->wheel[REAR_LFT].brake.pressure = ctrl * (1 - brkSyst->rep);
if (car->ctrl->ebrakeCmd > 0) {
car->wheel[REAR_RGT].brake.pressure = car->wheel[REAR_LFT].brake.pressure = brkSyst->coeff;
}
}