move the special keys out of the way of ascii codes (unless they represent

ascii codes (eg, K_ENTER)) and remove the magic number for the number of keys.
This commit is contained in:
Bill Currie 2001-07-17 15:51:56 +00:00
parent af366764de
commit bab80a0648
3 changed files with 28 additions and 25 deletions

View File

@ -44,7 +44,7 @@ typedef enum {
K_BACKSPACE = 127,
K_CAPSLOCK,
K_CAPSLOCK = 256,
K_PRNTSCR,
K_SCRLCK,
K_PAUSE,
@ -105,7 +105,7 @@ typedef enum {
//
// mouse buttons generate virtual keys
//
K_MOUSE1 = 200,
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
@ -157,7 +157,10 @@ typedef enum {
// JACK: Intellimouse(c) Mouse Wheel Support
K_MWHEELUP,
K_MWHEELDOWN
K_MWHEELDOWN,
// keys count
K_NUM_KEYS,
} keynum_t;
typedef struct
@ -171,8 +174,8 @@ typedef struct
typedef enum {key_game, key_console, key_message, key_menu, key_none} keydest_t;
extern keydest_t key_dest;
extern char *keybindings[256];
extern int key_repeats[256];
extern char *keybindings[K_NUM_KEYS];
extern int key_repeats[K_NUM_KEYS];
extern int key_lastpress;
extern char chat_buffer[];

View File

@ -67,12 +67,12 @@ int history_line = 0;
keydest_t key_dest = key_console;
char *keybindings[256];
qboolean consolekeys[256]; // if true, can't be rebound while in console
qboolean menubound[256]; // if true, can't be rebound while in menu
int keyshift[256]; // key to map to if shift held down in console
int key_repeats[256]; // if > 1, it is autorepeating
qboolean keydown[256];
char *keybindings[K_NUM_KEYS];
qboolean consolekeys[K_NUM_KEYS]; // if true, can't be rebound while in console
qboolean menubound[K_NUM_KEYS]; // if true, can't be rebound while in menu
int keyshift[K_NUM_KEYS]; // key to map to if shift held down in console
int key_repeats[K_NUM_KEYS]; // if > 1, it is autorepeating
qboolean keydown[K_NUM_KEYS];
typedef struct {
char *name;
@ -562,7 +562,7 @@ Key_Unbindall_f (void)
{
int i;
for (i = 0; i < 256; i++)
for (i = 0; i < K_NUM_KEYS; i++)
if (keybindings[i])
Key_SetBinding (i, "");
}
@ -615,7 +615,7 @@ Key_WriteBindings (VFile *f)
{
int i;
for (i = 0; i < 256; i++)
for (i = 0; i < K_NUM_KEYS; i++)
if (keybindings[i])
Qprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString (i),
keybindings[i]);
@ -655,7 +655,7 @@ Key_Init (void)
consolekeys['`'] = false;
consolekeys['~'] = false;
for (i = 0; i < 256; i++)
for (i = 0; i < K_NUM_KEYS; i++)
keyshift[i] = i;
for (i = 'a'; i <= 'z'; i++)
keyshift[i] = i - 'a' + 'A';
@ -860,7 +860,7 @@ Key_ClearStates (void)
{
int i;
for (i = 0; i < 256; i++) {
for (i = 0; i < K_NUM_KEYS; i++) {
if (keydown[i])
Key_Event (i, 0, false);
key_repeats[i] = false;

View File

@ -68,12 +68,12 @@ int history_line = 0;
keydest_t key_dest = key_console;
char *keybindings[256];
qboolean consolekeys[256]; // if true, can't be rebound while in console
qboolean menubound[256]; // if true, can't be rebound while in menu
int keyshift[256]; // key to map to if shift held down in console
int key_repeats[256]; // if > 1, it is autorepeating
qboolean keydown[256];
char *keybindings[K_NUM_KEYS];
qboolean consolekeys[K_NUM_KEYS]; // if true, can't be rebound while in console
qboolean menubound[K_NUM_KEYS]; // if true, can't be rebound while in menu
int keyshift[K_NUM_KEYS]; // key to map to if shift held down in console
int key_repeats[K_NUM_KEYS]; // if > 1, it is autorepeating
qboolean keydown[K_NUM_KEYS];
typedef struct {
char *name;
@ -563,7 +563,7 @@ Key_Unbindall_f (void)
{
int i;
for (i = 0; i < 256; i++)
for (i = 0; i < K_NUM_KEYS; i++)
if (keybindings[i])
Key_SetBinding (i, "");
}
@ -616,7 +616,7 @@ Key_WriteBindings (VFile *f)
{
int i;
for (i = 0; i < 256; i++)
for (i = 0; i < K_NUM_KEYS; i++)
if (keybindings[i])
Qprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString (i),
keybindings[i]);
@ -656,7 +656,7 @@ Key_Init (void)
consolekeys['`'] = false;
consolekeys['~'] = false;
for (i = 0; i < 256; i++)
for (i = 0; i < K_NUM_KEYS; i++)
keyshift[i] = i;
for (i = 'a'; i <= 'z'; i++)
keyshift[i] = i - 'a' + 'A';
@ -861,7 +861,7 @@ Key_ClearStates (void)
{
int i;
for (i = 0; i < 256; i++) {
for (i = 0; i < K_NUM_KEYS; i++) {
if (keydown[i])
Key_Event (i, 0, false);
key_repeats[i] = false;