TORCS  1.3.9
The Open Racing Car Simulator
controlconfig.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : controlconfig.cpp
4  created : Wed Mar 12 21:20:34 CET 2003
5  copyright : (C) 2003-2024 by Eric Espie, Bernhard Wymann
6  email : berniw@bluewin.ch
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #include <tgfclient.h>
29 #include <track.h>
30 #include <robot.h>
31 #include <playerpref.h>
32 #include <plib/js.h>
33 #include <portability.h>
34 
35 #include "controlconfig.h"
36 #include "mouseconfig.h"
37 #include "joystickconfig.h"
38 
39 static void *scrHandle = NULL;
40 static void *prevHandle = NULL;
41 static void *PrefHdle = NULL;
42 
43 static int MouseCalButton;
44 static int JoyCalButton;
45 
47 static const int CURRENTSECTIONSIZE = 256;
49 
50 static tCmdInfo Cmd[] = {
51  {HM_ATT_GEAR_R, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
52  {HM_ATT_GEAR_N, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
53  {HM_ATT_UP_SHFT, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
54  {HM_ATT_DN_SHFT, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
55  {HM_ATT_BRAKE_TOFRONT, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
56  {HM_ATT_BRAKE_TOREAR, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
57  {HM_ATT_LIGHT1_CMD, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
63  {HM_ATT_ASR_CMD, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
64  {HM_ATT_ABS_CMD, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1},
65  {HM_ATT_SPDLIM_CMD, {-1, GFCTRL_TYPE_NOT_AFFECTED}, 0, 0, 0, 0, 0, 0, 0, 1}
66 };
67 
68 static int maxCmd = sizeof(Cmd) / sizeof(Cmd[0]);
69 
70 static jsJoystick *js[NUM_JOY] = {NULL};
71 static float ax[_JS_MAX_AXES * NUM_JOY] = {0};
72 static float axCenter[_JS_MAX_AXES * NUM_JOY];
73 static int rawb[NUM_JOY] = {0};
74 static int ReloadValues = 1;
75 
76 // Variable to give a small delay for axis registration which might be overlapped by a button.
77 // This is e.g. the case for my ps4 gamepad, L2 and R2 are a button and an axis.
78 static double axisPressedTime = 0.0;
79 
80 
81 typedef struct {
82  const char *key;
83  const char *label;
84  int id;
85  float value;
86 } EditboxValue;
87 
89  { HM_ATT_STEER_SENS, "Steer sensitivity", 0, 0.0f},
90  { HM_ATT_LEFTSTEER_POW, "Steer power", 0, 0.0f},
91  { HM_ATT_STEER_DEAD, "Steer dead zone", 0, 0.0f},
92  { HM_ATT_STEER_SPD, "Steer speed factor", 0, 0.0f},
93  { HM_ATT_BRAKE_SENS, "Brake sensitivity", 0, 0.0f},
94  { HM_ATT_BRAKE_POW, "Brake power", 0, 0.0f},
95  { HM_ATT_THROTTLE_SENS, "Throttle sensitivity", 0, 0.0f},
96  { HM_ATT_CLUTCH_SENS, "Clutch sensitivity", 0, 0.0f},
97 };
98 
99 static const int IDX_LEFTSTEER_POW = 1; // Index for the list above
100 static const int IDX_BRAKE_POW = 5; // Index for the list above
101 static const int nbEditboxValues = sizeof(editBoxValues)/sizeof(editBoxValues[0]);
102 
103 
104 static void onValueChange(void* v)
105 {
106  EditboxValue* editBoxValue = (EditboxValue*) v;
107  float fv;
108  const int BUFSIZE = 10;
109  char buf[BUFSIZE];
110 
111  char* val = GfuiEditboxGetString(scrHandle, editBoxValue->id);
112 
113  if (sscanf(val, "%f", &fv) == 1) {
114  snprintf(buf, BUFSIZE, "%6.4f", fv);
115  editBoxValue->value = fv;
116  GfuiEditboxSetString(scrHandle, editBoxValue->id, buf);
117  } else {
118  GfuiEditboxSetString(scrHandle, editBoxValue->id, "");
119  }
120 }
121 
122 
123 static void onSave(void * /* dummy */)
124 {
125  int i;
126  const char *str;
127 
128  // First write the command values
129  for (i = 0; i < maxCmd; i++) {
130  str = GfctrlGetNameByRef(Cmd[i].ref.type, Cmd[i].ref.index);
131  if (str) {
132  GfParmSetStr(PrefHdle, CurrentSection, Cmd[i].name, str);
133  } else {
134  GfParmSetStr(PrefHdle, CurrentSection, Cmd[i].name, "");
135  }
136 
137  if (Cmd[i].minName) {
138  GfParmSetNum(PrefHdle, CurrentSection, Cmd[i].minName, NULL, Cmd[i].min);
139  }
140 
141  if (Cmd[i].maxName) {
142  GfParmSetNum(PrefHdle, CurrentSection, Cmd[i].maxName, NULL, Cmd[i].max);
143  }
144 
145  if (Cmd[i].powName) {
146  GfParmSetNum(PrefHdle, CurrentSection, Cmd[i].powName, NULL, Cmd[i].pow);
147  }
148  }
149 
150  // The editbox values must be written after the command values, otherwise the wrong "power" values are saved
151  for (i = 0; i < nbEditboxValues; i++) {
153  if (strcmp(HM_ATT_LEFTSTEER_POW, editBoxValues[i].key) == 0) {
154  GfParmSetNum(PrefHdle, CurrentSection, HM_ATT_RIGHTSTEER_POW, NULL, editBoxValues[i].value); // In GUI we set left == right
155  }
156  }
157 
158  GfParmWriteFile(NULL, PrefHdle, "preferences");
160 }
161 
162 
163 static void updateButtonText(void)
164 {
165  int i;
166  const char *str;
167  int displayMouseCal = GFUI_INVISIBLE;
168  int displayJoyCal = GFUI_INVISIBLE;
169  const int BUFSIZE = 1024;
170  char buf[BUFSIZE];
171 
172  for (i = 0; i < maxCmd; i++) {
173  str = GfctrlGetNameByRef(Cmd[i].ref.type, Cmd[i].ref.index);
174  if (str) {
175  GfuiButtonSetText (scrHandle, Cmd[i].Id, str);
176  } else {
177  GfuiButtonSetText (scrHandle, Cmd[i].Id, "---");
178  }
179 
180  if (Cmd[i].ref.type == GFCTRL_TYPE_MOUSE_AXIS) {
181  displayMouseCal = GFUI_VISIBLE;
182  } else if (Cmd[i].ref.type == GFCTRL_TYPE_JOY_AXIS) {
183  displayJoyCal = GFUI_VISIBLE;
184  }
185  }
186 
187  for (i = 0; i < nbEditboxValues; i++) {
188  snprintf(buf, BUFSIZE, "%6.4f", editBoxValues[i].value);
190  }
191 
192  GfuiVisibilitySet(scrHandle, MouseCalButton, displayMouseCal);
193  GfuiVisibilitySet(scrHandle, JoyCalButton, displayJoyCal);
194 }
195 
196 
197 static void onFocusLost(void * /* dummy */)
198 {
200 }
201 
202 
204 
205 static int InputWaited = 0;
206 
207 
208 static int onKeyAction(unsigned char key, int /* modifier */, int state)
209 {
210  const char *name;
211 
212  if (!InputWaited || (state == GFUI_KEY_UP)) {
213  return 0;
214  }
215 
216  if (key == 27) {
217  /* escape */
218  CurrentCmd->ref.index = -1;
221  } else {
222  name = GfctrlGetNameByRef(GFCTRL_TYPE_KEYBOARD, (int)key);
223  CurrentCmd->ref.index = (int)key;
226  }
227 
228  glutIdleFunc(GfuiIdle);
229  InputWaited = 0;
231  return 1;
232 }
233 
234 
235 static int onSKeyAction(int key, int /* modifier */, int state)
236 {
237  const char *name;
238 
239  if (!InputWaited || (state == GFUI_KEY_UP)) {
240  return 0;
241  }
242 
244  CurrentCmd->ref.index = key;
247 
248  glutIdleFunc(GfuiIdle);
249  InputWaited = 0;
251  return 1;
252 }
253 
254 
255 static int getMovedAxis(void)
256 {
257  int i;
258  int Index = -1;
259  float maxDiff = 0.3;
260 
261  for (i = 0; i < _JS_MAX_AXES * NUM_JOY; i++) {
262  if (maxDiff < fabs(ax[i] - axCenter[i])) {
263  maxDiff = fabs(ax[i] - axCenter[i]);
264  Index = i;
265  }
266  }
267 
268  return Index;
269 }
270 
271 
272 // Returns true if the preferred input is an axis
273 static bool isAxisPreffered(tCmdInfo* cmd) {
274  return strcmp(cmd->name, HM_ATT_LEFTSTEER) == 0
275  || strcmp(cmd->name, HM_ATT_RIGHTSTEER) == 0
276  || strcmp(cmd->name, HM_ATT_THROTTLE) == 0
277  || strcmp(cmd->name, HM_ATT_BRAKE) == 0
278  || strcmp(cmd->name, HM_ATT_CLUTCH) == 0;
279 }
280 
281 
282 static bool checkJoystickButtonPressed(tCmdInfo* cmd, int b[], bool checkOnly)
283 {
284  int mask, i, index;
285 
286  for (index = 0; index < NUM_JOY; index++) {
287  if (js[index]) {
288  /* Joystick buttons */
289  for (i = 0, mask = 1; i < 32; i++, mask *= 2) {
290  if (((b[index] & mask) != 0) && ((rawb[index] & mask) == 0)) {
291  /* Button i fired */
292  const char *str = GfctrlGetNameByRef(GFCTRL_TYPE_JOY_BUT, i + 32 * index);
294  if (checkOnly) {
295  return true;
296  }
297 
298  glutIdleFunc(GfuiIdle);
299  InputWaited = 0;
300  cmd->ref.index = i + 32 * index;
302  GfuiButtonSetText (scrHandle, cmd->Id, str);
303  glutPostRedisplay();
304  rawb[index] = b[index];
305  return true;
306  }
307  }
308  }
309  }
310  rawb[index] = b[index];
311  }
312  return false;
313 }
314 
316 {
317  int axis = getMovedAxis();
318 
319  if (axis != -1) {
320  glutIdleFunc(GfuiIdle);
321  InputWaited = 0;
323  cmd->ref.index = axis;
324  const char *str = GfctrlGetNameByRef(GFCTRL_TYPE_JOY_AXIS, axis);
325  GfuiButtonSetText (scrHandle, cmd->Id, str);
326  glutPostRedisplay();
327  return true;
328  }
329 
330  return false;
331 }
332 
333 
334 static void Idle(void)
335 {
336  int i;
337  int index;
338  const char *str;
339 
341 
342  /* Check for a mouse button pressed */
343  for (i = 0; i < 3; i++) {
344  if (mouseInfo.edgedn[i]) {
345  glutIdleFunc(GfuiIdle);
346  InputWaited = 0;
348  CurrentCmd->ref.index = i;
351  glutPostRedisplay();
352  return;
353  }
354  }
355 
356  /* Check for a mouse axis moved */
357  for (i = 0; i < 4; i++) {
358  if (mouseInfo.ax[i] > 20.0) {
359  glutIdleFunc(GfuiIdle);
360  InputWaited = 0;
362  CurrentCmd->ref.index = i;
365  glutPostRedisplay();
366  return;
367  }
368  }
369 
370  int b[NUM_JOY] = {0};
371  for (index = 0; index < NUM_JOY; index++) {
372  if (js[index]) {
373  js[index]->read(&b[index], &ax[index * _JS_MAX_AXES]);
374  }
375  }
376 
378  const double delay = 0.2;
379  double currentTime = GfTimeClock();
380 
381  if (!checkJoystickMovedAxis(CurrentCmd) && (currentTime - axisPressedTime > delay)) {
382  if (axisPressedTime == 0.0) {
383  if (checkJoystickButtonPressed(CurrentCmd, b, true)) {
384  axisPressedTime = currentTime;
385  }
386  } else {
388  }
389  }
390  } else {
391  if (!checkJoystickButtonPressed(CurrentCmd, b, false)) {
393  }
394  }
395 }
396 
397 
398 static void onPush(void *vi)
399 {
400  int index;
401 
402  CurrentCmd = (tCmdInfo*) vi;
404  CurrentCmd->ref.index = -1;
407 
409  InputWaited = 1;
410  }
411 
412  axisPressedTime = 0.0;
413 
414  glutIdleFunc(Idle);
416  memset(&mouseInfo, 0, sizeof(mouseInfo));
418 
419  for (index = 0; index < NUM_JOY; index++) {
420  if (js[index]) {
421  js[index]->read(&rawb[index], &ax[index * _JS_MAX_AXES]); /* initial value */
422  }
423  }
424  memcpy(axCenter, ax, sizeof(axCenter));
425 }
426 
427 
428 static void onActivate(void * /* dummy */)
429 {
430  int cmd;
431  const char *prm;
432  const int BUFSIZE = 1024;
433  char buf[BUFSIZE];
434 
435 
436  if (ReloadValues) {
437  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
439 
440  for (cmd = 0; cmd < maxCmd; cmd++) {
441  prm = GfctrlGetNameByRef(Cmd[cmd].ref.type, Cmd[cmd].ref.index);
442  if (!prm) {
443  prm = "---";
444  }
445 
446  prm = GfParmGetStr(PrefHdle, HM_SECT_MOUSEPREF, Cmd[cmd].name, prm);
447  prm = GfParmGetStr(PrefHdle, CurrentSection, Cmd[cmd].name, prm);
448  GfctrlGetRefByName(prm, &Cmd[cmd].ref);
449 
450  if (Cmd[cmd].minName) {
451  Cmd[cmd].min = GfParmGetNum(PrefHdle, GfctrlGetDefaultSection(Cmd[cmd].ref.type), Cmd[cmd].minName, NULL, Cmd[cmd].min);
452  Cmd[cmd].min = GfParmGetNum(PrefHdle, CurrentSection, Cmd[cmd].minName, NULL, Cmd[cmd].min);
453  }
454 
455  if (Cmd[cmd].maxName) {
456  Cmd[cmd].max = GfParmGetNum(PrefHdle, GfctrlGetDefaultSection(Cmd[cmd].ref.type), Cmd[cmd].maxName, NULL, Cmd[cmd].max);
457  Cmd[cmd].max = GfParmGetNum(PrefHdle, CurrentSection, Cmd[cmd].maxName, NULL, Cmd[cmd].max);
458  }
459 
460  if (Cmd[cmd].powName) {
461  Cmd[cmd].pow = GfParmGetNum(PrefHdle, GfctrlGetDefaultSection(Cmd[cmd].ref.type), Cmd[cmd].powName, NULL, Cmd[cmd].pow);
462  Cmd[cmd].pow = GfParmGetNum(PrefHdle, CurrentSection, Cmd[cmd].powName, NULL, Cmd[cmd].pow);
463  }
464  }
465 
466  int i;
467  for (i = 0; i < nbEditboxValues; i++) {
470  }
471  }
472 
473  // Update GUI after calibration to avoid nonsense values (inefficient)
474  for (cmd = 0; cmd < maxCmd; cmd++) {
475  if (strcmp(Cmd[cmd].name, HM_ATT_LEFTSTEER) == 0) {
477  }
478  if (strcmp(Cmd[cmd].name, HM_ATT_BRAKE) == 0) {
480  }
481  }
482 
484 }
485 
486 static void DevCalibrate(void *menu)
487 {
488  ReloadValues = 0;
489  GfuiScreenActivate(menu);
490 }
491 
492 
493 void * TorcsControlMenuInit(void *prevMenu, int idx)
494 {
495  int x, y, x2, dy, i;
496  int index;
497  const int BUFSIZE = 1024;
498  char buf[BUFSIZE];
499 
500  ReloadValues = 1;
501  snprintf(CurrentSection, CURRENTSECTIONSIZE, "%s/%d", HM_SECT_DRVPREF, idx);
502 
503  prevHandle = prevMenu;
504  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
506 
507  if (scrHandle) {
508  return scrHandle;
509  }
510 
511  for (index = 0; index < NUM_JOY; index++) {
512  if (js[index] == NULL) {
513  js[index] = new jsJoystick(index);
514  }
515 
516  if (js[index]->notWorking()) {
517  /* don't configure the joystick */
518  js[index] = NULL;
519  }
520  }
521 
522  scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, onActivate, NULL, (tfuiCallback)NULL, 1);
523  GfuiTitleCreate(scrHandle, "Control Configuration", 0);
524 
525  GfuiScreenAddBgImg(scrHandle, "data/img/splash-mouseconf.png");
526 
528 
529  x = 10;
530  x2 = 210;
531  y = 405;
532  dy = 30;
533 
534  for (i = 0; i < maxCmd; i++) {
536  Cmd[i].Id = GfuiButtonStateCreate (scrHandle, "MOUSE_MIDDLE_BUTTON", GFUI_FONT_MEDIUM_C, x+x2, y, 0, GFUI_ALIGN_HC_VB, GFUI_MOUSE_DOWN,
537  (void*)&Cmd[i], onPush, NULL, (tfuiCallback)NULL, onFocusLost);
538  y -= dy;
539  if (i == (maxCmd / 2 - 1)) {
540  x = 320;
541  y = 405;
542  x2 = 220;
543  }
544  }
545 
546  int y0 = 165;
547 
548  for (i = 0; i < nbEditboxValues; i++) {
549  y = y0 - (i%4)*dy;
551  editBoxValues[i].id = GfuiEditboxCreate(scrHandle, "", GFUI_FONT_MEDIUM_C, 10 + (i/4*310) + 190, y, 80, 6, &editBoxValues[i], (tfuiCallback)NULL, onValueChange);
552  }
553 
554  GfuiAddKey(scrHandle, 13, "Save", NULL, onSave, NULL);
556  scrHandle, "Save", GFUI_FONT_LARGE, 160, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
557  NULL, onSave, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL
558  );
559 
561  scrHandle, "Calibrate", GFUI_FONT_LARGE, 320, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
563  );
564 
566  scrHandle, "Calibrate", GFUI_FONT_LARGE, 320, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
568  );
569 
570  GfuiAddKey(scrHandle, 27, "Cancel", prevMenu, GfuiScreenActivate, NULL);
572  scrHandle, "Cancel", GFUI_FONT_LARGE, 480, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
573  prevMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL
574  );
575 
578 
579  return scrHandle;
580 }
#define HM_ATT_LEFTSTEER
Definition: playerpref.h:69
#define HM_ATT_CLUTCH_POW
Definition: playerpref.h:99
static int MouseCalButton
int GfctrlMouseGetCurrent(tCtrlMouseInfo *mouseInfo)
Get the mouse current values.
Definition: control.cpp:427
#define HM_ATT_CLUTCH_MAX
Definition: playerpref.h:97
int GfParmSetStr(void *handle, const char *path, const char *key, const char *val)
Set a string parameter in the parameter set handle.
Definition: params.cpp:2477
char * GfuiEditboxGetString(void *scr, int id)
Get the string.
Definition: guiedit.cpp:358
#define HM_ATT_DN_SHFT
Definition: playerpref.h:37
int GfuiButtonStateCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a state button to a screen.
Definition: guibutton.cpp:188
#define GFUI_MOUSE_UP
Definition: tgfclient.h:80
#define HM_ATT_UP_SHFT
Definition: playerpref.h:36
static EditboxValue editBoxValues[]
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
Definition: params.cpp:1157
static int getMovedAxis(void)
static int ReloadValues
static tCmdInfo * CurrentCmd
#define HM_ATT_STEER_SENS
Definition: playerpref.h:64
int GfuiButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a button to a screen.
Definition: guibutton.cpp:248
Scalar max(Scalar x, Scalar y)
Definition: Basic.h:50
float min
Definition: controlconfig.h:38
#define GFPARM_RMODE_STD
if handle already openned return it
Definition: tgf.h:265
bool GfctrlIsEventBlacklisted(void *parmHandle, const char *driversSection, const char *event)
Check if given event is blacklisted (used for buttons or axis which fire a button AND move event)...
Definition: control.cpp:502
static void onValueChange(void *v)
static void * PrefHdle
static float ax[_JS_MAX_AXES *NUM_JOY]
int edgedn[3]
Button transition from up to down.
Definition: tgfclient.h:297
static const int nbEditboxValues
#define HM_ATT_RIGHTSTEER_POW
Definition: playerpref.h:78
static void * scrHandle
const char * label
#define HM_ATT_BRAKE_MAX
Definition: playerpref.h:90
char * GetLocalDir(void)
Definition: tgf.cpp:231
#define HM_ATT_THROTTLE
Definition: playerpref.h:81
#define HM_ATT_THROTTLE_POW
Definition: playerpref.h:85
void GfuiAddKey(void *scr, unsigned char key, const char *descr, void *userData, tfuiCallback onKeyPressed, tfuiCallback onKeyReleased)
Add a Keyboard callback to a screen.
Definition: gui.cpp:742
Robot Module Interface Definition.
#define HM_ATT_THROTTLE_MAX
Definition: playerpref.h:83
int GfuiLabelCreate(void *scr, const char *text, int font, int x, int y, int align, int maxlen)
Add a label to a screen.
Definition: guilabel.cpp:142
static tCtrlMouseInfo mouseInfo
const char * maxName
Definition: controlconfig.h:39
#define HM_ATT_CLUTCH_SENS
Definition: playerpref.h:98
int GfuiEditboxCreate(void *scr, const char *text, int font, int x, int y, int width, int maxlen, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost, int margin)
Add a editbox to a screen.
Definition: guiedit.cpp:57
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
Definition: gui.cpp:961
#define HM_ATT_ASR_CMD
Definition: playerpref.h:38
#define HM_ATT_BRAKE
Definition: playerpref.h:88
static float axCenter[_JS_MAX_AXES *NUM_JOY]
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition: params.cpp:1610
static int maxCmd
void GfuiIdle(void)
Idle function for the GUI to be called during Idle loop of glut.
Definition: gui.cpp:116
static void onPush(void *vi)
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
Definition: params.cpp:2311
#define HM_ATT_LEFTSTEER_MAX
Definition: playerpref.h:71
const char * key
GfCtrlType type
Definition: tgfclient.h:267
void GfuiSKeyEventRegister(void *scr, tfuiSKeyCallback onSKeyAction)
Definition: gui.cpp:711
The Gaming Framework API (client part).
void GfuiKeyEventRegister(void *scr, tfuiKeyCallback onKeyAction)
Definition: gui.cpp:702
#define HM_ATT_LEFTSTEER_MIN
Definition: playerpref.h:70
static const int IDX_BRAKE_POW
static int InputWaited
#define HM_ATT_BRAKE_MIN
Definition: playerpref.h:89
#define HM_ATT_LIGHT1_CMD
Definition: playerpref.h:44
#define GFUI_FONT_LARGE
Definition: tgfclient.h:168
static void DevCalibrate(void *menu)
const char * minName
Definition: controlconfig.h:37
void GfuiButtonSetText(void *scr, int id, const char *text)
Change the label of a button.
Definition: guibutton.cpp:357
void * GfuiScreenCreateEx(float *bgColor, void *userDataOnActivate, tfuiCallback onActivate, void *userDataOnDeactivate, tfuiCallback onDeactivate, int mouseAllowed)
Create a screen.
Definition: gui.cpp:578
static const int CURRENTSECTIONSIZE
#define HM_ATT_RIGHTSTEER
Definition: playerpref.h:75
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
Definition: guiedit.cpp:383
#define HM_ATT_BRAKE_SENS
Definition: playerpref.h:91
#define HM_SECT_DRVPREF
Definition: playerpref.h:34
static char CurrentSection[CURRENTSECTIONSIZE]
static void onSave(void *)
const char * GfctrlGetDefaultSection(GfCtrlType type)
Definition: control.cpp:284
static void onActivate(void *)
const char * GfctrlGetNameByRef(GfCtrlType type, int index)
Get a control name by its reference.
Definition: control.cpp:191
#define HM_ATT_STEER_SPD
Definition: playerpref.h:66
static void onFocusLost(void *)
void * JoyCalMenuInit(void *prevMenu, tCmdInfo *cmd, int maxcmd, void *parmhandle, const char *driversection)
static int JoyCalButton
#define GFUI_KEY_UP
Definition: tgfclient.h:84
static tCmdInfo Cmd[]
int keyboardPossible
Definition: controlconfig.h:43
static void updateButtonText(void)
static jsJoystick * js[NUM_JOY]
static bool isAxisPreffered(tCmdInfo *cmd)
void GfuiMenuDefaultKeysAdd(void *scr)
Add the default menu keyboard callback to a screen.
Definition: guimenu.cpp:55
void * MouseCalMenuInit(void *prevMenu, tCmdInfo *cmd, int maxcmd)
const char * powName
Definition: controlconfig.h:41
#define HM_ATT_THROTTLE_SENS
Definition: playerpref.h:84
#define HM_ATT_THROTTLE_MIN
Definition: playerpref.h:82
#define HM_ATT_GEAR_R
Definition: playerpref.h:49
#define HM_SECT_MOUSEPREF
Definition: playerpref.h:31
float max
Definition: controlconfig.h:40
void(* tfuiCallback)(void *)
Definition: tgfclient.h:105
void GfctrlMouseInitCenter(void)
Get the reference position.
Definition: control.cpp:489
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition: gui.cpp:467
#define GFUI_INVISIBLE
Object invisibility flag.
Definition: tgfclient.h:159
#define HM_ATT_BRAKE_TOREAR
Definition: playerpref.h:42
tCtrlRef ref
Definition: controlconfig.h:35
int GfParmSetNum(void *handle, const char *path, const char *key, const char *unit, tdble val)
Set a numerical parameter in the parameter set handle.
Definition: params.cpp:2586
#define GFUI_ALIGN_HC_VB
Definition: tgfclient.h:72
void GfctrlGetRefByName(const char *name, tCtrlRef *ref)
Get a control reference by its name.
Definition: control.cpp:123
#define GFUI_ALIGN_HL_VB
Definition: tgfclient.h:69
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Definition: params.cpp:2392
double GfTimeClock(void)
Get the time in seconds.
Definition: os.cpp:50
Scalar min(Scalar x, Scalar y)
Definition: Basic.h:49
static Vector y[4]
Definition: Convex.cpp:56
#define HM_ATT_GEAR_N
Definition: playerpref.h:50
#define HM_ATT_RIGHTSTEER_MIN
Definition: playerpref.h:76
static const int IDX_LEFTSTEER_POW
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
Definition: guilabel.cpp:170
static void Idle(void)
#define HM_ATT_LEFTSTEER_POW
Definition: playerpref.h:72
const char * name
Definition: controlconfig.h:34
void * TorcsControlMenuInit(void *prevMenu, int idx)
#define HM_ATT_BRAKE_POW
Definition: playerpref.h:92
#define GFUI_FONT_MEDIUM_C
Definition: tgfclient.h:173
static int onKeyAction(unsigned char key, int, int state)
Mouse information structure.
Definition: tgfclient.h:294
#define HM_PREF_FILE
Definition: playerpref.h:28
#define GFUI_FONT_MEDIUM
Definition: tgfclient.h:169
#define HM_ATT_ABS_CMD
Definition: playerpref.h:39
#define HM_ATT_SPDLIM_CMD
Definition: playerpref.h:45
static bool checkJoystickButtonPressed(tCmdInfo *cmd, int b[], bool checkOnly)
float ax[4]
mouse axis position (mouse considered as a joystick)
Definition: tgfclient.h:299
static double axisPressedTime
int index
Definition: tgfclient.h:266
int GfuiVisibilitySet(void *scr, int id, int visible)
Set/unset the visibility attribute of an object.
Definition: guiobject.cpp:404
Track Structure and Track Loader Module Definition.
#define HM_ATT_STEER_DEAD
Definition: playerpref.h:67
#define HM_ATT_RIGHTSTEER_MAX
Definition: playerpref.h:77
#define HM_ATT_BRAKE_TOFRONT
Definition: playerpref.h:41
#define GFUI_VISIBLE
Object visibility flag.
Definition: tgfclient.h:158
#define GFPARM_RMODE_CREAT
Create the file if doesn&#39;t exist.
Definition: tgf.h:267
static bool checkJoystickMovedAxis(tCmdInfo *cmd)
#define NUM_JOY
Definition: tgfclient.h:35
static int onSKeyAction(int key, int, int state)
#define HM_ATT_CLUTCH
Definition: playerpref.h:95
float pow
Definition: controlconfig.h:42
static int rawb[NUM_JOY]
static void * prevHandle
#define GFUI_MOUSE_DOWN
Definition: tgfclient.h:81
#define HM_ATT_CLUTCH_MIN
Definition: playerpref.h:96