TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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-2026 by Eric Espié 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
23
24
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
39static void *scrHandle = NULL;
40static void *prevHandle = NULL;
41static void *PrefHdle = NULL;
42
43static int MouseCalButton;
44static int JoyCalButton;
45
47static const int CURRENTSECTIONSIZE = 256;
49
50static 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
68static int maxCmd = sizeof(Cmd) / sizeof(Cmd[0]);
69
70static jsJoystick *js[NUM_JOY] = {NULL};
71static float ax[_JS_MAX_AXES * NUM_JOY] = {0};
72static float axCenter[_JS_MAX_AXES * NUM_JOY];
73static int rawb[NUM_JOY] = {0};
74static 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.
78static double axisPressedTime = 0.0;
79
80
81typedef struct {
82 const char *key;
83 const char *label;
84 int id;
85 float value;
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
99static const int IDX_LEFTSTEER_POW = 1; // Index for the list above
100static const int IDX_BRAKE_POW = 5; // Index for the list above
101static const int nbEditboxValues = sizeof(editBoxValues)/sizeof(editBoxValues[0]);
102
103
104static void onValueChange(EditboxValue* editBoxValue)
105{
106 float fv;
107 const int BUFSIZE = 10;
108 char buf[BUFSIZE];
109
110 char* val = GfuiEditboxGetString(scrHandle, editBoxValue->id);
111
112 if (sscanf(val, "%f", &fv) == 1) {
113 snprintf(buf, BUFSIZE, "%6.4f", fv);
114 editBoxValue->value = fv;
115 GfuiEditboxSetString(scrHandle, editBoxValue->id, buf);
116 } else {
117 GfuiEditboxSetString(scrHandle, editBoxValue->id, "");
118 }
119}
120
121
122static void onSave(void)
123{
124 int i;
125 const char *str;
126
127 // First write the command values
128 for (i = 0; i < maxCmd; i++) {
129 str = GfctrlGetNameByRef(Cmd[i].ref.type, Cmd[i].ref.index);
130 if (str) {
131 GfParmSetStr(PrefHdle, CurrentSection, Cmd[i].name, str);
132 } else {
134 }
135
136 if (Cmd[i].minName) {
137 GfParmSetNum(PrefHdle, CurrentSection, Cmd[i].minName, NULL, Cmd[i].min);
138 }
139
140 if (Cmd[i].maxName) {
141 GfParmSetNum(PrefHdle, CurrentSection, Cmd[i].maxName, NULL, Cmd[i].max);
142 }
143
144 if (Cmd[i].powName) {
145 GfParmSetNum(PrefHdle, CurrentSection, Cmd[i].powName, NULL, Cmd[i].pow);
146 }
147 }
148
149 // The editbox values must be written after the command values, otherwise the wrong "power" values are saved
150 for (i = 0; i < nbEditboxValues; i++) {
152 if (strcmp(HM_ATT_LEFTSTEER_POW, editBoxValues[i].key) == 0) {
153 GfParmSetNum(PrefHdle, CurrentSection, HM_ATT_RIGHTSTEER_POW, NULL, editBoxValues[i].value); // In GUI we set left == right
154 }
155 }
156
157 GfParmWriteFile(NULL, PrefHdle, "preferences");
159}
160
161
162static void updateButtonText(void)
163{
164 int i;
165 const char *str;
166 int displayMouseCal = GFUI_INVISIBLE;
167 int displayJoyCal = GFUI_INVISIBLE;
168 const int BUFSIZE = 1024;
169 char buf[BUFSIZE];
170
171 for (i = 0; i < maxCmd; i++) {
172 str = GfctrlGetNameByRef(Cmd[i].ref.type, Cmd[i].ref.index);
173 if (str) {
174 GfuiButtonSetText (scrHandle, Cmd[i].Id, str);
175 } else {
176 GfuiButtonSetText (scrHandle, Cmd[i].Id, "---");
177 }
178
179 if (Cmd[i].ref.type == GFCTRL_TYPE_MOUSE_AXIS) {
180 displayMouseCal = GFUI_VISIBLE;
181 } else if (Cmd[i].ref.type == GFCTRL_TYPE_JOY_AXIS) {
182 displayJoyCal = GFUI_VISIBLE;
183 }
184 }
185
186 for (i = 0; i < nbEditboxValues; i++) {
187 snprintf(buf, BUFSIZE, "%6.4f", editBoxValues[i].value);
189 }
190
191 GfuiVisibilitySet(scrHandle, MouseCalButton, displayMouseCal);
193}
194
195
196static void onFocusLost(void)
197{
199}
200
201
203
204static int InputWaited = 0;
205
206
207static int onKeyAction(unsigned char key, int /* modifier */, int state)
208{
209 const char *name;
210
211 if (!InputWaited || (state == GFUI_KEY_UP)) {
212 return 0;
213 }
214
215 if (key == 27) {
216 /* escape */
217 CurrentCmd->ref.index = -1;
220 } else {
222 CurrentCmd->ref.index = (int)key;
225 }
226
227 glutIdleFunc(GfuiIdle);
228 InputWaited = 0;
230 return 1;
231}
232
233
234static int onSKeyAction(int key, int /* modifier */, int state)
235{
236 const char *name;
237
238 if (!InputWaited || (state == GFUI_KEY_UP)) {
239 return 0;
240 }
241
243 CurrentCmd->ref.index = key;
246
247 glutIdleFunc(GfuiIdle);
248 InputWaited = 0;
250 return 1;
251}
252
253
254static int getMovedAxis(void)
255{
256 int i;
257 int Index = -1;
258 float maxDiff = 0.3;
259
260 for (i = 0; i < _JS_MAX_AXES * NUM_JOY; i++) {
261 if (maxDiff < fabs(ax[i] - axCenter[i])) {
262 maxDiff = fabs(ax[i] - axCenter[i]);
263 Index = i;
264 }
265 }
266
267 return Index;
268}
269
270
271// Returns true if the preferred input is an axis
272static bool isAxisPreffered(tCmdInfo* cmd) {
273 return strcmp(cmd->name, HM_ATT_LEFTSTEER) == 0
274 || strcmp(cmd->name, HM_ATT_RIGHTSTEER) == 0
275 || strcmp(cmd->name, HM_ATT_THROTTLE) == 0
276 || strcmp(cmd->name, HM_ATT_BRAKE) == 0
277 || strcmp(cmd->name, HM_ATT_CLUTCH) == 0;
278}
279
280
281static bool checkJoystickButtonPressed(tCmdInfo* cmd, int b[], bool checkOnly)
282{
283 int mask, i, index;
284
285 for (index = 0; index < NUM_JOY; index++) {
286 if (js[index]) {
287 /* Joystick buttons */
288 for (i = 0, mask = 1; i < 32; i++, mask *= 2) {
289 if (((b[index] & mask) != 0) && ((rawb[index] & mask) == 0)) {
290 /* Button i fired */
291 const char *str = GfctrlGetNameByRef(GFCTRL_TYPE_JOY_BUT, i + 32 * index);
293 if (checkOnly) {
294 return true;
295 }
296
297 glutIdleFunc(GfuiIdle);
298 InputWaited = 0;
299 cmd->ref.index = i + 32 * index;
301 GfuiButtonSetText (scrHandle, cmd->Id, str);
302 glutPostRedisplay();
303 rawb[index] = b[index];
304 return true;
305 }
306 }
307 }
308 }
309 rawb[index] = b[index];
310 }
311 return false;
312}
313
315{
316 int axis = getMovedAxis();
317
318 if (axis != -1) {
319 glutIdleFunc(GfuiIdle);
320 InputWaited = 0;
322 cmd->ref.index = axis;
323 const char *str = GfctrlGetNameByRef(GFCTRL_TYPE_JOY_AXIS, axis);
324 GfuiButtonSetText (scrHandle, cmd->Id, str);
325 glutPostRedisplay();
326 return true;
327 }
328
329 return false;
330}
331
332
333static void Idle(void)
334{
335 int i;
336 int index;
337 const char *str;
338
340
341 /* Check for a mouse button pressed */
342 for (i = 0; i < 3; i++) {
343 if (mouseInfo.edgedn[i]) {
344 glutIdleFunc(GfuiIdle);
345 InputWaited = 0;
347 CurrentCmd->ref.index = i;
350 glutPostRedisplay();
351 return;
352 }
353 }
354
355 /* Check for a mouse axis moved */
356 for (i = 0; i < 4; i++) {
357 if (mouseInfo.ax[i] > 20.0) {
358 glutIdleFunc(GfuiIdle);
359 InputWaited = 0;
361 CurrentCmd->ref.index = i;
364 glutPostRedisplay();
365 return;
366 }
367 }
368
369 int b[NUM_JOY] = {0};
370 for (index = 0; index < NUM_JOY; index++) {
371 if (js[index]) {
372 js[index]->read(&b[index], &ax[index * _JS_MAX_AXES]);
373 }
374 }
375
377 const double delay = 0.2;
378 double currentTime = GfTimeClock();
379
380 if (!checkJoystickMovedAxis(CurrentCmd) && (currentTime - axisPressedTime > delay)) {
381 if (axisPressedTime == 0.0) {
383 axisPressedTime = currentTime;
384 }
385 } else {
387 }
388 }
389 } else {
390 if (!checkJoystickButtonPressed(CurrentCmd, b, false)) {
392 }
393 }
394}
395
396
397static void onPush(tCmdInfo *cmdInfo)
398{
399 int index;
400
401 CurrentCmd = cmdInfo;
403 CurrentCmd->ref.index = -1;
406
407 if (CurrentCmd->keyboardPossible) {
408 InputWaited = 1;
409 }
410
411 axisPressedTime = 0.0;
412
413 glutIdleFunc(Idle);
415 memset(&mouseInfo, 0, sizeof(mouseInfo));
417
418 for (index = 0; index < NUM_JOY; index++) {
419 if (js[index]) {
420 js[index]->read(&rawb[index], &ax[index * _JS_MAX_AXES]); /* initial value */
421 }
422 }
423 memcpy(axCenter, ax, sizeof(axCenter));
424}
425
426
427static void onActivate(void)
428{
429 int cmd;
430 const char *prm;
431 const int BUFSIZE = 1024;
432 char buf[BUFSIZE];
433
434
435 if (ReloadValues) {
436 snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
438
439 for (cmd = 0; cmd < maxCmd; cmd++) {
440 prm = GfctrlGetNameByRef(Cmd[cmd].ref.type, Cmd[cmd].ref.index);
441 if (!prm) {
442 prm = "---";
443 }
444
445 prm = GfParmGetStr(PrefHdle, HM_SECT_MOUSEPREF, Cmd[cmd].name, prm);
446 prm = GfParmGetStr(PrefHdle, CurrentSection, Cmd[cmd].name, prm);
447 GfctrlGetRefByName(prm, &Cmd[cmd].ref);
448
449 if (Cmd[cmd].minName) {
450 Cmd[cmd].min = GfParmGetNum(PrefHdle, GfctrlGetDefaultSection(Cmd[cmd].ref.type), Cmd[cmd].minName, NULL, Cmd[cmd].min);
451 Cmd[cmd].min = GfParmGetNum(PrefHdle, CurrentSection, Cmd[cmd].minName, NULL, Cmd[cmd].min);
452 }
453
454 if (Cmd[cmd].maxName) {
455 Cmd[cmd].max = GfParmGetNum(PrefHdle, GfctrlGetDefaultSection(Cmd[cmd].ref.type), Cmd[cmd].maxName, NULL, Cmd[cmd].max);
456 Cmd[cmd].max = GfParmGetNum(PrefHdle, CurrentSection, Cmd[cmd].maxName, NULL, Cmd[cmd].max);
457 }
458
459 if (Cmd[cmd].powName) {
460 Cmd[cmd].pow = GfParmGetNum(PrefHdle, GfctrlGetDefaultSection(Cmd[cmd].ref.type), Cmd[cmd].powName, NULL, Cmd[cmd].pow);
461 Cmd[cmd].pow = GfParmGetNum(PrefHdle, CurrentSection, Cmd[cmd].powName, NULL, Cmd[cmd].pow);
462 }
463 }
464
465 int i;
466 for (i = 0; i < nbEditboxValues; i++) {
469 }
470 }
471
472 // Update GUI after calibration to avoid nonsense values (inefficient)
473 for (cmd = 0; cmd < maxCmd; cmd++) {
474 if (strcmp(Cmd[cmd].name, HM_ATT_LEFTSTEER) == 0) {
475 editBoxValues[IDX_LEFTSTEER_POW].value = Cmd[cmd].pow;
476 }
477 if (strcmp(Cmd[cmd].name, HM_ATT_BRAKE) == 0) {
478 editBoxValues[IDX_BRAKE_POW].value = Cmd[cmd].pow;
479 }
480 }
481
483}
484
485static void DevCalibrate(void *menu)
486{
487 ReloadValues = 0;
488 GfuiScreenActivate(menu);
489}
490
491
492void * TorcsControlMenuInit(void *prevMenu, int idx)
493{
494 int x, y, x2, dy, i;
495 int index;
496 const int BUFSIZE = 1024;
497 char buf[BUFSIZE];
498
499 ReloadValues = 1;
500 snprintf(CurrentSection, CURRENTSECTIONSIZE, "%s/%d", HM_SECT_DRVPREF, idx);
501
502 prevHandle = prevMenu;
503 snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), HM_PREF_FILE);
505
506 if (scrHandle) {
507 return scrHandle;
508 }
509
510 for (index = 0; index < NUM_JOY; index++) {
511 if (js[index] == NULL) {
512 js[index] = new jsJoystick(index);
513 }
514
515 if (js[index]->notWorking()) {
516 /* don't configure the joystick */
517 js[index] = NULL;
518 }
519 }
520
522 GfuiTitleCreate(scrHandle, "Control Configuration", 0);
523
524 GfuiScreenAddBgImg(scrHandle, "data/img/splash-mouseconf.png");
525
527
528 x = 10;
529 x2 = 210;
530 y = 405;
531 dy = 30;
532
533 for (i = 0; i < maxCmd; i++) {
536 [i] { onPush(&Cmd[i]); }, tGfuiAction(), onFocusLost);
537 y -= dy;
538 if (i == (maxCmd / 2 - 1)) {
539 x = 320;
540 y = 405;
541 x2 = 220;
542 }
543 }
544
545 int y0 = 165;
546
547 for (i = 0; i < nbEditboxValues; i++) {
548 y = y0 - (i%4)*dy;
550 editBoxValues[i].id = GfuiEditboxCreateAction(scrHandle, "", GFUI_FONT_MEDIUM_C, 10 + (i/4*310) + 190, y, 80, 6,
551 tGfuiAction(), [i] { onValueChange(&editBoxValues[i]); });
552 }
553
558 );
559
560 void *mouseCalMenu = MouseCalMenuInit(scrHandle, Cmd, maxCmd);
562 scrHandle, "Calibrate", GFUI_FONT_LARGE, 320, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
563 [mouseCalMenu] { DevCalibrate(mouseCalMenu); }, tGfuiAction(), tGfuiAction()
564 );
565
568 scrHandle, "Calibrate", GFUI_FONT_LARGE, 320, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
569 [joyCalMenu] { DevCalibrate(joyCalMenu); }, tGfuiAction(), tGfuiAction()
570 );
571
572 GfuiAddKeyAction(scrHandle, 27, "Cancel", [prevMenu] { GfuiScreenActivate(prevMenu); }, tGfuiAction());
574 scrHandle, "Cancel", GFUI_FONT_LARGE, 480, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
575 [prevMenu] { GfuiScreenActivate(prevMenu); }, tGfuiAction(), tGfuiAction()
576 );
577
580
581 return scrHandle;
582}
Scalar min(Scalar x, Scalar y)
Definition Basic.h:49
Scalar max(Scalar x, Scalar y)
Definition Basic.h:50
static Vector y[4]
Definition Convex.cpp:56
const char * GfctrlGetDefaultSection(GfCtrlType type)
Definition control.cpp:284
static void * prevHandle
void * TorcsControlMenuInit(void *prevMenu, int idx)
static EditboxValue editBoxValues[]
static int onKeyAction(unsigned char key, int, int state)
static bool isAxisPreffered(tCmdInfo *cmd)
static int MouseCalButton
static int onSKeyAction(int key, int, int state)
static const int IDX_BRAKE_POW
static const int CURRENTSECTIONSIZE
static int rawb[NUM_JOY]
static jsJoystick * js[NUM_JOY]
static int getMovedAxis(void)
static void * scrHandle
static void onPush(tCmdInfo *cmdInfo)
static float axCenter[_JS_MAX_AXES *NUM_JOY]
static float ax[_JS_MAX_AXES *NUM_JOY]
static void * PrefHdle
static char CurrentSection[CURRENTSECTIONSIZE]
static void onActivate(void)
static int JoyCalButton
static void onFocusLost(void)
static int InputWaited
static void onValueChange(EditboxValue *editBoxValue)
static tCtrlMouseInfo mouseInfo
static tCmdInfo * CurrentCmd
static const int IDX_LEFTSTEER_POW
static bool checkJoystickMovedAxis(tCmdInfo *cmd)
static void DevCalibrate(void *menu)
static void onSave(void)
static int ReloadValues
static double axisPressedTime
static bool checkJoystickButtonPressed(tCmdInfo *cmd, int b[], bool checkOnly)
static void Idle(void)
static tCmdInfo Cmd[]
static const int nbEditboxValues
static void updateButtonText(void)
static int maxCmd
int GfctrlMouseGetCurrent(tCtrlMouseInfo *mouseInfo)
Get the mouse current values.
Definition control.cpp:425
void GfctrlGetRefByName(const char *name, tCtrlRef *ref)
Get a control reference by its name.
Definition control.cpp:123
const char * GfctrlGetNameByRef(GfCtrlType type, int index)
Get a control name by its reference.
Definition control.cpp:191
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:498
void GfctrlMouseInitCenter(void)
Get the reference position.
Definition control.cpp:485
void * GfuiScreenCreateExAction(float *bgColor, const tGfuiAction &onActivate, const tGfuiAction &onDeactivate, int mouseAllowed)
Create a screen.
Definition gui.cpp:619
void GfuiMenuDefaultKeysAdd(void *scr)
Add the default menu keyboard callback to a screen.
Definition guimenu.cpp:56
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
Definition guilabel.cpp:150
void GfuiAddKeyAction(void *scr, unsigned char key, const char *descr, const tGfuiAction &onKeyPressed, const tGfuiAction &onKeyReleased)
Add a Keyboard callback to a screen.
Definition gui.cpp:809
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
Definition gui.cpp:1058
int GfuiEditboxCreateAction(void *scr, const char *text, int font, int x, int y, int width, int maxlen, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost, int margin)
Add an edit box to a screen.
Definition guiedit.cpp:53
void GfuiIdle(void)
Process held-mouse-button repeat actions on the active screen.
Definition gui.cpp:152
int GfuiVisibilitySet(void *scr, int id, int visible)
Set/unset the visibility attribute of an object.
void GfuiButtonSetText(void *scr, int id, const char *text)
Change the label of a button.
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
Definition guiedit.cpp:390
char * GfuiEditboxGetString(void *scr, int id)
Get the current text of an edit box.
Definition guiedit.cpp:364
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:121
void GfuiKeyEventRegister(void *scr, tfuiKeyCallback onKeyAction)
Set the ordinary-key event interceptor for a screen.
Definition gui.cpp:769
int GfuiButtonStateCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Create a text button that toggles between pressed and released while focused.
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition gui.cpp:508
void GfuiSKeyEventRegister(void *scr, tfuiSKeyCallback onSKeyAction)
Set the special-key event interceptor for a screen.
Definition gui.cpp:778
int GfuiButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a button to a screen.
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:2453
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:2623
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:2534
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:2737
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition params.cpp:1732
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
Definition params.cpp:1173
void * JoyCalMenuInit(void *prevMenu, tCmdInfo *cmd, int maxcmd, void *parmhandle, const char *driversection)
void * MouseCalMenuInit(void *prevMenu, tCmdInfo *cmd, int maxcmd)
double GfTimeClock(void)
Get the time in seconds.
Definition os.cpp:50
#define HM_ATT_RIGHTSTEER
Definition playerpref.h:75
#define HM_ATT_LEFTSTEER_POW
Definition playerpref.h:72
#define HM_ATT_THROTTLE_MAX
Definition playerpref.h:83
#define HM_ATT_GEAR_R
Definition playerpref.h:49
#define HM_ATT_THROTTLE
Definition playerpref.h:81
#define HM_ATT_DN_SHFT
Definition playerpref.h:37
#define HM_ATT_BRAKE_TOREAR
Definition playerpref.h:42
#define HM_ATT_STEER_DEAD
Definition playerpref.h:67
#define HM_ATT_LEFTSTEER
Definition playerpref.h:69
#define HM_ATT_RIGHTSTEER_MAX
Definition playerpref.h:77
#define HM_ATT_BRAKE_POW
Definition playerpref.h:92
#define HM_ATT_STEER_SENS
Definition playerpref.h:64
#define HM_ATT_BRAKE_TOFRONT
Definition playerpref.h:41
#define HM_ATT_LIGHT1_CMD
Definition playerpref.h:44
#define HM_ATT_LEFTSTEER_MIN
Definition playerpref.h:70
#define HM_ATT_CLUTCH
Definition playerpref.h:95
#define HM_ATT_RIGHTSTEER_POW
Definition playerpref.h:78
#define HM_ATT_CLUTCH_MIN
Definition playerpref.h:96
#define HM_ATT_RIGHTSTEER_MIN
Definition playerpref.h:76
#define HM_ATT_GEAR_N
Definition playerpref.h:50
#define HM_ATT_BRAKE_MIN
Definition playerpref.h:89
#define HM_ATT_ASR_CMD
Definition playerpref.h:38
#define HM_ATT_UP_SHFT
Definition playerpref.h:36
#define HM_SECT_DRVPREF
Definition playerpref.h:34
#define HM_ATT_ABS_CMD
Definition playerpref.h:39
#define HM_ATT_CLUTCH_MAX
Definition playerpref.h:97
#define HM_PREF_FILE
Definition playerpref.h:28
#define HM_ATT_THROTTLE_SENS
Definition playerpref.h:84
#define HM_ATT_THROTTLE_MIN
Definition playerpref.h:82
#define HM_ATT_BRAKE_MAX
Definition playerpref.h:90
#define HM_ATT_LEFTSTEER_MAX
Definition playerpref.h:71
#define HM_ATT_BRAKE
Definition playerpref.h:88
#define HM_ATT_SPDLIM_CMD
Definition playerpref.h:45
#define HM_ATT_THROTTLE_POW
Definition playerpref.h:85
#define HM_SECT_MOUSEPREF
Definition playerpref.h:31
#define HM_ATT_CLUTCH_POW
Definition playerpref.h:99
#define HM_ATT_BRAKE_SENS
Definition playerpref.h:91
#define HM_ATT_STEER_SPD
Definition playerpref.h:66
#define HM_ATT_CLUTCH_SENS
Definition playerpref.h:98
const char * label
const char * key
tCtrlRef ref
const char * name
Mouse information structure.
Definition tgfclient.h:502
GfCtrlType type
Definition tgfclient.h:474
int index
Definition tgfclient.h:473
char * GetLocalDir(void)
Definition tgf.cpp:230
#define GFPARM_RMODE_CREAT
Allow an empty in-memory set on file-open failure; does not write a file.
Definition tgf.h:266
#define GFPARM_RMODE_STD
Return a new handle sharing cached data for this filename, if available.
Definition tgf.h:264
#define GFUI_FONT_LARGE
Definition tgfclient.h:248
#define GFUI_FONT_MEDIUM
Definition tgfclient.h:249
#define GFUI_KEY_UP
Definition tgfclient.h:86
#define GFUI_INVISIBLE
Object invisibility flag.
Definition tgfclient.h:239
@ GFCTRL_TYPE_MOUSE_AXIS
Definition tgfclient.h:467
@ GFCTRL_TYPE_JOY_AXIS
Definition tgfclient.h:463
@ GFCTRL_TYPE_KEYBOARD
Definition tgfclient.h:465
@ GFCTRL_TYPE_MOUSE_BUT
Definition tgfclient.h:466
@ GFCTRL_TYPE_SKEYBOARD
Definition tgfclient.h:468
@ GFCTRL_TYPE_JOY_BUT
Definition tgfclient.h:464
@ GFCTRL_TYPE_NOT_AFFECTED
Definition tgfclient.h:462
#define GFUI_MOUSE_DOWN
Definition tgfclient.h:83
#define GFUI_FONT_MEDIUM_C
Definition tgfclient.h:253
#define GFUI_ALIGN_HL_VB
Definition tgfclient.h:71
#define GFUI_MOUSE_UP
Definition tgfclient.h:82
std::function< void()> tGfuiAction
Definition tgfclient.h:107
#define GFUI_ALIGN_HC_VB
Definition tgfclient.h:74
#define GFUI_VISIBLE
Object visibility flag.
Definition tgfclient.h:238
#define NUM_JOY
Definition tgfclient.h:36