summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2007-03-09 12:56:45 +0000
committerSimon Howard2007-03-09 12:56:45 +0000
commitf6d6e5fc7b00c79382416a99d7e7548d7dd71185 (patch)
tree3d701332821b77c63c9b548c8442b91f45dc7f30 /src
parentc5a4f04bc21825a0bdd59bef804229389a7a4ce1 (diff)
downloadchocolate-doom-f6d6e5fc7b00c79382416a99d7e7548d7dd71185.tar.gz
chocolate-doom-f6d6e5fc7b00c79382416a99d7e7548d7dd71185.tar.bz2
chocolate-doom-f6d6e5fc7b00c79382416a99d7e7548d7dd71185.zip
Pay closer attention to keyboard mappings. In the menu code, distinguish
between keys pressed and characters typed, so that, for example, when the menu prompts "press 'y' to continue", it responds to the _character_ y being typed, not the key that is 'y' on an american keyboard being pressed. Do the same when reading cheats. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 847
Diffstat (limited to 'src')
-rw-r--r--src/am_map.c2
-rw-r--r--src/m_menu.c63
-rw-r--r--src/st_stuff.c22
3 files changed, 51 insertions, 36 deletions
diff --git a/src/am_map.c b/src/am_map.c
index 7ba71f5c..11f77c1e 100644
--- a/src/am_map.c
+++ b/src/am_map.c
@@ -706,7 +706,7 @@ AM_Responder
cheatstate=0;
rc = false;
}
- if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1))
+ if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data2))
{
rc = false;
cheating = (cheating+1) % 3;
diff --git a/src/m_menu.c b/src/m_menu.c
index 2abcc52c..1b9f8014 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -1397,6 +1397,7 @@ M_WriteText
boolean M_Responder (event_t* ev)
{
int ch;
+ int key;
int i;
static int joywait = 0;
static int mousewait = 0;
@@ -1405,40 +1406,50 @@ boolean M_Responder (event_t* ev)
static int mousex = 0;
static int lastx = 0;
- ch = -1;
+ // There is a distinction here between the typed character and the key
+ // pressed. 'key' is the key code, while 'ch' is the actual character
+ // typed. For an example, on a German QWERTZ keyboard, if 'z' is
+ // pressed, ch='z' but key='y' (the position it occupies on the
+ // "standard" american keyboard)
+ //
+ // When dealing with actual keys pressed, we must use key, but any time
+ // we want the actual character typed, we use ch.
+
+ key = -1;
+ ch = 0;
if (ev->type == ev_joystick && joywait < I_GetTime())
{
if (ev->data3 == -1)
{
- ch = KEY_UPARROW;
+ key = KEY_UPARROW;
joywait = I_GetTime() + 5;
}
else if (ev->data3 == 1)
{
- ch = KEY_DOWNARROW;
+ key = KEY_DOWNARROW;
joywait = I_GetTime() + 5;
}
if (ev->data2 == -1)
{
- ch = KEY_LEFTARROW;
+ key = KEY_LEFTARROW;
joywait = I_GetTime() + 2;
}
else if (ev->data2 == 1)
{
- ch = KEY_RIGHTARROW;
+ key = KEY_RIGHTARROW;
joywait = I_GetTime() + 2;
}
if (ev->data1&1)
{
- ch = KEY_ENTER;
+ key = KEY_ENTER;
joywait = I_GetTime() + 5;
}
if (ev->data1&2)
{
- ch = KEY_BACKSPACE;
+ key = KEY_BACKSPACE;
joywait = I_GetTime() + 5;
}
}
@@ -1449,13 +1460,13 @@ boolean M_Responder (event_t* ev)
mousey += ev->data3;
if (mousey < lasty-30)
{
- ch = KEY_DOWNARROW;
+ key = KEY_DOWNARROW;
mousewait = I_GetTime() + 5;
mousey = lasty -= 30;
}
else if (mousey > lasty+30)
{
- ch = KEY_UPARROW;
+ key = KEY_UPARROW;
mousewait = I_GetTime() + 5;
mousey = lasty += 30;
}
@@ -1463,37 +1474,38 @@ boolean M_Responder (event_t* ev)
mousex += ev->data2;
if (mousex < lastx-30)
{
- ch = KEY_LEFTARROW;
+ key = KEY_LEFTARROW;
mousewait = I_GetTime() + 5;
mousex = lastx -= 30;
}
else if (mousex > lastx+30)
{
- ch = KEY_RIGHTARROW;
+ key = KEY_RIGHTARROW;
mousewait = I_GetTime() + 5;
mousex = lastx += 30;
}
if (ev->data1&1)
{
- ch = KEY_ENTER;
+ key = KEY_ENTER;
mousewait = I_GetTime() + 15;
}
if (ev->data1&2)
{
- ch = KEY_BACKSPACE;
+ key = KEY_BACKSPACE;
mousewait = I_GetTime() + 15;
}
}
else
if (ev->type == ev_keydown)
{
- ch = ev->data1;
+ key = ev->data1;
+ ch = ev->data2;
}
}
- if (ch == -1)
+ if (key == -1)
return false;
// In testcontrols mode, none of the function keys should do anything
@@ -1501,7 +1513,7 @@ boolean M_Responder (event_t* ev)
if (testcontrols)
{
- if (ch == KEY_ESCAPE || ch == KEY_F10)
+ if (key == KEY_ESCAPE || key == KEY_F10)
{
I_Quit();
return true;
@@ -1513,7 +1525,7 @@ boolean M_Responder (event_t* ev)
// Save Game string input
if (saveStringEnter)
{
- switch(ch)
+ switch(key)
{
case KEY_BACKSPACE:
if (saveCharIndex > 0)
@@ -1536,16 +1548,19 @@ boolean M_Responder (event_t* ev)
default:
ch = toupper(ch);
- if (ch != 32)
+ if (ch != ' ')
+ {
if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE)
break;
+ }
+
if (ch >= 32 && ch <= 127 &&
saveCharIndex < SAVESTRINGSIZE-1 &&
M_StringWidth(savegamestrings[saveSlot]) <
(SAVESTRINGSIZE-2)*8)
{
savegamestrings[saveSlot][saveCharIndex++] = ch;
- savegamestrings[saveSlot][saveCharIndex] = 0;
+ savegamestrings[saveSlot][saveCharIndex] = '\0';
}
break;
}
@@ -1556,7 +1571,7 @@ boolean M_Responder (event_t* ev)
if (messageToPrint)
{
if (messageNeedsInput == true &&
- !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE))
+ !(ch == ' ' || ch == 'n' || ch == 'y' || key == KEY_ESCAPE))
return false;
menuactive = messageLastMenuActive;
@@ -1569,7 +1584,7 @@ boolean M_Responder (event_t* ev)
return true;
}
- if (devparm && ch == KEY_F1)
+ if (devparm && key == KEY_F1)
{
G_ScreenShot ();
return true;
@@ -1578,7 +1593,7 @@ boolean M_Responder (event_t* ev)
// F-Keys
if (!menuactive)
- switch(ch)
+ switch(key)
{
case KEY_MINUS: // Screen size down
if (automapactive || chat_on)
@@ -1669,7 +1684,7 @@ boolean M_Responder (event_t* ev)
// Pop-up menu?
if (!menuactive)
{
- if (ch == KEY_ESCAPE)
+ if (key == KEY_ESCAPE)
{
M_StartControlPanel ();
S_StartSound(NULL,sfx_swtchn);
@@ -1680,7 +1695,7 @@ boolean M_Responder (event_t* ev)
// Keys usable within menu
- switch (ch)
+ switch (key)
{
case KEY_DOWNARROW:
do
diff --git a/src/st_stuff.c b/src/st_stuff.c
index b8e636c5..b82504af 100644
--- a/src/st_stuff.c
+++ b/src/st_stuff.c
@@ -474,7 +474,7 @@ ST_Responder (event_t* ev)
if (!netgame && gameskill != sk_nightmare)
{
// 'dqd' cheat for toggleable god mode
- if (cht_CheckCheat(&cheat_god, ev->data1))
+ if (cht_CheckCheat(&cheat_god, ev->data2))
{
plyr->cheats ^= CF_GODMODE;
if (plyr->cheats & CF_GODMODE)
@@ -489,7 +489,7 @@ ST_Responder (event_t* ev)
plyr->message = DEH_String(STSTR_DQDOFF);
}
// 'fa' cheat for killer fucking arsenal
- else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
+ else if (cht_CheckCheat(&cheat_ammonokey, ev->data2))
{
plyr->armorpoints = deh_idfa_armor;
plyr->armortype = deh_idfa_armor_class;
@@ -503,7 +503,7 @@ ST_Responder (event_t* ev)
plyr->message = DEH_String(STSTR_FAADDED);
}
// 'kfa' cheat for key full ammo
- else if (cht_CheckCheat(&cheat_ammo, ev->data1))
+ else if (cht_CheckCheat(&cheat_ammo, ev->data2))
{
plyr->armorpoints = deh_idkfa_armor;
plyr->armortype = deh_idkfa_armor_class;
@@ -520,7 +520,7 @@ ST_Responder (event_t* ev)
plyr->message = DEH_String(STSTR_KFAADDED);
}
// 'mus' cheat for changing music
- else if (cht_CheckCheat(&cheat_mus, ev->data1))
+ else if (cht_CheckCheat(&cheat_mus, ev->data2))
{
char buf[3];
@@ -549,9 +549,9 @@ ST_Responder (event_t* ev)
}
}
else if ( (gamemission == doom
- && cht_CheckCheat(&cheat_noclip, ev->data1))
+ && cht_CheckCheat(&cheat_noclip, ev->data2))
|| (gamemission != doom
- && cht_CheckCheat(&cheat_commercial_noclip,ev->data1)))
+ && cht_CheckCheat(&cheat_commercial_noclip,ev->data2)))
{
// Noclip cheat.
// For Doom 1, use the idspipsopd cheat; for all others, use
@@ -567,7 +567,7 @@ ST_Responder (event_t* ev)
// 'behold?' power-up cheats
for (i=0;i<6;i++)
{
- if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
+ if (cht_CheckCheat(&cheat_powerup[i], ev->data2))
{
if (!plyr->powers[i])
P_GivePower( plyr, i);
@@ -581,19 +581,19 @@ ST_Responder (event_t* ev)
}
// 'behold' power-up menu
- if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
+ if (cht_CheckCheat(&cheat_powerup[6], ev->data2))
{
plyr->message = DEH_String(STSTR_BEHOLD);
}
// 'choppers' invulnerability & chainsaw
- else if (cht_CheckCheat(&cheat_choppers, ev->data1))
+ else if (cht_CheckCheat(&cheat_choppers, ev->data2))
{
plyr->weaponowned[wp_chainsaw] = true;
plyr->powers[pw_invulnerability] = true;
plyr->message = DEH_String(STSTR_CHOPPERS);
}
// 'mypos' for player position
- else if (cht_CheckCheat(&cheat_mypos, ev->data1))
+ else if (cht_CheckCheat(&cheat_mypos, ev->data2))
{
static char buf[ST_MSGWIDTH];
sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
@@ -605,7 +605,7 @@ ST_Responder (event_t* ev)
}
// 'clev' change-level cheat
- if (cht_CheckCheat(&cheat_clev, ev->data1))
+ if (cht_CheckCheat(&cheat_clev, ev->data2))
{
char buf[3];
int epsd;