summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-27 19:42:14 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-27 19:42:14 +0000
commite6d579525f0276c465c54b97be38b2173111f42a (patch)
treef59cb92c476f71c1e62904543ceab9952b3bce7d
parentaee28916b06c3ce47d68f76ef8d1fe7dc55f151a (diff)
downloadplan9front-e6d579525f0276c465c54b97be38b2173111f42a.tar.xz
games/doom: remove key translation
-rw-r--r--sys/src/games/doom/d_event.h6
-rw-r--r--sys/src/games/doom/hu_stuff.c130
-rw-r--r--sys/src/games/doom/i_video.c20
-rw-r--r--sys/src/games/doom/m_menu.c2
-rw-r--r--sys/src/games/doom/st_stuff.c22
5 files changed, 31 insertions, 149 deletions
diff --git a/sys/src/games/doom/d_event.h b/sys/src/games/doom/d_event.h
index feb578333..1a9717ae6 100644
--- a/sys/src/games/doom/d_event.h
+++ b/sys/src/games/doom/d_event.h
@@ -44,9 +44,9 @@ typedef enum
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;
diff --git a/sys/src/games/doom/hu_stuff.c b/sys/src/games/doom/hu_stuff.c
index 583fca054..55dea7b2e 100644
--- a/sys/src/games/doom/hu_stuff.c
+++ b/sys/src/games/doom/hu_stuff.c
@@ -283,112 +283,6 @@ char *mapnamest[] = // TNT WAD map names.
};
-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 @@ void HU_Init(void)
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 @@ void HU_Ticker(void)
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 HU_Responder(event_t *ev)
boolean eatkey = false;
static boolean shiftdown = false;
static boolean altdown = false;
- unsigned char c;
+ int c;
int i;
int numplayers;
@@ -701,12 +588,15 @@ boolean HU_Responder(event_t *ev)
}
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 @@ boolean HU_Responder(event_t *ev)
}
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)
{
diff --git a/sys/src/games/doom/i_video.c b/sys/src/games/doom/i_video.c
index 1f68f1389..dcf31a993 100644
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -179,13 +179,8 @@ runetokey(Rune r)
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 @@ runetokey(Rune r)
case KF|12:
return KEY_F1+(r-(KF|1));
}
-
if(r > 0x7f)
return 0;
return r;
@@ -231,8 +225,11 @@ kbdproc(void *)
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 @@ kbdproc(void *)
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);
diff --git a/sys/src/games/doom/m_menu.c b/sys/src/games/doom/m_menu.c
index 89b8ceb84..07f2a1b68 100644
--- a/sys/src/games/doom/m_menu.c
+++ b/sys/src/games/doom/m_menu.c
@@ -1426,7 +1426,7 @@ boolean M_Responder (event_t* ev)
else
if (ev->type == ev_keydown)
{
- ch = ev->data1;
+ ch = ev->data2;
}
}
diff --git a/sys/src/games/doom/st_stuff.c b/sys/src/games/doom/st_stuff.c
index a7c857837..3513af6c5 100644
--- a/sys/src/games/doom/st_stuff.c
+++ b/sys/src/games/doom/st_stuff.c
@@ -543,7 +543,7 @@ ST_Responder (event_t* ev)
// 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 @@ ST_Responder (event_t* ev)
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 @@ ST_Responder (event_t* ev)
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 @@ ST_Responder (event_t* ev)
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 @@ ST_Responder (event_t* ev)
}
// 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 @@ 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);
@@ -646,19 +646,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 = 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 = 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 @@ 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;