Fix setinfo.
[xonotic/darkplaces.git] / keys.h
diff --git a/keys.h b/keys.h
index 4140f29..7841e9d 100644 (file)
--- a/keys.h
+++ b/keys.h
 /*
-Copyright (C) 1996-1997 Id Software, Inc.
+       $RCSfile$
 
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
+       Copyright (C) 1996-1997  Id Software, Inc.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+       This program is free software; you can redistribute it and/or
+       modify it under the terms of the GNU General Public License
+       as published by the Free Software Foundation; either version 2
+       of the License, or (at your option) any later version.
 
-See the GNU General Public License for more details.
+       This program is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+       See the GNU General Public License for more details.
 
+       You should have received a copy of the GNU General Public License
+       along with this program; if not, write to:
+
+               Free Software Foundation, Inc.
+               59 Temple Place - Suite 330
+               Boston, MA  02111-1307, USA
+
+       $Id$
 */
 
-#ifndef KEYS_H
-#define KEYS_H
+#ifndef __KEYS_H
+#define __KEYS_H
+
+#include "qtypes.h"
 
 //
 // these are the key numbers that should be passed to Key_Event
 //
-#define        K_TAB                   9
-#define        K_ENTER                 13
-#define        K_ESCAPE                27
-#define        K_SPACE                 32
-
-// normal keys should be passed as lowercased ascii
-
-#define        K_BACKSPACE             127
-#define        K_UPARROW               128
-#define        K_DOWNARROW             129
-#define        K_LEFTARROW             130
-#define        K_RIGHTARROW    131
-
-#define        K_ALT                   132
-#define        K_CTRL                  133
-#define        K_SHIFT                 134
-#define        K_F1                    135
-#define        K_F2                    136
-#define        K_F3                    137
-#define        K_F4                    138
-#define        K_F5                    139
-#define        K_F6                    140
-#define        K_F7                    141
-#define        K_F8                    142
-#define        K_F9                    143
-#define        K_F10                   144
-#define        K_F11                   145
-#define        K_F12                   146
-#define        K_INS                   147
-#define        K_DEL                   148
-#define        K_PGDN                  149
-#define        K_PGUP                  150
-#define        K_HOME                  151
-#define        K_END                   152
-
-#define K_KP_HOME              160
-#define K_KP_UPARROW   161
-#define K_KP_PGUP              162
-#define        K_KP_LEFTARROW  163
-#define K_KP_5                 164
-#define K_KP_RIGHTARROW        165
-#define K_KP_END               166
-#define K_KP_DOWNARROW 167
-#define K_KP_PGDN              168
-#define        K_KP_ENTER              169
-#define K_KP_INS               170
-#define        K_KP_DEL                171
-#define K_KP_SLASH             172
-#define K_KP_MINUS             173
-#define K_KP_PLUS              174
-
-#define K_PAUSE                        255
+typedef enum keynum_e
+{
+       K_TEXT                  = 1, // used only for unicode character input
+       K_TAB                   = 9,
+       K_ENTER                 = 13,
+       K_ESCAPE                = 27,
+       K_SPACE                 = 32,
+
+       // normal keys should be passed as lowercased ascii
+
+       K_BACKSPACE             = 127,
+       K_UPARROW,
+       K_DOWNARROW,
+       K_LEFTARROW,
+       K_RIGHTARROW,
+
+       K_ALT,
+       K_CTRL,
+       K_SHIFT,
+
+       K_F1,
+       K_F2,
+       K_F3,
+       K_F4,
+       K_F5,
+       K_F6,
+       K_F7,
+       K_F8,
+       K_F9,
+       K_F10,
+       K_F11,
+       K_F12,
+
+       K_INS,
+       K_DEL,
+       K_PGDN,
+       K_PGUP,
+       K_HOME,
+       K_END,
+
+       K_PAUSE,
+
+       K_NUMLOCK,
+       K_CAPSLOCK,
+       K_SCROLLOCK,
+
+       K_KP_0,
+       K_KP_INS = K_KP_0,
+       K_KP_1,
+       K_KP_END = K_KP_1,
+       K_KP_2,
+       K_KP_DOWNARROW = K_KP_2,
+       K_KP_3,
+       K_KP_PGDN = K_KP_3,
+       K_KP_4,
+       K_KP_LEFTARROW = K_KP_4,
+       K_KP_5,
+       K_KP_6,
+       K_KP_RIGHTARROW = K_KP_6,
+       K_KP_7,
+       K_KP_HOME = K_KP_7,
+       K_KP_8,
+       K_KP_UPARROW = K_KP_8,
+       K_KP_9,
+       K_KP_PGUP = K_KP_9,
+       K_KP_PERIOD,
+       K_KP_DEL = K_KP_PERIOD,
+       K_KP_DIVIDE,
+       K_KP_SLASH = K_KP_DIVIDE,
+       K_KP_MULTIPLY,
+       K_KP_MINUS,
+       K_KP_PLUS,
+       K_KP_ENTER,
+       K_KP_EQUALS,
+
+       K_PRINTSCREEN,
+
+       // mouse buttons generate virtual keys
+
+       K_MOUSE1 = 512,
+       K_OTHERDEVICESBEGIN = K_MOUSE1,
+       K_MOUSE2,
+       K_MOUSE3,
+       K_MWHEELUP,
+       K_MWHEELDOWN,
+       K_MOUSE4,
+       K_MOUSE5,
+       K_MOUSE6,
+       K_MOUSE7,
+       K_MOUSE8,
+       K_MOUSE9,
+       K_MOUSE10,
+       K_MOUSE11,
+       K_MOUSE12,
+       K_MOUSE13,
+       K_MOUSE14,
+       K_MOUSE15,
+       K_MOUSE16,
 
 //
 // joystick buttons
 //
-#define        K_JOY1                  203
-#define        K_JOY2                  204
-#define        K_JOY3                  205
-#define        K_JOY4                  206
+       K_JOY1 = 768,
+       K_JOY2,
+       K_JOY3,
+       K_JOY4,
+       K_JOY5,
+       K_JOY6,
+       K_JOY7,
+       K_JOY8,
+       K_JOY9,
+       K_JOY10,
+       K_JOY11,
+       K_JOY12,
+       K_JOY13,
+       K_JOY14,
+       K_JOY15,
+       K_JOY16,
 
 //
 // aux keys are for multi-buttoned joysticks to generate so they can use
 // the normal binding process
 //
-#define        K_AUX1                  207
-#define        K_AUX2                  208
-#define        K_AUX3                  209
-#define        K_AUX4                  210
-#define        K_AUX5                  211
-#define        K_AUX6                  212
-#define        K_AUX7                  213
-#define        K_AUX8                  214
-#define        K_AUX9                  215
-#define        K_AUX10                 216
-#define        K_AUX11                 217
-#define        K_AUX12                 218
-#define        K_AUX13                 219
-#define        K_AUX14                 220
-#define        K_AUX15                 221
-#define        K_AUX16                 222
-#define        K_AUX17                 223
-#define        K_AUX18                 224
-#define        K_AUX19                 225
-#define        K_AUX20                 226
-#define        K_AUX21                 227
-#define        K_AUX22                 228
-#define        K_AUX23                 229
-#define        K_AUX24                 230
-#define        K_AUX25                 231
-#define        K_AUX26                 232
-#define        K_AUX27                 233
-#define        K_AUX28                 234
-#define        K_AUX29                 235
-#define        K_AUX30                 236
-#define        K_AUX31                 237
-#define        K_AUX32                 238
-
-#define K_MWHEELDOWN   239
-#define K_MWHEELUP             240
+       K_AUX1,
+       K_AUX2,
+       K_AUX3,
+       K_AUX4,
+       K_AUX5,
+       K_AUX6,
+       K_AUX7,
+       K_AUX8,
+       K_AUX9,
+       K_AUX10,
+       K_AUX11,
+       K_AUX12,
+       K_AUX13,
+       K_AUX14,
+       K_AUX15,
+       K_AUX16,
+       K_AUX17,
+       K_AUX18,
+       K_AUX19,
+       K_AUX20,
+       K_AUX21,
+       K_AUX22,
+       K_AUX23,
+       K_AUX24,
+       K_AUX25,
+       K_AUX26,
+       K_AUX27,
+       K_AUX28,
+       K_AUX29,
+       K_AUX30,
+       K_AUX31,
+       K_AUX32,
 
-//
-// mouse buttons generate virtual keys
-//
-#define        K_MOUSE1                241
-#define        K_MOUSE2                242
-#define        K_MOUSE3                243
-// LordHavoc: thanks to backslash for this MOUSE4 and MOUSE5 code,
-// LordHavoc: however I renumbered it differently and added MOUSE6 through MOUSE10
-/* backslash :: imouse explorer buttons */
-#define K_MOUSE4               244
-#define K_MOUSE5               245
-/* backslash :: renumber everything that follows so that the mouse4/5 buttons can be squeezed in */
-// LordHavoc: added these for completeness
-#define        K_MOUSE6                246
-#define        K_MOUSE7                247
-#define        K_MOUSE8                248
-#define        K_MOUSE9                249
-#define        K_MOUSE10               250
-
-
-extern char *keybindings[256];
-extern int key_repeats[256];
-
-extern char chat_buffer[256];
-extern int chat_bufferlen;
-extern qboolean chat_team;
-
-typedef enum {key_game, key_message, key_menu} keydest_t;
+       // Microsoft Xbox 360 Controller For Windows
+       K_X360_DPAD_UP,
+       K_X360_DPAD_DOWN,
+       K_X360_DPAD_LEFT,
+       K_X360_DPAD_RIGHT,
+       K_X360_START,
+       K_X360_BACK,
+       K_X360_LEFT_THUMB,
+       K_X360_RIGHT_THUMB,
+       K_X360_LEFT_SHOULDER,
+       K_X360_RIGHT_SHOULDER,
+       K_X360_A,
+       K_X360_B,
+       K_X360_X,
+       K_X360_Y,
+       K_X360_LEFT_TRIGGER,
+       K_X360_RIGHT_TRIGGER,
+       K_X360_LEFT_THUMB_UP,
+       K_X360_LEFT_THUMB_DOWN,
+       K_X360_LEFT_THUMB_LEFT,
+       K_X360_LEFT_THUMB_RIGHT,
+       K_X360_RIGHT_THUMB_UP,
+       K_X360_RIGHT_THUMB_DOWN,
+       K_X360_RIGHT_THUMB_LEFT,
+       K_X360_RIGHT_THUMB_RIGHT,
+
+       // generic joystick emulation for menu
+       K_JOY_UP,
+       K_JOY_DOWN,
+       K_JOY_LEFT,
+       K_JOY_RIGHT,
 
+       K_MIDINOTE0 = 896, // to this, the note number is added
+       K_MIDINOTE1,
+       K_MIDINOTE2,
+       K_MIDINOTE3,
+       K_MIDINOTE4,
+       K_MIDINOTE5,
+       K_MIDINOTE6,
+       K_MIDINOTE7,
+       K_MIDINOTE8,
+       K_MIDINOTE9,
+       K_MIDINOTE10,
+       K_MIDINOTE11,
+       K_MIDINOTE12,
+       K_MIDINOTE13,
+       K_MIDINOTE14,
+       K_MIDINOTE15,
+       K_MIDINOTE16,
+       K_MIDINOTE17,
+       K_MIDINOTE18,
+       K_MIDINOTE19,
+       K_MIDINOTE20,
+       K_MIDINOTE21,
+       K_MIDINOTE22,
+       K_MIDINOTE23,
+       K_MIDINOTE24,
+       K_MIDINOTE25,
+       K_MIDINOTE26,
+       K_MIDINOTE27,
+       K_MIDINOTE28,
+       K_MIDINOTE29,
+       K_MIDINOTE30,
+       K_MIDINOTE31,
+       K_MIDINOTE32,
+       K_MIDINOTE33,
+       K_MIDINOTE34,
+       K_MIDINOTE35,
+       K_MIDINOTE36,
+       K_MIDINOTE37,
+       K_MIDINOTE38,
+       K_MIDINOTE39,
+       K_MIDINOTE40,
+       K_MIDINOTE41,
+       K_MIDINOTE42,
+       K_MIDINOTE43,
+       K_MIDINOTE44,
+       K_MIDINOTE45,
+       K_MIDINOTE46,
+       K_MIDINOTE47,
+       K_MIDINOTE48,
+       K_MIDINOTE49,
+       K_MIDINOTE50,
+       K_MIDINOTE51,
+       K_MIDINOTE52,
+       K_MIDINOTE53,
+       K_MIDINOTE54,
+       K_MIDINOTE55,
+       K_MIDINOTE56,
+       K_MIDINOTE57,
+       K_MIDINOTE58,
+       K_MIDINOTE59,
+       K_MIDINOTE60,
+       K_MIDINOTE61,
+       K_MIDINOTE62,
+       K_MIDINOTE63,
+       K_MIDINOTE64,
+       K_MIDINOTE65,
+       K_MIDINOTE66,
+       K_MIDINOTE67,
+       K_MIDINOTE68,
+       K_MIDINOTE69,
+       K_MIDINOTE70,
+       K_MIDINOTE71,
+       K_MIDINOTE72,
+       K_MIDINOTE73,
+       K_MIDINOTE74,
+       K_MIDINOTE75,
+       K_MIDINOTE76,
+       K_MIDINOTE77,
+       K_MIDINOTE78,
+       K_MIDINOTE79,
+       K_MIDINOTE80,
+       K_MIDINOTE81,
+       K_MIDINOTE82,
+       K_MIDINOTE83,
+       K_MIDINOTE84,
+       K_MIDINOTE85,
+       K_MIDINOTE86,
+       K_MIDINOTE87,
+       K_MIDINOTE88,
+       K_MIDINOTE89,
+       K_MIDINOTE90,
+       K_MIDINOTE91,
+       K_MIDINOTE92,
+       K_MIDINOTE93,
+       K_MIDINOTE94,
+       K_MIDINOTE95,
+       K_MIDINOTE96,
+       K_MIDINOTE97,
+       K_MIDINOTE98,
+       K_MIDINOTE99,
+       K_MIDINOTE100,
+       K_MIDINOTE101,
+       K_MIDINOTE102,
+       K_MIDINOTE103,
+       K_MIDINOTE104,
+       K_MIDINOTE105,
+       K_MIDINOTE106,
+       K_MIDINOTE107,
+       K_MIDINOTE108,
+       K_MIDINOTE109,
+       K_MIDINOTE110,
+       K_MIDINOTE111,
+       K_MIDINOTE112,
+       K_MIDINOTE113,
+       K_MIDINOTE114,
+       K_MIDINOTE115,
+       K_MIDINOTE116,
+       K_MIDINOTE117,
+       K_MIDINOTE118,
+       K_MIDINOTE119,
+       K_MIDINOTE120,
+       K_MIDINOTE121,
+       K_MIDINOTE122,
+       K_MIDINOTE123,
+       K_MIDINOTE124,
+       K_MIDINOTE125,
+       K_MIDINOTE126,
+       K_MIDINOTE127,
+
+       MAX_KEYS
+}
+keynum_t;
+
+typedef enum keydest_e { key_game, key_message, key_menu, key_menu_grabbed, key_console, key_void } keydest_t;
+
+extern char            key_line[MAX_INPUTLINE];
+extern int                     key_linepos;
+extern qboolean        key_insert;     // insert key toggle (for editing)
+extern keydest_t       key_dest;
 // key_consoleactive bits
 // user wants console (halfscreen)
 #define KEY_CONSOLEACTIVE_USER 1
 // console forced because there's nothing else active (fullscreen)
