Always use printable UNICODE characters for the key_handler and included routine to assign key symbols to UNICODE so we get an equivalent of a Key-Released state which we need for the Keyboard buffer; Removed the shifted_ascii_value field from key_props and stored all usable characters in seperate rows; Improves Text input and makes keyboard mapping independent from keyboard layout without breaking any compability

This commit is contained in:
zicodxx 2008-10-31 16:57:36 +00:00
parent 85b303e5e1
commit ab0524f95b
12 changed files with 373 additions and 369 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20081031
--------
arch/include/key.h, arch/sdl/key.c, main/game.c, main/kmatrix.c, main/multi.c, main/multi.h, main/newmenu.c, main/scores.c, ui/inputbox.c, main/menubar.c: Always use printable UNICODE characters for the key_handler and included routine to assign key symbols to UNICODE so we get an equivalent of a Key-Released state which we need for the Keyboard buffer; Removed the shifted_ascii_value field from key_props and stored all usable characters in seperate rows; Improves Text input and makes keyboard mapping independent from keyboard layout without breaking any compability
20081030
--------
INSTALL.txt, README.txt: Docs update: Infos about Jukebox over SDL_mixer, SDL_mixer is not experimental anymore, yet another .de->.com change

View file

@ -43,8 +43,6 @@ extern unsigned char keyd_editor_mode;
// Time in seconds when last key was pressed...
extern volatile int keyd_time_when_last_pressed;
extern volatile int keyd_ascii;
//==========================================================================
// These are the "buffered" keypress routines. Use them by setting the
// "keyd_buffer_type" variable.
@ -57,7 +55,7 @@ extern int key_inkey(); // Gets key if one, other returns 0.
extern int key_inkey_time(fix *time); // Same as inkey, but returns the time the key was pressed down.
extern int key_peekkey(); // Same as inkey, but doesn't remove key from buffer.
extern unsigned char key_to_ascii(void);
extern unsigned char key_to_ascii(int keycode);
extern void key_debug(); // Does an INT3

View file

