x11 seems ok (hard to say: nothing's bound:/)

rename bind and unbind to in_bind and in_unbind
This commit is contained in:
Bill Currie 2001-08-16 16:41:40 +00:00
parent 7cf0fd1b3b
commit 12eff5eb65
2 changed files with 69 additions and 57 deletions

View File

@ -88,74 +88,75 @@ static int p_mouse_x, p_mouse_y;
#define FOCUS_MASK (FocusChangeMask) #define FOCUS_MASK (FocusChangeMask)
#define INPUT_MASK (KEY_MASK | MOUSE_MASK | FOCUS_MASK) #define INPUT_MASK (KEY_MASK | MOUSE_MASK | FOCUS_MASK)
static int static void
XLateKey (XKeyEvent * ev, qboolean modified) XLateKey (XKeyEvent * ev, int *k, int *u)
{ {
char tmp[2];
int key = 0; int key = 0;
KeySym keysym; KeySym keysym;
XComposeStatus compose;
unsigned char buffer[4];
int bytes;
int unicode;
if (!modified) { //keysym = XLookupKeysym (ev, 0);
keysym = XLookupKeysym (ev, 0); bytes = XLookupString (ev, buffer, sizeof(buffer), &keysym, &compose);
} else { unicode = buffer[0];
XLookupString (ev, tmp, 1, &keysym, NULL);
}
switch (keysym) { switch (keysym) {
case XK_KP_Page_Up: case XK_KP_Page_Up:
key = KP_PGUP; key = K_KP9;
break; break;
case XK_Page_Up: case XK_Page_Up:
key = K_PGUP; key = K_PAGEUP;
break; break;
case XK_KP_Page_Down: case XK_KP_Page_Down:
key = KP_PGDN; key = K_KP3;
break; break;
case XK_Page_Down: case XK_Page_Down:
key = K_PGDN; key = K_PAGEDOWN;
break; break;
case XK_KP_Home: case XK_KP_Home:
key = KP_HOME; key = K_KP7;
break; break;
case XK_Home: case XK_Home:
key = K_HOME; key = K_HOME;
break; break;
case XK_KP_End: case XK_KP_End:
key = KP_END; key = K_KP1;
break; break;
case XK_End: case XK_End:
key = K_END; key = K_END;
break; break;
case XK_KP_Left: case XK_KP_Left:
key = KP_LEFTARROW; key = K_KP4;
break; break;
case XK_Left: case XK_Left:
key = K_LEFTARROW; key = K_LEFT;
break; break;
case XK_KP_Right: case XK_KP_Right:
key = KP_RIGHTARROW; key = K_KP6;
break; break;
case XK_Right: case XK_Right:
key = K_RIGHTARROW; key = K_RIGHT;
break; break;
case XK_KP_Down: case XK_KP_Down:
key = KP_DOWNARROW; key = K_KP2;
break; break;
case XK_Down: case XK_Down:
key = K_DOWNARROW; key = K_DOWN;
break; break;
case XK_KP_Up: case XK_KP_Up:
key = KP_UPARROW; key = K_KP8;
break; break;
case XK_Up: case XK_Up:
key = K_UPARROW; key = K_UP;
break; break;
case XK_Escape: case XK_Escape:
@ -163,10 +164,10 @@ XLateKey (XKeyEvent * ev, qboolean modified)
break; break;
case XK_KP_Enter: case XK_KP_Enter:
key = KP_ENTER; key = K_KP_ENTER;
break; break;
case XK_Return: case XK_Return:
key = K_ENTER; key = K_RETURN;
break; break;
case XK_Tab: case XK_Tab:
@ -215,10 +216,10 @@ XLateKey (XKeyEvent * ev, qboolean modified)
break; break;
case XK_KP_Delete: case XK_KP_Delete:
key = KP_DEL; key = K_KP_PERIOD;
break; break;
case XK_Delete: case XK_Delete:
key = K_DEL; key = K_DELETE;
break; break;
case XK_Pause: case XK_Pause:
@ -226,49 +227,59 @@ XLateKey (XKeyEvent * ev, qboolean modified)
break; break;
case XK_Shift_L: case XK_Shift_L:
key = K_LSHIFT;
break;
case XK_Shift_R: case XK_Shift_R:
key = K_SHIFT; key = K_RSHIFT;
break; break;
case XK_Execute: case XK_Execute:
case XK_Control_L: case XK_Control_L:
key = K_LCTRL;
break;
case XK_Control_R: case XK_Control_R:
key = K_CTRL; key = K_LCTRL;
break; break;
case XK_Mode_switch: case XK_Mode_switch:
case XK_Alt_L: case XK_Alt_L:
key = K_LALT;
break;
case XK_Meta_L: case XK_Meta_L:
key = K_LMETA;
break;
case XK_Alt_R: case XK_Alt_R:
key = K_RALT;
break;
case XK_Meta_R: case XK_Meta_R:
key = K_ALT; key = K_RMETA;
break; break;
case XK_Caps_Lock: case XK_Caps_Lock:
key = K_CAPSLOCK; key = K_CAPSLOCK;
break; break;
case XK_KP_Begin: case XK_KP_Begin:
key = KP_5; key = K_KP5;
break; break;
case XK_Insert: case XK_Insert:
key = K_INS; key = K_INSERT;
break; break;
case XK_KP_Insert: case XK_KP_Insert:
key = KP_INS; key = K_KP0;
break; break;
case XK_KP_Multiply: case XK_KP_Multiply:
key = KP_MULTIPLY; key = K_KP_MULTIPLY;
break; break;
case XK_KP_Add: case XK_KP_Add:
key = KP_PLUS; key = K_KP_PLUS;
break; break;
case XK_KP_Subtract: case XK_KP_Subtract:
key = KP_MINUS; key = K_KP_MINUS;
break; break;
case XK_KP_Divide: case XK_KP_Divide:
key = KP_DIVIDE; key = K_KP_DIVIDE;
break; break;
/* For Sun keyboards */ /* For Sun keyboards */
@ -276,53 +287,54 @@ XLateKey (XKeyEvent * ev, qboolean modified)
key = K_HOME; key = K_HOME;
break; break;
case XK_F29: case XK_F29:
key = K_PGUP; key = K_PAGEUP;
break; break;
case XK_F33: case XK_F33:
key = K_END; key = K_END;
break; break;
case XK_F35: case XK_F35:
key = K_PGDN; key = K_PAGEDOWN;
break; break;
/* Some high ASCII symbols, for azerty keymaps */ /* Some high ASCII symbols, for azerty keymaps */
case XK_twosuperior: case XK_twosuperior:
key = K_ASC178; key = K_WORLD_18;
break; break;
case XK_eacute: case XK_eacute:
key = K_ASC233; key = K_WORLD_63;
break; break;
case XK_section: case XK_section:
key = K_ASC167; key = K_WORLD_7;
break; break;
case XK_egrave: case XK_egrave:
key = K_ASC232; key = K_WORLD_72;
break; break;
case XK_ccedilla: case XK_ccedilla:
key = K_ASC231; key = K_WORLD_71;
break; break;
case XK_agrave: case XK_agrave:
key = K_ASC224; key = K_WORLD_64;
break; break;
default: default:
if (keysym < 128) { if (keysym < 128) {
/* ASCII keys */ /* ASCII keys */
key = keysym; key = keysym;
if (!modified && ((key >= 'A') && (key <= 'Z'))) { if ((key >= 'A') && (key <= 'Z')) {
key = key + ('a' - 'A'); key = key + ('a' - 'A');
} }
} }
break; break;
} }
*k = key;
return key; *u = unicode;
} }
static void static void
event_key (XEvent * event) event_key (XEvent * event)
{ {
int key, unicode;
if (old_key_dest != key_dest) { if (old_key_dest != key_dest) {
old_key_dest = key_dest; old_key_dest = key_dest;
if (key_dest == key_game) { if (key_dest == key_game) {
@ -331,8 +343,8 @@ event_key (XEvent * event)
XAutoRepeatOn (x_disp); XAutoRepeatOn (x_disp);
} }
} }
Key_Event (XLateKey (&event->xkey, 0), XLateKey (&event->xkey, 1), XLateKey (&event->xkey, &key, &unicode);
event->type == KeyPress); Key_Event (key, unicode, event->type == KeyPress);
} }
@ -350,13 +362,13 @@ event_button (XEvent * event)
case 1: case 1:
case 2: case 2:
case 3: case 3:
Key_Event (K_MOUSE1 + but - 1, 0, event->type == ButtonPress); Key_Event (M_BUTTON1 + but - 1, 0, event->type == ButtonPress);
break; break;
case 4: case 4:
Key_Event (K_MWHEELUP, 0, event->type == ButtonPress); Key_Event (M_WHEEL_UP, 0, event->type == ButtonPress);
break; break;
case 5: case 5:
Key_Event (K_MWHEELDOWN, 0, event->type == ButtonPress); Key_Event (M_WHEEL_DOWN, 0, event->type == ButtonPress);
break; break;
} }
} }