-#define KEY_CONSOLEACTIVE_FORCED 2
-extern int key_consoleactive;
-extern keydest_t key_dest;
+#define KEY_CONSOLEACTIVE_FORCED 4
+extern int                     key_consoleactive;
+extern char            *keybindings[MAX_BINDMAPS][MAX_KEYS];
+
+extern int chat_mode; // 0 for say, 1 for say_team, -1 for command
+extern char chat_buffer[MAX_INPUTLINE];
+extern unsigned int chat_bufferlen;
+
+void Key_ClearEditLine(int edit_line);
+void Key_WriteBindings(qfile_t *f);
+void Key_Init(void);
+void Key_Shutdown(void);
+void Key_Init_Cvars(void);
+void Key_Event(int key, int ascii, qboolean down);
+void Key_ReleaseAll (void);
+void Key_EventQueue_Block(void);
+void Key_EventQueue_Unblock(void);
 
-void Key_Event (int key, char ascii, qboolean down);
-void Key_Init (void);
-void Key_WriteBindings (qfile_t *f);
-void Key_SetBinding (int keynum, char *binding);
-void Key_ClearStates (void);
+qboolean Key_SetBinding (int keynum, int bindmap, const char *binding);
+const char *Key_GetBind (int key, int bindmap);
+void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bindmap);
+qboolean Key_SetBindMap(int fg, int bg);
+void Key_GetBindMap(int *fg, int *bg);
 
-#endif
+#endif // __KEYS_H