git: 9front

Download patch

ref: 3c4e1c41471c56856044cf856390983bbd3ed04f
parent: d8191814dc53b608ce96fd7b7fca5c823e3e5b4c
author: cinap_lenrek <cinap_lenrek@localhost>
date: Fri May 27 15:42:14 EDT 2011

games/doom: remove key translation

--- a/sys/src/games/doom/d_event.h
+++ b/sys/src/games/doom/d_event.h
@@ -44,9 +44,9 @@
 typedef struct
 {
     evtype_t	type;
-    int		data1;		// keys / mouse/joystick buttons
-    int		data2;		// mouse/joystick x move
-    int		data3;		// mouse/joystick y move
+    int		data1;		// raw keys / mouse/joystick buttons
+    int		data2;		// composed key down, mouse/joystick x move
+    int		data3;		// raw key down, mouse/joystick y move
 } event_t;
 
  
--- a/sys/src/games/doom/hu_stuff.c
+++ b/sys/src/games/doom/hu_stuff.c
@@ -283,112 +283,6 @@
 };
 
 
-const char*	shiftxform;
-
-const char french_shiftxform[] =
-{
-    0,
-    1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
-    11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
-    21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
-    31,
-    ' ', '!', '"', '#', '$', '%', '&',
-    '"', // shift-'
-    '(', ')', '*', '+',
-    '?', // shift-,
-    '_', // shift--
-    '>', // shift-.
-    '?', // shift-/
-    '0', // shift-0
-    '1', // shift-1
-    '2', // shift-2
-    '3', // shift-3
-    '4', // shift-4
-    '5', // shift-5
-    '6', // shift-6
-    '7', // shift-7
-    '8', // shift-8
-    '9', // shift-9
-    '/',
-    '.', // shift-;
-    '<',
-    '+', // shift-=
-    '>', '?', '@',
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
-    'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
-    '[', // shift-[
-    '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
-    ']', // shift-]
-    '"', '_',
-    '\'', // shift-`
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
-    'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
-    '{', '|', '}', '~', 127
-
-};
-
-const char english_shiftxform[] =
-{
-
-    0,
-    1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
-    11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
-    21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
-    31,
-    ' ', '!', '"', '#', '$', '%', '&',
-    '"', // shift-'
-    '(', ')', '*', '+',
-    '<', // shift-,
-    '_', // shift--
-    '>', // shift-.
-    '?', // shift-/
-    ')', // shift-0
-    '!', // shift-1
-    '@', // shift-2
-    '#', // shift-3
-    '$', // shift-4
-    '%', // shift-5
-    '^', // shift-6
-    '&', // shift-7
-    '*', // shift-8
-    '(', // shift-9
-    ':',
-    ':', // shift-;
-    '<',
-    '+', // shift-=
-    '>', '?', '@',
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
-    'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
-    '[', // shift-[
-    '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
-    ']', // shift-]
-    '"', '_',
-    '\'', // shift-`
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
-    'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
-    '{', '|', '}', '~', 127
-};
-
-char frenchKeyMap[128]=
-{
-    0,
-    1,2,3,4,5,6,7,8,9,10,
-    11,12,13,14,15,16,17,18,19,20,
-    21,22,23,24,25,26,27,28,29,30,
-    31,
-    ' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!',
-    '0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?',
-    '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
-    'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_',
-    '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
-    'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127
-};
-
-char ForeignTranslation(unsigned char ch)
-{
-    return ch < 128 ? frenchKeyMap[ch] : ch;
-}
-
 void HU_Init(void)
 {
 
@@ -396,11 +290,6 @@
     int		j;
     char	buffer[9];
 
-    if (language == french)
-	shiftxform = french_shiftxform;
-    else
-	shiftxform = english_shiftxform;
-
     // load the heads-up font
     j = HU_FONTSTART;
     for (i=0;i<HU_FONTSIZE;i++)
@@ -546,8 +435,6 @@
 		    chat_dest[i] = c;
 		else
 		{
-		    if (c >= 'a' && c <= 'z')
-			c = (char) shiftxform[(unsigned char) c];
 		    rc = HUlib_keyInIText(&w_inputbuffer[i], c);
 		    if (rc && c == KEY_ENTER)
 		    {
@@ -622,7 +509,7 @@
     boolean		eatkey = false;
     static boolean	shiftdown = false;
     static boolean	altdown = false;
-    unsigned char 	c;
+    int			c;
     int			i;
     int			numplayers;
     
@@ -701,12 +588,15 @@
     }
     else
     {
-	c = ev->data1;
+	c = ev->data2;
+	if(c == -1)
+		return false;
+
 	// send a macro
 	if (altdown)
 	{
 	    c = c - '0';
-	    if (c > 9)
+	    if (c < 0 || c > 9)
 		return false;
 	    // fprintf(stderr, "got here\n");
 	    macromessage = chat_macros[c];
@@ -727,18 +617,10 @@
 	}
 	else
 	{
-	    if (language == french)
-		c = ForeignTranslation(c);
-	    if (shiftdown || (c >= 'a' && c <= 'z'))
-		c = shiftxform[c];
 	    eatkey = HUlib_keyInIText(&w_chat, c);
 	    if (eatkey)
 	    {
-		// static unsigned char buf[20]; // DEBUG
 		HU_queueChatChar(c);
-		
-		// sprintf(buf, "KEY: %d => %d", ev->data1, c);
-		//      plr->message = buf;
 	    }
 	    if (c == KEY_ENTER)
 	    {
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -179,13 +179,8 @@
 	case Kalt:
 		return KEY_RALT;
 
-	case KEY_MINUS:
-	case KEY_EQUALS:
-	case KEY_BACKSPACE:
-	case KEY_ESCAPE:
-	case KEY_TAB:
-		return r;
-
+	case Kbs:
+		return KEY_BACKSPACE;
 	case '\n':
 		return KEY_ENTER;
 
@@ -203,7 +198,6 @@
 	case KF|12:
 		return KEY_F1+(r-(KF|1));
 	}
-
 	if(r > 0x7f)
 		return 0;
 	return r;
@@ -231,8 +225,11 @@
 			s += chartorune(&r, s);
 			if(utfrune(buf2, r) == nil){
 				e.type = ev_keydown;
-				if(e.data1 = runetokey(r))
+				if(e.data1 = runetokey(r)){
+					e.data2 = *s == 0 ? e.data1 : -1;
+					e.data3 = *s ? e.data1 : -1;
 					D_PostEvent(&e);
+				}
 			}
 		}
 		s = buf2;
@@ -240,8 +237,11 @@
 			s += chartorune(&r, s);
 			if(utfrune(buf, r) == nil){
 				e.type = ev_keyup;
-				if(e.data1 = runetokey(r))
+				if(e.data1 = runetokey(r)){
+					e.data2 = -1;
+					e.data3 = -1;
 					D_PostEvent(&e);
+				}
 			}
 		}
 		strcpy(buf2, buf);
--- a/sys/src/games/doom/m_menu.c
+++ b/sys/src/games/doom/m_menu.c
@@ -1426,7 +1426,7 @@
 	else
 	    if (ev->type == ev_keydown)
 	    {
-		ch = ev->data1;
+		ch = ev->data2;
 	    }
     }
     
--- a/sys/src/games/doom/st_stuff.c
+++ b/sys/src/games/doom/st_stuff.c
@@ -543,7 +543,7 @@
       // if (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)
@@ -558,7 +558,7 @@
 	  plyr->message = 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 = 200;
 	plyr->armortype = 2;
@@ -572,7 +572,7 @@
 	plyr->message = 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 = 200;
 	plyr->armortype = 2;
@@ -589,7 +589,7 @@
 	plyr->message = 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];
@@ -619,8 +619,8 @@
       }
       // Simplified, accepting both "noclip" and "idspispopd".
       // no clipping mode cheat
-      else if ( cht_CheckCheat(&cheat_noclip, ev->data1) 
-		|| cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
+      else if ( cht_CheckCheat(&cheat_noclip, ev->data2) 
+		|| cht_CheckCheat(&cheat_commercial_noclip,ev->data2) )
       {	
 	plyr->cheats ^= CF_NOCLIP;
 	
@@ -632,7 +632,7 @@
       // '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);
@@ -646,12 +646,12 @@
       }
       
       // 'behold' power-up menu
-      if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
+      if (cht_CheckCheat(&cheat_powerup[6], ev->data2))
       {
 	plyr->message = 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;
@@ -658,7 +658,7 @@
 	plyr->message = 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)",
@@ -670,7 +670,7 @@
     }
     
     // 'clev' change-level cheat
-    if (cht_CheckCheat(&cheat_clev, ev->data1))
+    if (cht_CheckCheat(&cheat_clev, ev->data2))
     {
       char		buf[3];
       int		epsd;
--