@ -507,7 +507,7 @@ void ogl_draw_reticle(int cross,int primary,int secondary)
glPushMatrix();
glTranslatef((grd_curcanv->cv_bitmap.bm_w/2+grd_curcanv->cv_bitmap.bm_x)/(float)last_width,1.0-(grd_curcanv->cv_bitmap.bm_h/2+grd_curcanv->cv_bitmap.bm_y)/(float)last_height,0);
glScalef(scale/320.0,scale/200.0,scale);//the positions are based upon the standard reticle at 320x200 res.
glLineWidth(SWIDTH/320);
glLineWidth(SHEIGHT/240);
OGL_DISABLE(TEXTURE_2D);
glDisable(GL_CULL_FACE);
if (!cross_lh[cross])
@ -962,7 +962,7 @@ void ogl_start_frame(void){
OGL_VIEWPORT(grd_curcanv->cv_bitmap.bm_x,grd_curcanv->cv_bitmap.bm_y,Canvas_width,Canvas_height);
glClearColor(0.0, 0.0, 0.0, 0.0);
glLineWidth(SWIDTH<640?1:SWIDTH/640);
glLineWidth(SHEIGHT/480);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View file

@ -21,6 +21,7 @@
#include "timer.h"
#define KEY_BUFFER_SIZE 16
#define UNICODE
static unsigned char Installed = 0;
@ -32,7 +33,6 @@ volatile unsigned char keyd_last_pressed;
volatile unsigned char keyd_last_released;
volatile unsigned char keyd_pressed[256];
volatile int keyd_time_when_last_pressed;
volatile int keyd_ascii;
typedef struct Key_info {
ubyte state; // state of key 1 == down, 0 == up
@ -56,338 +56,347 @@ static keyboard key_data;
typedef struct key_props {
char *key_text;
unsigned char ascii_value;
unsigned char shifted_ascii_value;
SDLKey sym;
} key_props;
key_props key_properties[256] = {
{ "", 255, 255, -1 }, // 0
{ "ESC", 255, 255, SDLK_ESCAPE },
{ "1", '1', '!', SDLK_1 },
{ "2", '2', '@', SDLK_2 },
{ "3", '3', '#', SDLK_3 },
{ "4", '4', '$', SDLK_4 },
{ "5", '5', '%', SDLK_5 },
{ "6", '6', '^', SDLK_6 },
{ "7", '7', '&', SDLK_7 },
{ "8", '8', '*', SDLK_8 },
{ "9", '9', '(', SDLK_9 }, // 10
{ "0", '0', ')', SDLK_0 },
{ "-", '-', '_', SDLK_MINUS },
{ "=", '=', '+', SDLK_EQUALS },
{ "BSPC", 255, 255, SDLK_BACKSPACE },
{ "TAB", 255, 255, SDLK_TAB },
{ "Q", 'q', 'Q', SDLK_q },
{ "W", 'w', 'W', SDLK_w },
{ "E", 'e', 'E', SDLK_e },
{ "R", 'r', 'R', SDLK_r },
{ "T", 't', 'T', SDLK_t }, // 20
{ "Y", 'y', 'Y', SDLK_y },
{ "U", 'u', 'U', SDLK_u },
{ "I", 'i', 'I', SDLK_i },
{ "O", 'o', 'O', SDLK_o },
{ "P", 'p', 'P', SDLK_p },
{ "[", '[', '{', SDLK_LEFTBRACKET },
{ "]", ']', '}', SDLK_RIGHTBRACKET },
{ "ENTER", 255, 255, SDLK_RETURN },
{ "LCTRL", 255, 255, SDLK_LCTRL },
{ "A", 'a', 'A', SDLK_a }, // 30
{ "S", 's', 'S', SDLK_s },
{ "D", 'd', 'D', SDLK_d },
{ "F", 'f', 'F', SDLK_f },
{ "G", 'g', 'G', SDLK_g },
{ "H", 'h', 'H', SDLK_h },
{ "J", 'j', 'J', SDLK_j },
{ "K", 'k', 'K', SDLK_k },
{ "L", 'l', 'L', SDLK_l },
{ ";", ';', ':', SDLK_SEMICOLON },
{ "'", '\'', '"', SDLK_QUOTE }, // 40
{ "`", '`', '~', SDLK_BACKQUOTE },
{ "LSHFT", 255, 255, SDLK_LSHIFT },
{ "\\", '\\', '|', SDLK_BACKSLASH },
{ "Z", 'z', 'Z', SDLK_z },
{ "X", 'x', 'X', SDLK_x },
{ "C", 'c', 'C', SDLK_c },
{ "V", 'v', 'V', SDLK_v },
{ "B", 'b', 'B', SDLK_b },
{ "N", 'n', 'N', SDLK_n },
{ "M", 'm', 'M', SDLK_m }, // 50
{ ",", ',', '<', SDLK_COMMA },
{ ".", '.', '>', SDLK_PERIOD },
{ "/", '/', '?', SDLK_SLASH },
{ "RSHFT", 255, 255, SDLK_RSHIFT },
{ "PAD*", '*', 255, SDLK_KP_MULTIPLY },
{ "LALT", 255, 255, SDLK_LALT },
{ "SPC", ' ', ' ', SDLK_SPACE },
{ "CPSLK", 255, 255, SDLK_CAPSLOCK },
{ "F1", 255, 255, SDLK_F1 },
{ "F2", 255, 255, SDLK_F2 }, // 60
{ "F3", 255, 255, SDLK_F3 },
{ "F4", 255, 255, SDLK_F4 },
{ "F5", 255, 255, SDLK_F5 },
{ "F6", 255, 255, SDLK_F6 },
{ "F7", 255, 255, SDLK_F7 },
{ "F8", 255, 255, SDLK_F8 },
{ "F9", 255, 255, SDLK_F9 },
{ "F10", 255, 255, SDLK_F10 },
{ "NMLCK", 255, 255, SDLK_NUMLOCK },
{ "SCLK", 255, 255, SDLK_SCROLLOCK }, // 70
{ "PAD7", 255, 255, SDLK_KP7 },
{ "PAD8", 255, 255, SDLK_KP8 },
{ "PAD9", 255, 255, SDLK_KP9 },
{ "PAD-", 255, 255, SDLK_KP_MINUS },
{ "PAD4", 255, 255, SDLK_KP4 },
{ "PAD5", 255, 255, SDLK_KP5 },
{ "PAD6", 255, 255, SDLK_KP6 },
{ "PAD+", 255, 255, SDLK_KP_PLUS },
{ "PAD1", 255, 255, SDLK_KP1 },
{ "PAD2", 255, 255, SDLK_KP2 }, // 80
{ "PAD3", 255, 255, SDLK_KP3 },
{ "PAD0", 255, 255, SDLK_KP0 },
{ "PAD.", 255, 255, SDLK_KP_PERIOD },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "F11", 255, 255, SDLK_F11 },
{ "F12", 255, 255, SDLK_F12 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 90
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "PAUSE", 255, 255, SDLK_PAUSE },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 100
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 110
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 120
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 130
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 140
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 150
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "PAD", 255, 255, SDLK_KP_ENTER },
{ "RCTRL", 255, 255, SDLK_RCTRL },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 160
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 170
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 180
{ "PAD/", 255, 255, SDLK_KP_DIVIDE },
{ "", 255, 255, -1 },
{ "PRSCR", 255, 255, SDLK_PRINT },
{ "RALT", 255, 255, SDLK_RALT },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 190
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "HOME", 255, 255, SDLK_HOME },
{ "UP", 255, 255, SDLK_UP }, // 200
{ "PGUP", 255, 255, SDLK_PAGEUP },
{ "", 255, 255, -1 },
{ "LEFT", 255, 255, SDLK_LEFT },
{ "", 255, 255, -1 },
{ "RIGHT", 255, 255, SDLK_RIGHT },
{ "", 255, 255, -1 },
{ "END", 255, 255, SDLK_END },
{ "DOWN", 255, 255, SDLK_DOWN },
{ "PGDN", 255, 255, SDLK_PAGEDOWN },
{ "INS", 255, 255, SDLK_INSERT }, // 210
{ "DEL", 255, 255, SDLK_DELETE },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 220
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 230
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 240
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 250
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 },
{ "", 255, 255, -1 }, // 255
{ "", 255, -1 }, // 0
{ "ESC", 255, SDLK_ESCAPE },
{ "1", '1', SDLK_1 },
{ "2", '2', SDLK_2 },
{ "3", '3', SDLK_3 },
{ "4", '4', SDLK_4 },
{ "5", '5', SDLK_5 },
{ "6", '6', SDLK_6 },
{ "7", '7', SDLK_7 },
{ "8", '8', SDLK_8 },
{ "9", '9', SDLK_9 }, // 10
{ "0", '0', SDLK_0 },
{ "-", '-', SDLK_MINUS },
{ "=", '=', SDLK_EQUALS },
{ "BSPC", 255, SDLK_BACKSPACE },
{ "TAB", 255, SDLK_TAB },
{ "Q", 'q', SDLK_q },
{ "W", 'w', SDLK_w },
{ "E", 'e', SDLK_e },
{ "R", 'r', SDLK_r },
{ "T", 't', SDLK_t }, // 20
{ "Y", 'y', SDLK_y },
{ "U", 'u', SDLK_u },
{ "I", 'i', SDLK_i },
{ "O", 'o', SDLK_o },
{ "P", 'p', SDLK_p },
{ "[", '[', SDLK_LEFTBRACKET },
{ "]", ']', SDLK_RIGHTBRACKET },
{ "ENTER", 255, SDLK_RETURN },
{ "LCTRL", 255, SDLK_LCTRL },
{ "A", 'a', SDLK_a }, // 30
{ "S", 's', SDLK_s },
{ "D", 'd', SDLK_d },
{ "F", 'f', SDLK_f },
{ "G", 'g', SDLK_g },
{ "H", 'h', SDLK_h },
{ "J", 'j', SDLK_j },
{ "K", 'k', SDLK_k },
{ "L", 'l', SDLK_l },
{ ";", ';', SDLK_SEMICOLON },
{ "'", '\'', SDLK_QUOTE }, // 40
{ "`", '`', SDLK_BACKQUOTE },
{ "LSHFT", 255, SDLK_LSHIFT },
{ "\\", '\\', SDLK_BACKSLASH },
{ "Z", 'z', SDLK_z },
{ "X", 'x', SDLK_x },
{ "C", 'c', SDLK_c },
{ "V", 'v', SDLK_v },
{ "B", 'b', SDLK_b },
{ "N", 'n', SDLK_n },
{ "M", 'm', SDLK_m }, // 50
{ ",", ',', SDLK_COMMA },
{ ".", '.', SDLK_PERIOD },
{ "/", '/', SDLK_SLASH },
{ "RSHFT", 255, SDLK_RSHIFT },
{ "PAD*", '*', SDLK_KP_MULTIPLY },
{ "LALT", 255, SDLK_LALT },
{ "SPC", ' ', SDLK_SPACE },
{ "CPSLK", 255, SDLK_CAPSLOCK },
{ "F1", 255, SDLK_F1 },
{ "F2", 255, SDLK_F2 }, // 60
{ "F3", 255, SDLK_F3 },
{ "F4", 255, SDLK_F4 },
{ "F5", 255, SDLK_F5 },
{ "F6", 255, SDLK_F6 },
{ "F7", 255, SDLK_F7 },
{ "F8", 255, SDLK_F8 },
{ "F9", 255, SDLK_F9 },
{ "F10", 255, SDLK_F10 },
{ "NMLCK", 255, SDLK_NUMLOCK },
{ "SCLK", 255, SDLK_SCROLLOCK }, // 70
{ "PAD7", 255, SDLK_KP7 },
{ "PAD8", 255, SDLK_KP8 },
{ "PAD9", 255, SDLK_KP9 },
{ "PAD-", 255, SDLK_KP_MINUS },
{ "PAD4", 255, SDLK_KP4 },
{ "PAD5", 255, SDLK_KP5 },
{ "PAD6", 255, SDLK_KP6 },
{ "PAD+", 255, SDLK_KP_PLUS },
{ "PAD1", 255, SDLK_KP1 },
{ "PAD2", 255, SDLK_KP2 }, // 80
{ "PAD3", 255, SDLK_KP3 },
{ "PAD0", 255, SDLK_KP0 },
{ "PAD.", 255, SDLK_KP_PERIOD },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "F11", 255, SDLK_F11 },
{ "F12", 255, SDLK_F12 },
{ "", 255, -1 },
{ "", 255, -1 }, // 90
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "PAUSE", 255, SDLK_PAUSE },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 100
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 110
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 120
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 130
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 140
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 150
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "PAD", 255, SDLK_KP_ENTER },
{ "RCTRL", 255, SDLK_RCTRL },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 160
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 170
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 180
{ "PAD/", 255, SDLK_KP_DIVIDE },
{ "", 255, -1 },
{ "PRSCR", 255, SDLK_PRINT },
{ "RALT", 255, SDLK_RALT },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 190
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "HOME", 255, SDLK_HOME },
{ "UP", 255, SDLK_UP }, // 200
{ "PGUP", 255, SDLK_PAGEUP },
{ "", 255, -1 },
{ "LEFT", 255, SDLK_LEFT },
{ "", 255, -1 },
{ "RIGHT", 255, SDLK_RIGHT },
{ "", 255, -1 },
{ "END", 255, SDLK_END },
{ "DOWN", 255, SDLK_DOWN },
{ "PGDN", 255, SDLK_PAGEDOWN },
{ "INS", 255, SDLK_INSERT }, // 210
{ "DEL", 255, SDLK_DELETE },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 220
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 }, // 230
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "", 255, -1 },
{ "!", '!', SDLK_EXCLAIM },
{ "@", '@', SDLK_AT },
{ "#", '#', SDLK_HASH },
{ "$", '$', SDLK_DOLLAR },
{ "%", '%', -1 }, // 240
{ "^", '^', SDLK_CARET },
{ "&", '&', SDLK_AMPERSAND },
{ "(", '(', SDLK_LEFTPAREN },
{ ")", ')', SDLK_RIGHTPAREN },
{ "_", '_', SDLK_UNDERSCORE },
{ "+", '+', SDLK_PLUS },
{ "{", '{', -1 },
{ "}", '}', -1 },
{ ":", ':', SDLK_COLON },
{ "\"", '"', SDLK_QUOTEDBL }, // 250
{ "~", '~', -1 },
{ "|", '|', -1 },
{ "<", '<', SDLK_LESS },
{ ">", '>', SDLK_GREATER },
{ "?", '?', SDLK_QUESTION }, // 255
};
static char font_table[256] = {
255, 255, 255, 255, 255, '.', 255, 255, 255, 255,
255, 255, ' ', 255, '.', '.', '[', ']', '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', '.', '<',
'=', '>', ' ', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
'<', '=', '>', '?', '@', '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', '[', '\\', ']', '^', '_', '`', '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', '{', '|', '}', '~', '<', '<', '=',
'>', 255, 255, '.', 255, 255, 255, 255, ' ', 255,
' ', '>', '.', '.', '[', ']', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '.', '<', '=', '>',
' ', '!', '"', 255, '$', '%', '&', '\'', '(', ')',
'*', '+', ',', '-', '.', '/', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
'>', '?', '@', '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', '[',
'\\', ']', '^', '_', '`', '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', '{', '|', '}', '~', '<'
// As UNICODE chars have no RELEASED state, we save each one together with the symbol assigned to it.
// If a symbol is RELEASED, check the list and we know which unicode we just released!
// This way we almost "emulate" the RELEASED state for UNICODE chars.
int sym2unimap[KEY_BUFFER_SIZE][2] =
{
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
};
char *key_text[256];
void key_buid_key_text(void)
unsigned char key_to_ascii(int keycode)
{
}
unsigned char key_to_ascii(void)
{
static int last_ascii = 0;
if (last_ascii == keyd_ascii)
return 255;
last_ascii = keyd_ascii;
return keyd_ascii;
keycode &= 0xFF;
return key_properties[keycode].ascii_value;
}
void key_handler(SDL_KeyboardEvent *event)
{
ubyte state;
int i, keycode, event_key, key_state;
int i, keycode, event_keysym=-1, event_keyuni=-1, key_state;
Key_info *key;
unsigned char temp;
event_key = event->keysym.sym;
// Read SDLK symbol and state
event_keysym = event->keysym.sym;
key_state = (event->state == SDL_PRESSED); // !(wInfo & KF_UP);
// Read unicode
if (event->keysym.unicode > 0)
{
event_keyuni = event->keysym.unicode;
// Now add the UNICODE char to our map (see comment on sym2unimap declaration)
for (i = 0; i < KEY_BUFFER_SIZE; i++)
{
if (sym2unimap[i][0] == -1)
{
sym2unimap[i][0] = event_keyuni;
sym2unimap[i][1] = event_keysym;
break;
}
}
}
else // UNICODE reported as 0 - now check which one!
{
for (i = 0; i < KEY_BUFFER_SIZE; i++)
{
if (event_keysym == sym2unimap[i][1])
{
event_keyuni = sym2unimap[i][0];
sym2unimap[i][0] = sym2unimap[i][1] = -1;
}
}
}
key_state = (event->state == SDL_PRESSED);
keyd_ascii = font_table[event->keysym.unicode];
//=====================================================
//Here a translation from win keycodes to mac keycodes!
//=====================================================
for (i = 255; i >= 0; i--) {
keycode = i;
key = &(key_data.keys[keycode]);
if (key_properties[i].sym == event_key)
if (key_properties[i].ascii_value == event_keyuni && key_properties[i].ascii_value != 255)
state = key_state;
else if ((event_keyuni == -1 || event_keyuni == event_keysym) && key_properties[i].sym == event_keysym)
state = key_state;
else
state = key->last_state;
@ -433,34 +442,33 @@ void key_handler(SDL_KeyboardEvent *event)
}
}
key->last_state = state;
}
}
void key_close()
{
Installed = 0;
Installed = 0;
}
void key_init()
{
int i;
if (Installed) return;
int i;
if (Installed) return;
Installed=1;
SDL_EnableUNICODE(1);
Installed=1;
SDL_EnableUNICODE(1);
keyd_time_when_last_pressed = timer_get_fixed_seconds();
keyd_buffer_type = 1;
keyd_repeat = 1;
for(i=0; i<256; i++)
key_text[i] = key_properties[i].key_text;
// Clear the keyboard array
key_flush();
atexit(key_close);
keyd_time_when_last_pressed = timer_get_fixed_seconds();
keyd_buffer_type = 1;
keyd_repeat = 1;
for(i=0; i<256; i++)
key_text[i] = key_properties[i].key_text;
// Clear the keyboard array
key_flush();
atexit(key_close);
}
void key_flush()
@ -479,6 +487,12 @@ void key_flush()
key_data.time_pressed[i] = 0;
}
//Clear the unicode map
for (i=0; i<KEY_BUFFER_SIZE; i++ ) {
sym2unimap[i][0] = -1;
sym2unimap[i][1] = -1;
}
//use gettimeofday here:
curtime = timer_get_fixed_seconds();
@ -492,14 +506,14 @@ void key_flush()
key_data.keys[i].timehelddown = 0;
key_data.keys[i].counter = 0;
}
keyd_ascii=255;
}
int add_one(int n)
{
n++;
if ( n >= KEY_BUFFER_SIZE ) n=0;
return n;
n++;
if ( n >= KEY_BUFFER_SIZE )
n=0;
return n;
}
int key_checkch()

