mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-22 04:01:17 +00:00
Closer and closer, next step is restoring some of the code I commented
out to get stuff compiling with the key stuff ripped out.
This commit is contained in:
parent
ac3c6aabcc
commit
1f7e01d75c
5 changed files with 61 additions and 17 deletions
|
@ -31,6 +31,7 @@
|
||||||
#define _KEYS_H
|
#define _KEYS_H
|
||||||
|
|
||||||
#include "quakeio.h"
|
#include "quakeio.h"
|
||||||
|
#include "wtoi.h"
|
||||||
|
|
||||||
// these are the key numbers that should be passed to Key_Event
|
// these are the key numbers that should be passed to Key_Event
|
||||||
|
|
||||||
|
@ -168,6 +169,12 @@ typedef enum {
|
||||||
K_MWHEELDOWN
|
K_MWHEELDOWN
|
||||||
} keynum_t;
|
} keynum_t;
|
||||||
|
|
||||||
|
extern wic_t bindnames[];
|
||||||
|
extern wic_t keynames[];
|
||||||
|
|
||||||
|
int Key_StringToKeynum (char *);
|
||||||
|
char *Key_KeynumToString (int);
|
||||||
|
|
||||||
void Key_Event (int key, qboolean down);
|
void Key_Event (int key, qboolean down);
|
||||||
void Key_Init (void);
|
void Key_Init (void);
|
||||||
void Key_WriteBindings (QFile *f);
|
void Key_WriteBindings (QFile *f);
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef WTOI_H
|
||||||
|
#define WTOI_H
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -34,3 +37,5 @@ typedef struct
|
||||||
|
|
||||||
char *WIC_IntToStr (int, wic_t *);
|
char *WIC_IntToStr (int, wic_t *);
|
||||||
int WIC_StrToInt (char *, wic_t *);
|
int WIC_StrToInt (char *, wic_t *);
|
||||||
|
|
||||||
|
#endif // WTOI_H
|
||||||
|
|
|
@ -650,7 +650,7 @@ Con_Insert_Char_f(void)
|
||||||
Con_Printf("usage: con_insert_char <char>\n");
|
Con_Printf("usage: con_insert_char <char>\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
key = *Cmd_Argv(1);
|
key = Key_StringToKeynum(Cmd_Argv(1));
|
||||||
if (key < 32 || key > 127)
|
if (key < 32 || key > 127)
|
||||||
return; // non printable
|
return; // non printable
|
||||||
|
|
||||||
|
@ -858,12 +858,20 @@ Con_Init
|
||||||
*/
|
*/
|
||||||
void Con_Init (void)
|
void Con_Init (void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
con_debuglog = COM_CheckParm("-condebug");
|
con_debuglog = COM_CheckParm("-condebug");
|
||||||
|
|
||||||
con = &con_main;
|
con = &con_main;
|
||||||
con_linewidth = -1;
|
con_linewidth = -1;
|
||||||
Con_CheckResize ();
|
Con_CheckResize ();
|
||||||
|
|
||||||
|
for (i=0 ; i<32 ; i++) {
|
||||||
|
key_lines[i][0] = ']';
|
||||||
|
key_lines[i][1] = 0;
|
||||||
|
}
|
||||||
|
key_linepos = 1;
|
||||||
|
|
||||||
Con_Printf ("Console initialized.\n");
|
Con_Printf ("Console initialized.\n");
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -887,8 +895,8 @@ void Con_Init (void)
|
||||||
Cmd_AddCommand ("con_delete_char", Con_Delete_Char_f);
|
Cmd_AddCommand ("con_delete_char", Con_Delete_Char_f);
|
||||||
Cmd_AddCommand ("con_cursor_left", Con_Cursor_Left_f);
|
Cmd_AddCommand ("con_cursor_left", Con_Cursor_Left_f);
|
||||||
Cmd_AddCommand ("con_cursor_right", Con_Cursor_Right_f);
|
Cmd_AddCommand ("con_cursor_right", Con_Cursor_Right_f);
|
||||||
Cmd_AddCommand ("con_curser_up", Con_Cursor_Up_f);
|
Cmd_AddCommand ("con_cursor_up", Con_Cursor_Up_f);
|
||||||
Cmd_AddCommand ("con_curser_down", Con_Cursor_Down_f);
|
Cmd_AddCommand ("con_cursor_down", Con_Cursor_Down_f);
|
||||||
Cmd_AddCommand ("con_page_up", Con_Page_Up_f);
|
Cmd_AddCommand ("con_page_up", Con_Page_Up_f);
|
||||||
Cmd_AddCommand ("con_page_down", Con_Page_Down_f);
|
Cmd_AddCommand ("con_page_down", Con_Page_Down_f);
|
||||||
Cmd_AddCommand ("con_beginningofbuffer", Con_BeginningOfBuffer_f);
|
Cmd_AddCommand ("con_beginningofbuffer", Con_BeginningOfBuffer_f);
|
||||||
|
|
|
@ -66,7 +66,7 @@ qboolean keydown[256];
|
||||||
|
|
||||||
bind_states bind_state = BIND_CONSOLE;
|
bind_states bind_state = BIND_CONSOLE;
|
||||||
|
|
||||||
static wic_t bindnames[] =
|
wic_t bindnames[] =
|
||||||
{
|
{
|
||||||
{ "GAME", BIND_GAME },
|
{ "GAME", BIND_GAME },
|
||||||
{ "CONSOLE", BIND_CONSOLE },
|
{ "CONSOLE", BIND_CONSOLE },
|
||||||
|
@ -74,7 +74,7 @@ static wic_t bindnames[] =
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static wic_t keynames[] =
|
wic_t keynames[] =
|
||||||
{
|
{
|
||||||
{"TAB", K_TAB},
|
{"TAB", K_TAB},
|
||||||
{"ENTER", K_ENTER},
|
{"ENTER", K_ENTER},
|
||||||
|
@ -192,6 +192,7 @@ static wic_t keynames[] =
|
||||||
{"MWHEELDOWN", K_MWHEELDOWN},
|
{"MWHEELDOWN", K_MWHEELDOWN},
|
||||||
|
|
||||||
{"SEMICOLON", ';'}, // because a raw semicolon seperates commands
|
{"SEMICOLON", ';'}, // because a raw semicolon seperates commands
|
||||||
|
{"DOUBLEQUOTE", '"'},
|
||||||
|
|
||||||
{NULL,0}
|
{NULL,0}
|
||||||
};
|
};
|
||||||
|
@ -463,6 +464,17 @@ Key_Init ( void )
|
||||||
Cmd_AddCommand ("unbindall", Key_Unbindall_f);
|
Cmd_AddCommand ("unbindall", Key_Unbindall_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
bind_get(int key, bind_states state)
|
||||||
|
{
|
||||||
|
if (bindings[state][key])
|
||||||
|
return bindings[state][key];
|
||||||
|
else if (bindings[BIND_ALL][key])
|
||||||
|
return bindings[BIND_ALL][key];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
Key_Event
|
Key_Event
|
||||||
|
@ -474,14 +486,26 @@ Should NOT be called during an interrupt!
|
||||||
void
|
void
|
||||||
Key_Event ( int key, qboolean down )
|
Key_Event ( int key, qboolean down )
|
||||||
{
|
{
|
||||||
char *kb;
|
char *kb = NULL;
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
|
|
||||||
// Con_Printf ("%i : %i\n", key, down); //@@@
|
// Check to see if this is just a repeat.
|
||||||
|
if (down == keydown[key])
|
||||||
|
return;
|
||||||
|
|
||||||
keydown[key] = down;
|
keydown[key] = down;
|
||||||
|
|
||||||
if ((kb = bindings[bind_state][key]) || (kb = bindings[BIND_ALL][key])) {
|
if (keydown[K_SHIFT]) {
|
||||||
|
int shifted = keyshift[key];
|
||||||
|
|
||||||
|
if ((kb = bind_get(shifted, bind_state)))
|
||||||
|
key = shifted;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!kb)
|
||||||
|
kb = bind_get(key, bind_state);
|
||||||
|
|
||||||
|
if (kb) {
|
||||||
if (kb[0] == '+') { // button commands add keynum as a parm
|
if (kb[0] == '+') { // button commands add keynum as a parm
|
||||||
snprintf (cmd, sizeof(cmd), "%s %i\n", kb, key);
|
snprintf (cmd, sizeof(cmd), "%s %i\n", kb, key);
|
||||||
if (!down)
|
if (!down)
|
||||||
|
|
|
@ -646,7 +646,7 @@ void M_Options_Key (int k)
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/* KEYS MENU */
|
/* KEYS MENU */
|
||||||
|
|
||||||
static char *bindnames[][2] =
|
static char *menu_bindnames[][2] =
|
||||||
{
|
{
|
||||||
{"+attack", "attack"},
|
{"+attack", "attack"},
|
||||||
{"impulse 10", "change weapon"},
|
{"impulse 10", "change weapon"},
|
||||||
|
@ -668,7 +668,7 @@ static char *bindnames[][2] =
|
||||||
{"+movedown", "swim down"}
|
{"+movedown", "swim down"}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
|
#define NUMCOMMANDS (sizeof(menu_bindnames)/sizeof(menu_bindnames[0]))
|
||||||
|
|
||||||
int keys_cursor;
|
int keys_cursor;
|
||||||
int bind_grab;
|
int bind_grab;
|
||||||
|
@ -751,11 +751,11 @@ void M_Keys_Draw (void)
|
||||||
{
|
{
|
||||||
y = 48 + 8*i;
|
y = 48 + 8*i;
|
||||||
|
|
||||||
M_Print (16, y, bindnames[i][1]);
|
M_Print (16, y, menu_bindnames[i][1]);
|
||||||
|
|
||||||
l = strlen (bindnames[i][0]);
|
l = strlen (menu_bindnames[i][0]);
|
||||||
|
|
||||||
M_FindKeysForCommand (bindnames[i][0], keys);
|
M_FindKeysForCommand (menu_bindnames[i][0], keys);
|
||||||
|
|
||||||
if (keys[0] == -1)
|
if (keys[0] == -1)
|
||||||
{
|
{
|
||||||
|
@ -795,7 +795,7 @@ void M_Keys_Key (int k)
|
||||||
}
|
}
|
||||||
else if (k != '`')
|
else if (k != '`')
|
||||||
{
|
{
|
||||||
snprintf (cmd, sizeof(cmd), "bind %s \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
|
snprintf (cmd, sizeof(cmd), "bind %s \"%s\"\n", Key_KeynumToString (k), menu_bindnames[keys_cursor][0]);
|
||||||
Cbuf_InsertText (cmd);
|
Cbuf_InsertText (cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,17 +826,17 @@ void M_Keys_Key (int k)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case K_ENTER: // go into bind mode
|
case K_ENTER: // go into bind mode
|
||||||
M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
|
M_FindKeysForCommand (menu_bindnames[keys_cursor][0], keys);
|
||||||
S_LocalSound ("misc/menu2.wav");
|
S_LocalSound ("misc/menu2.wav");
|
||||||
if (keys[1] != -1)
|
if (keys[1] != -1)
|
||||||
M_UnbindCommand (bindnames[keys_cursor][0]);
|
M_UnbindCommand (menu_bindnames[keys_cursor][0]);
|
||||||
bind_grab = true;
|
bind_grab = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case K_BACKSPACE: // delete bindings
|
case K_BACKSPACE: // delete bindings
|
||||||
case K_DEL: // delete bindings
|
case K_DEL: // delete bindings
|
||||||
S_LocalSound ("misc/menu2.wav");
|
S_LocalSound ("misc/menu2.wav");
|
||||||
M_UnbindCommand (bindnames[keys_cursor][0]);
|
M_UnbindCommand (menu_bindnames[keys_cursor][0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue