Bug #826 - fixes multiple human players using keyboard
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5509 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: f9c32313f2a86e5623042331ac7aca355ef93380 Former-commit-id: 1b9516c4aff57a8174b3824e530ac0252e30c90e
This commit is contained in:
parent
c5cc58c8be
commit
0b1affdd95
2 changed files with 16 additions and 4 deletions
|
@ -95,6 +95,7 @@ static int lastReadKeyState[GFUIK_MAX+1];
|
||||||
static tKeyInfo keyInfo[GFUIK_MAX+1];
|
static tKeyInfo keyInfo[GFUIK_MAX+1];
|
||||||
|
|
||||||
static bool firstTime = false;
|
static bool firstTime = false;
|
||||||
|
static int resumeIndex = 0;
|
||||||
static tdble lastKeyUpdate = -10.0;
|
static tdble lastKeyUpdate = -10.0;
|
||||||
|
|
||||||
void *PrefHdle = NULL;
|
void *PrefHdle = NULL;
|
||||||
|
@ -146,6 +147,8 @@ shutdown(const int index)
|
||||||
GfuiKeyEventRegisterCurrent(0);
|
GfuiKeyEventRegisterCurrent(0);
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
}//if firstTime
|
}//if firstTime
|
||||||
|
|
||||||
|
resumeIndex = 0;
|
||||||
}//shutdown
|
}//shutdown
|
||||||
|
|
||||||
|
|
||||||
|
@ -614,8 +617,13 @@ resumerace(int index, tCarElt* car, tSituation *s)
|
||||||
HmReadPrefs(index);
|
HmReadPrefs(index);
|
||||||
|
|
||||||
// Setup Keyboard map (key code => index of the associated command in keyInfo / lastReadKeyState).
|
// Setup Keyboard map (key code => index of the associated command in keyInfo / lastReadKeyState).
|
||||||
keyIndex = 0;
|
if (index > resumeIndex) {
|
||||||
mapKeys.clear();
|
// must be first time after start/resume (index counts down)
|
||||||
|
GfOut("Clearing Keyboard map (index %d)\n", index);
|
||||||
|
keyIndex = 0;
|
||||||
|
mapKeys.clear();
|
||||||
|
}
|
||||||
|
resumeIndex = index;
|
||||||
|
|
||||||
for (int i = 0; i < NbCmdControl; i++)
|
for (int i = 0; i < NbCmdControl; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,11 @@ HmReadPrefs(const int index)
|
||||||
const int idx = index - 1;
|
const int idx = index - 1;
|
||||||
tControlCmd *cmdCtrl;
|
tControlCmd *cmdCtrl;
|
||||||
|
|
||||||
cmdCtrl = HCtx[idx]->cmdControl = (tControlCmd *) calloc (NbCmdControl, sizeof (tControlCmd));
|
if (HCtx[idx]->cmdControl == NULL) {
|
||||||
|
GfOut("malloc control array index %d:\n", index);
|
||||||
|
HCtx[idx]->cmdControl = (tControlCmd *) calloc (NbCmdControl, sizeof (tControlCmd));
|
||||||
|
}
|
||||||
|
cmdCtrl = HCtx[idx]->cmdControl;
|
||||||
memcpy(cmdCtrl, CmdControlRef, NbCmdControl * sizeof (tControlCmd));
|
memcpy(cmdCtrl, CmdControlRef, NbCmdControl * sizeof (tControlCmd));
|
||||||
|
|
||||||
sprintf(sstring, "%s%s", GfLocalDir(), HM_PREF_FILE);
|
sprintf(sstring, "%s%s", GfLocalDir(), HM_PREF_FILE);
|
||||||
|
@ -128,7 +132,7 @@ HmReadPrefs(const int index)
|
||||||
defaultSettings = controlList[i].settings;
|
defaultSettings = controlList[i].settings;
|
||||||
|
|
||||||
/* Command Settings */
|
/* Command Settings */
|
||||||
GfOut("Command settings :\n");
|
GfOut("Command settings for index %d:\n", index);
|
||||||
for (int cmd = 0; cmd < NbCmdControl; cmd++) {
|
for (int cmd = 0; cmd < NbCmdControl; cmd++) {
|
||||||
|
|
||||||
prm = GfctrlGetNameByRef(cmdCtrl[cmd].type, cmdCtrl[cmd].val);
|
prm = GfctrlGetNameByRef(cmdCtrl[cmd].type, cmdCtrl[cmd].val);
|
||||||
|
|
Loading…
Reference in a new issue