View file

@ -2485,15 +2485,18 @@ void ReadControls()
if (Newdemo_state == ND_STATE_PLAYBACK )
update_vcr_state();
#ifdef NETWORK
if ( (Game_mode & GM_MULTI) && (multi_sending_message || multi_defining_message) )
multi_message_input_sub();
#endif
while ((key=key_inkey_time(&key_time)) != 0) {
if (con_events(key) && con_render)
game_flush_inputs();
#ifdef NETWORK
if ( (Game_mode & GM_MULTI) && (multi_sending_message || multi_defining_message) )
{
multi_message_input_sub(key);
continue;
}
#endif
if (Player_is_dead)
HandleDeathKey(key);

View file

@ -202,7 +202,7 @@ void kmatrix_redraw()
void kmatrix_view(int network)
{
int i, k, done;
int k, done;
fix entry_time = timer_get_approx_seconds();
//edit 05/18/99 Matt Mueller - should be initialized.
int key=0;
@ -218,11 +218,6 @@ void kmatrix_view(int network)
timer_delay2(50);
kmatrix_redraw();
for (i=0; i<JOY_MAX_BUTTONS; i++ )
if (joy_get_button_down_cnt(i)>0) done=1;
for (i=0; i<MOUSE_MAX_BUTTONS; i++ )
if (mouse_button_down_count(i)>0) done=1;
//see if redbook song needs to be restarted
songs_check_redbook_repeat();

View file

@ -962,14 +962,11 @@ multi_send_macro(int key)
return;
}
snprintf(Network_message, MAX_MESSAGE_LEN, "%s", PlayerCfg.NetworkMessageMacro[key]);
strcpy(Network_message, PlayerCfg.NetworkMessageMacro[key]);
Network_message_reciever = 100;
//added/replaced on 11/10/98 by Victor Rachels to make macros act like normal msgs
multi_send_message_end();
//-replaced- Network_message_reciever = 100;
//-replaced- hud_message(MSGC_GAME_FEEDBACK, "%s '%s'", TXT_SENDING, Network_message);
//-replaced- multi_message_feedback();
//end this section change - VR
HUD_init_message("%s '%s'", TXT_SENDING, Network_message);
multi_message_feedback();
}
@ -1076,10 +1073,8 @@ void multi_define_macro_end()
game_flush_inputs();
}
void multi_message_input_sub()
void multi_message_input_sub(int key)
{
int key = key_inkey();
switch( key )
{
case KEY_F8:
@ -1103,8 +1098,8 @@ void multi_message_input_sub()
game_flush_inputs();
break;
default:
{
int ascii = key_to_ascii();
if (key > 0) {
int ascii = key_to_ascii(key);
if ((ascii < 255 ) && (ascii != 37)) {
if (multi_message_index < MAX_MESSAGE_LEN-2 ) {
Network_message[multi_message_index++] = ascii;

View file

@ -231,7 +231,7 @@ extern int multi_quit_game;
extern int multi_sending_message;
extern int multi_defining_message;
extern void multi_message_input_sub();
extern void multi_message_input_sub(int key);
extern void multi_send_message_start();
extern void multi_message_feedback();

View file

@ -1189,7 +1189,7 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item *
item[choice].value--;
item[choice].text[item[choice].value] = 0;
} else {
ascii = key_to_ascii();
ascii = key_to_ascii(k);
if ((ascii < 255 ) && (item[choice].value < item[choice].text_len ))
{
int allowed;
@ -1213,7 +1213,7 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item *
}
else if ((item[choice].type!=NM_TYPE_INPUT) && (item[choice].type!=NM_TYPE_INPUT_MENU) )
{
ascii = key_to_ascii();
ascii = key_to_ascii(k);
if (ascii < 255 ) {
int choice1 = choice;
ascii = toupper(ascii);
@ -1711,8 +1711,8 @@ ReadFileNames:
break;
default:
{
int ascii = key_to_ascii();
if (key > 0) {
int ascii = key_to_ascii(key);
if ( ascii < 255 ) {
int cc,cc1;
cc=cc1=citem+1;
@ -2011,8 +2011,8 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_
break;
default:
{
int ascii = key_to_ascii();
if (key > 0) {
int ascii = key_to_ascii(key);
if ( ascii < 255 ) {
int cc,cc1;
cc=cc1=citem+1;

View file

@ -396,11 +396,6 @@ ReshowScores:
scores_draw_item( citem, &Scores.stats[citem] );
}
for (i=0; i<4; i++ )
if (joy_get_button_down_cnt(i)>0) done=1;
for (i=0; i<3; i++ )
if (mouse_button_down_count(i)>0) done=1;
//see if redbook song needs to be restarted
songs_check_redbook_repeat();

View file

@ -173,7 +173,7 @@ void ui_inputbox_do( UI_GADGET_INPUTBOX * inputbox, int keypress )
if (inputbox->first_time) inputbox->first_time = 0;
break;
default:
ascii = key_to_ascii();
ascii = key_to_ascii(keypress);
if ((ascii < 255 ) && (inputbox->position < inputbox->length-2))
{
if (inputbox->first_time) {

View file

@ -197,7 +197,7 @@ int menu_match_keypress( MENU * menu, int keypress )
keypress &= 0xFF;
c = key_to_ascii();
c = key_to_ascii(keypress);
for (i=0; i< menu->NumItems; i++ )
{