shithub: choc

Download patch

ref: 7ebeb39398f0e7fbdda6393ef2a251b0f2a42f54
parent: f6d6e5fc7b00c79382416a99d7e7548d7dd71185
author: Simon Howard <fraggle@gmail.com>
date: Fri Mar 9 17:20:28 EST 2007

Partially revert the last change. I'm going with a mixed approach for
handling key mappings. Chocolate Doom will use the original (broken)
Doom behavior, in that keys will be unmapped. A German user will have to
type "IDMZPOS", for example. However, when actually entering text, for
savegame names and multiplayer chat, the mapped character will be used.
The reasoning here is that Vanilla users will be used to pressing the
wrong keys, but it can never be desirable to use the wrong mappings when
typing in text.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 848

--- a/src/am_map.c
+++ b/src/am_map.c
@@ -706,7 +706,7 @@
 	    cheatstate=0;
 	    rc = false;
 	}
-	if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data2))
+	if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1))
 	{
 	    rc = false;
 	    cheating = (cheating+1) % 3;
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -1406,17 +1406,10 @@
     static  int     mousex = 0;
     static  int     lastx = 0;
 	
-    // 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;
+    // key is the key pressed, ch is the actual character typed
+  
     ch = 0;
+    key = -1;
 	
     if (ev->type == ev_joystick && joywait < I_GetTime())
     {
@@ -1498,11 +1491,13 @@
 	    }
 	}
 	else
+	{
 	    if (ev->type == ev_keydown)
 	    {
 		key = ev->data1;
-                ch = ev->data2;
+		ch = ev->data2;
 	    }
+	}
     }
     
     if (key == -1)
@@ -1547,11 +1542,14 @@
 	    break;
 				
 	  default:
-	    ch = toupper(ch);
-	    if (ch != ' ')
+	    // Entering a character - use the 'ch' value, not the key
+
+            ch = toupper(ch);
+
+            if (ch != ' '
+             && (ch - HU_FONTSTART < 0 || ch - HU_FONTSTART >= HU_FONTSIZE))
             {
-		if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE)
-		    break;
+                break;
             }
 
 	    if (ch >= 32 && ch <= 127 &&
@@ -1560,7 +1558,7 @@
 		(SAVESTRINGSIZE-2)*8)
 	    {
 		savegamestrings[saveSlot][saveCharIndex++] = ch;
-		savegamestrings[saveSlot][saveCharIndex] = '\0';
+		savegamestrings[saveSlot][saveCharIndex] = 0;
 	    }
 	    break;
 	}
@@ -1571,13 +1569,13 @@
     if (messageToPrint)
     {
 	if (messageNeedsInput == true &&
-	    !(ch == ' ' || ch == 'n' || ch == 'y' || key == KEY_ESCAPE))
+	    !(key == ' ' || key == 'n' || key == 'y' || key == KEY_ESCAPE))
 	    return false;
 		
 	menuactive = messageLastMenuActive;
 	messageToPrint = 0;
 	if (messageRoutine)
-	    messageRoutine(ch);
+	    messageRoutine(key);
 			
 	menuactive = false;
 	S_StartSound(NULL,sfx_swtchx);
@@ -1771,7 +1769,7 @@
 	
       default:
 	for (i = itemOn+1;i < currentMenu->numitems;i++)
-	    if (currentMenu->menuitems[i].alphaKey == ch)
+	    if (currentMenu->menuitems[i].alphaKey == key)
 	    {
 		itemOn = i;
 		S_StartSound(NULL,sfx_pstop);
@@ -1778,7 +1776,7 @@
 		return true;
 	    }
 	for (i = 0;i <= itemOn;i++)
-	    if (currentMenu->menuitems[i].alphaKey == ch)
+	    if (currentMenu->menuitems[i].alphaKey == key)
 	    {
 		itemOn = i;
 		S_StartSound(NULL,sfx_pstop);
--- a/src/st_stuff.c
+++ b/src/st_stuff.c
@@ -474,7 +474,7 @@
     if (!netgame && gameskill != sk_nightmare)
     {
       // 'dqd' cheat for toggleable god mode
-      if (cht_CheckCheat(&cheat_god, ev->data2))
+      if (cht_CheckCheat(&cheat_god, ev->data1))
       {
 	plyr->cheats ^= CF_GODMODE;
 	if (plyr->cheats & CF_GODMODE)
@@ -489,7 +489,7 @@
 	  plyr->message = DEH_String(STSTR_DQDOFF);
       }
       // 'fa' cheat for killer fucking arsenal
-      else if (cht_CheckCheat(&cheat_ammonokey, ev->data2))
+      else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
       {
 	plyr->armorpoints = deh_idfa_armor;
 	plyr->armortype = deh_idfa_armor_class;
@@ -503,7 +503,7 @@
 	plyr->message = DEH_String(STSTR_FAADDED);
       }
       // 'kfa' cheat for key full ammo
-      else if (cht_CheckCheat(&cheat_ammo, ev->data2))
+      else if (cht_CheckCheat(&cheat_ammo, ev->data1))
       {
 	plyr->armorpoints = deh_idkfa_armor;
 	plyr->armortype = deh_idkfa_armor_class;
@@ -520,7 +520,7 @@
 	plyr->message = DEH_String(STSTR_KFAADDED);
       }
       // 'mus' cheat for changing music
-      else if (cht_CheckCheat(&cheat_mus, ev->data2))
+      else if (cht_CheckCheat(&cheat_mus, ev->data1))
       {
 	
 	char	buf[3];
@@ -549,9 +549,9 @@
 	}
       }
       else if ( (gamemission == doom 
-                 && cht_CheckCheat(&cheat_noclip, ev->data2))
+                 && cht_CheckCheat(&cheat_noclip, ev->data1))
              || (gamemission != doom 
-                 && cht_CheckCheat(&cheat_commercial_noclip,ev->data2)))
+                 && cht_CheckCheat(&cheat_commercial_noclip,ev->data1)))
       {	
         // Noclip cheat.
         // For Doom 1, use the idspipsopd cheat; for all others, use
@@ -567,7 +567,7 @@
       // 'behold?' power-up cheats
       for (i=0;i<6;i++)
       {
-	if (cht_CheckCheat(&cheat_powerup[i], ev->data2))
+	if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
 	{
 	  if (!plyr->powers[i])
 	    P_GivePower( plyr, i);
@@ -581,12 +581,12 @@
       }
       
       // 'behold' power-up menu
-      if (cht_CheckCheat(&cheat_powerup[6], ev->data2))
+      if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
       {
 	plyr->message = DEH_String(STSTR_BEHOLD);
       }
       // 'choppers' invulnerability & chainsaw
-      else if (cht_CheckCheat(&cheat_choppers, ev->data2))
+      else if (cht_CheckCheat(&cheat_choppers, ev->data1))
       {
 	plyr->weaponowned[wp_chainsaw] = true;
 	plyr->powers[pw_invulnerability] = true;
@@ -593,7 +593,7 @@
 	plyr->message = DEH_String(STSTR_CHOPPERS);
       }
       // 'mypos' for player position
-      else if (cht_CheckCheat(&cheat_mypos, ev->data2))
+      else if (cht_CheckCheat(&cheat_mypos, ev->data1))
       {
 	static char	buf[ST_MSGWIDTH];
 	sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
@@ -605,7 +605,7 @@
     }
     
     // 'clev' change-level cheat
-    if (cht_CheckCheat(&cheat_clev, ev->data2))
+    if (cht_CheckCheat(&cheat_clev, ev->data1))
     {
       char		buf[3];
       int		epsd;