[input] Clean out a lot of obsolete stuff from keys

The new binding system makes much of keys.[ch] obsolete leaving only the
key name translations.
This commit is contained in:
Bill Currie 2021-11-27 12:31:24 +09:00
parent fe9241e573
commit 652546a4fb
6 changed files with 7 additions and 1210 deletions

View file

@ -379,154 +379,7 @@ typedef enum {
QFK_LAST
} knum_t;
typedef enum {
key_unfocused, ///< engine has lost input focus
key_game, ///< Normal in-game key bindings
key_demo, ///< Demo playback key bindings
key_console, ///< Command console key bindings
key_message, ///< Message input line key bindings
key_menu, ///< Menu key bindings.
key_last ///< enum size
} keydest_t;
#ifndef __QFCC__
extern knum_t key_toggleconsole;
/** Chain of input mapping tables ascociated with a keydest sub-system (game,
menu, etc).
*/
typedef struct keytarget_s {
struct imt_s *imts; ///< list of tables attached to this target
struct imt_s *active; ///< currently active table in this target
} keytarget_t;
extern int keydown[QFK_LAST];
/** Callback for handling key events based on keydest.
\param key The key that was pressed or released for this event.
\param unicode The unicode value of the key.
\param down True if a press event, false if a release event.
\param data Callback specific data pointer as passed to Key_SetKeyDest
*/
typedef void key_event_t (knum_t key, short unicode, qboolean down,
void *data);
/** Set the fallback key event handler callback for the specified keydest.
The fallback is for handling keys that have not been bound, thus allowing
the callback to handle large numbers of keys without having to create many
explicit bindings (eg, console input).
If no callback has been set for a specific keydest, then the key event
is simply ignored.
\param keydest The keydest for which the callback will be set.
\param callback The function to be called when an event occurs.
\param data Opaque data pointer passed to the callback.
*/
void Key_SetKeyEvent (keydest_t keydest, key_event_t *callback, void *data);
/** Callback for handling the escape key.
\param data Callback specific data pointer as passed to Key_PushEscape
*/
typedef void key_escape_t (void *data);
/** Push an escape key event handler callback.
\param callback The function to be called when the escape key is pressed.
\param data Opaque data pointer passed to the callback.
*/
void Key_PushEscape (key_escape_t *callback, void *data);
/** Push an escape key event handler callback.
*/
void Key_PopEscape (void);
struct cbuf_s;
void Key_Init (struct cbuf_s *cb);
void Key_Init_Cvars (void);
struct imt_s *Key_FindIMT (const char *imt_name) __attribute__((pure));
void Key_CreateIMT (keydest_t kd, const char *imt_name,
const char *chain_imt_name);
/** Handle a key press/release event.
\param key The key that was pressed or released for this event.
\param unicode The unicode value of the key.
\param down True if a press event, false if a release event.
*/
void Key_Event (knum_t key, short unicode, qboolean down);
/** Handle loss or gain of input focus (usually in windowed enviroments).
Sets the keydest target to key_unfocuses when input focus is lost.
Triggers keydest callbacks.
\bug Always sets the target to key_game when focus is gained.
\param gain True if focus is gained, false if focus is lost.
*/
void Key_FocusEvent (int gain);
void Key_WriteBindings (QFile *f);
/** Force all key states to unpressed.
Sends a key release event for any keys that are seen as down.
*/
void Key_ClearStates (void);
/** Return a key binding in the specified input mapping table.
\param imt The input mapping table from which to get the binding.
\param key The key for which to get the binding.
\return The command string bound to the key, or null if unbound.
*/
const char *Key_GetBinding (struct imt_s *imt, knum_t key) __attribute__((pure));
/** Bind a command string to a key in the specified input mapping table.
Only one command string can be bound to a key, but the command string may
contain multiple commands.
\param imt The input mapping table in which the key will be bound.
\param keynum The key to which the command string will be bound.
\param binding The command string that will be bound.
*/
void Key_SetBinding (struct imt_s *imt, knum_t keynum, const char *binding);
/** Set the current keydest target.
Triggers keydest callbacks.
\param kd The keydest target to make current.
*/
void Key_SetKeyDest(keydest_t kd);
/** Get the current keydest target.
\return The current keydest target.
*/
keydest_t Key_GetKeyDest(void) __attribute__((pure));
/** keydest callback signature.
\param kd The new current keydest target.
\param data Callback specific data pointer as passed to
Key_KeydestCallback
*/
typedef void keydest_callback_t (keydest_t kd, void *data);
/** Add a callback for when the keydest target changes.
\param callback The callback to be added.
\param data Opaque data pointer passed to the callback.
*/
void Key_KeydestCallback (keydest_callback_t *callback, void *data);
/** Get the string representation of a key.

View file

@ -111,9 +111,6 @@ static view_t *hud_view;
static qboolean con_initialized;
static keydest_t con_curr_keydest;
//static keydest_t con_prev_keydest;
static void
ClearNotify (void)
{
@ -158,11 +155,11 @@ ToggleChat_f (void)
{
Con_ClearTyping (input_line, 0);
if (con_curr_keydest == key_console && !con_data.force_commandline) {
//if (con_curr_keydest == key_console && !con_data.force_commandline) {
//Key_SetKeyDest (key_game);
} else {
//} else {
//Key_SetKeyDest (key_console);
}
//}
ClearNotify ();
}
@ -686,9 +683,9 @@ C_DrawConsole (void)
if (console_view->ylen != con_data.lines)
view_resize (console_view, console_view->xlen, con_data.lines);
say_view->visible = con_curr_keydest == key_message;
say_view->visible = 0;//FIXME
console_view->visible = con_data.lines != 0;
menu_view->visible = con_curr_keydest == key_menu;
menu_view->visible = 0;//FIXME
con_data.view->draw (con_data.view);
}

View file

@ -22,7 +22,8 @@ libs_input_libQFinput_la_SOURCES= \
libs/input/in_button.c \
libs/input/in_common.c \
libs/input/in_event.c \
libs/input/in_imt.c
libs/input/in_imt.c \
libs/input/keys.c
EXTRA_LTLIBRARIES += \
libs/input/libinput_evdev.la

File diff suppressed because it is too large Load diff

View file

@ -153,20 +153,16 @@ bi_Key_CountBinding (progs_t *pr)
static void
bi_Key_KeynumToString (progs_t *pr)
{
#if 0
int keynum = P_INT (pr, 0);
RETURN_STRING (pr, Key_KeynumToString (keynum));
#endif
}
static void
bi_Key_StringToKeynum (progs_t *pr)
{
#if 0
const char *keyname = P_GSTRING (pr, 0);
R_INT (pr) = Key_StringToKeynum (keyname);
#endif
}
static builtin_t builtins[] = {

View file

@ -91,7 +91,6 @@ typedef struct {
// connection information
cactive_t state;
signon_t signon;
keydest_t key_dest;
// network stuff
struct qsocket_s *netcon;