View File

@ -756,7 +756,7 @@ Key_Unbind_f (void)
int b, t; int b, t;
if (Cmd_Argc () != 3) { if (Cmd_Argc () != 3) {
Con_Printf ("unbind <kgt> <key> : remove commands from a key\n"); Con_Printf ("in_unbind <kgt> <key> : remove commands from a key\n");
return; return;
} }
@ -800,7 +800,7 @@ Key_Bind_f (void)
c = Cmd_Argc (); c = Cmd_Argc ();
if (c != 3 && c != 4) { if (c != 3 && c != 4) {
Con_Printf ("bind <kgt> <key> [command] : attach a command to a key\n"); Con_Printf ("in_bind <kgt> <key> [command] : attach a command to a key\n");
return; return;
} }
@ -878,7 +878,7 @@ Key_WriteBindings (VFile *f)
for (j = 0; j < KGT_LAST; j++) for (j = 0; j < KGT_LAST; j++)
for (i = 0; i < K_LAST; i++) for (i = 0; i < K_LAST; i++)
if ((bind = Key_GetBinding(j, i))) if ((bind = Key_GetBinding(j, i)))
Qprintf (f, "bind %s %s \"%s\"\n", Key_KgtnumToString (j), Qprintf (f, "in_bind %s %s \"%s\"\n", Key_KgtnumToString (j),
Key_KeynumToString (i), bind); Key_KeynumToString (i), bind);
} }
@ -976,7 +976,7 @@ Key_Init (void)
key_linepos = 1; key_linepos = 1;
// register our functions // register our functions
Cmd_AddCommand ("bind", Key_Bind_f, Cmd_AddCommand ("in_bind", Key_Bind_f,
"Assign a command or a set of commands to a key.\n" "Assign a command or a set of commands to a key.\n"
"Note: To bind multiple commands to a key, enclose the " "Note: To bind multiple commands to a key, enclose the "
"commands in quotes and separate with semi-colons. \n" "commands in quotes and separate with semi-colons. \n"
@ -989,7 +989,7 @@ Key_Init (void)
"mwheelup, mwheeldown\n" "mwheelup, mwheeldown\n"
"Special: The escape, and ~ (tilde) keys can only be " "Special: The escape, and ~ (tilde) keys can only be "
"bound from an external configuration file."); "bound from an external configuration file.");
Cmd_AddCommand ("unbind", Key_Unbind_f, Cmd_AddCommand ("in_unbind", Key_Unbind_f,
"Remove the bind from the the selected key"); "Remove the bind from the the selected key");
Cmd_AddCommand ("unbindall", Key_Unbindall_f, Cmd_AddCommand ("unbindall", Key_Unbindall_f,
"Remove all binds (USE CAUTIOUSLY!!!)"); "Remove all binds (USE CAUTIOUSLY!!!)");