]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.h
physics: fix and refactor unsticking
[xonotic/darkplaces.git] / keys.h
diff --git a/keys.h b/keys.h
index cd95805e921e0bdd6c2b818302f9c4646a4adcca..2081e8009e21d9322df83943a5b834df86b8cf81 100644 (file)
--- a/keys.h
+++ b/keys.h
 #ifndef __KEYS_H
 #define __KEYS_H
 
+#include <stddef.h>
 #include "qtypes.h"
+#include "qdefs.h"
+#include "fs.h"
+#include "cmd.h"
+
+// the highest Unicode character to allow key binding.
+// note that an excessively high value may degrade fps
+// when code is looping through the bindings
+// U+ABFF is probably the highest bindable codepoint,
+// see: https://github.com/DarkPlacesEngine/darkplaces/pull/68#issuecomment-1416802873
+#define MAX_KEY_BINDS 0xAC00
+
+// how long is a "tinystr" to hold a keyboard key's
+// Unicode utf-8 presentation, plus final \x00
+// to allow all characters <= 0xffff, use 4
+#define TINYSTR_LEN 4
 
 //
 // these are the key numbers that should be passed to Key_Event
 //
 typedef enum keynum_e
 {
+       K_TEXT                  = 1, // used only for unicode character input
        K_TAB                   = 9,
        K_ENTER                 = 13,
        K_ESCAPE                = 27,
@@ -187,6 +204,38 @@ typedef enum keynum_e
        K_AUX31,
        K_AUX32,
 
+       // 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,
@@ -316,7 +365,7 @@ typedef enum keynum_e
        K_MIDINOTE126,
        K_MIDINOTE127,
 
-       MAX_KEYS
+       MAX_KEYS = MAX_KEY_BINDS
 }
 keynum_t;
 
@@ -324,7 +373,7 @@ typedef enum keydest_e { key_game, key_message, key_menu, key_menu_grabbed, key_
 
 extern char            key_line[MAX_INPUTLINE];
 extern int                     key_linepos;
-extern qboolean        key_insert;     // insert key toggle (for editing)
+extern qbool   key_insert;     // insert key toggle (for editing)
 extern keydest_t       key_dest;
 // key_consoleactive bits
 // user wants console (halfscreen)
@@ -334,23 +383,30 @@ extern    keydest_t       key_dest;
 extern int                     key_consoleactive;
 extern char            *keybindings[MAX_BINDMAPS][MAX_KEYS];
 
-extern void Key_ClearEditLine(int edit_line);
-extern int chat_mode; // 0 for say, 1 for say_team, -1 for command
+extern signed char chat_mode; // 0 for say, 1 for say_team, -1 for command
 extern char chat_buffer[MAX_INPUTLINE];
-extern unsigned int chat_bufferlen;
+extern int     chat_bufferpos;
 
+int Key_ClearEditLine(qbool is_console);
 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_ClearStates (void);
-void Key_SetBinding (int keynum, int bindmap, const char *binding);
+void Key_Event(int key, int ascii, qbool down);
+void Key_ReleaseAll (void);
+void Key_ReleaseAll_f(cmd_state_t *cmd);
 void Key_EventQueue_Block(void);
 void Key_EventQueue_Unblock(void);
+int Key_AddChar(int unicode, qbool is_console);
+int Key_Parse_CommonKeys(cmd_state_t *cmd, qbool is_console, int key, int unicode);
 
+qbool 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);
+qbool Key_SetBindMap(int fg, int bg);
+void Key_GetBindMap(int *fg, int *bg);
+const char *Key_KeynumToString (int keynum, char *buf, size_t buflength);
+int Key_StringToKeynum (const char *str);
 
 #endif // __KEYS_H