![]() |
Crossfire Client, Trunk
|
Modules | |
GTK-V2 client keybinding window functions. | |
EndOf GtkV2KeyBinding. | |
Variables | |
char * | keybind::command |
Command string bound to a key. More... | |
gint8 | keybind::direction |
-1 non-direction key, else >= 0. More... | |
guint8 | keybind::flags |
KEYF_* flags set for the record. More... | |
guint32 | keybind::keysym |
Key this binding record is for. More... | |
struct keybind * | keybind::next |
key_entry struct | |
A keybinding hash record structure. | |
static bool | debounce = false |
When a key is held down, prevent multiple commands from being sent without server acknowledgement by setting debounce when keys are pressed, and clearing it when the server acknowledges or when a key is released. More... | |
static struct keybind * | keybind_find (guint32 keysym, unsigned int flags, int scope) |
Find a keybinding for keysym. More... | |
static int | keybind_insert (guint32 keysym, unsigned int flags, const char *command) |
Updates the keys array with the keybinding that is passed. More... | |
static int | keybind_remove (struct keybind *entry) |
static void | keybind_free (struct keybind **entry) |
static void | parse_keybind_line (char *buf, int line, unsigned int scope_flag) |
This function is common to both gdk and x11 client. More... | |
static int | parse_keys_file (GInputStream *in, unsigned int scope_flag) |
Opens a file and loads the keybinds contained in it. More... | |
static void | init_default_keybindings () |
Load pre-compiled built-in default keybindings. More... | |
void | keybindings_init (const char *character_name) |
Reads in the keybindings, and initializes special values. More... | |
static void | on_count_changed (GtkSpinButton *spinbutton, gpointer *data) |
void | keys_init (GtkWidget *window_root) |
One-time initialization of windows and signals for the keybindings dialog. More... | |
static void | parse_key_release (guint32 keysym) |
The only things we actually care about is the run and fire keys. More... | |
static void | parse_key (char key, guint32 keysym) |
Parses a keypress. More... | |
static void | get_key_modchars (struct keybind *kb, int save_mode, char *buf) |
static char * | get_key_info (struct keybind *kb, int save_mode) |
static void | show_keys (void) |
Shows all the keybindings. More... | |
void | bind_key (char *params) |
Implements the "bind" command when entered as a text command. More... | |
static void | save_individual_key (FILE *fp, struct keybind *kb, KeyCode kc) |
A recursive function that saves all the entries for a particular entry. More... | |
static void | save_keys (void) |
Saves the keybindings into the user's .crossfire/keys file. More... | |
static void | configure_keys (guint32 keysym) |
static void | unbind_usage (void) |
Show help for the unbind command in the message pane. More... | |
void | unbind_key (const char *params) |
void | focusoutfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
When the main window looses its focus, act as if all keys have been released. More... | |
void | keyrelfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
GTK callback function used to handle client key release events. More... | |
void | keyfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
GTK Callback function used to handle client key press events. More... | |
void | x_set_echo (void) |
void | draw_prompt (const char *str) |
Draws a prompt. More... | |
void | gtk_command_history (int direction) |
Deals with command history. More... | |
void | gtk_complete_command (void) |
Executes when the TAB key is pressed while the command input box has focus to give hints on what commands begin with the text already entered to this point. More... | |
void | on_entry_commands_activate (GtkEntry *entry, gpointer user_data) |
Used to process keyboard input whenever the player types commands into the command entry box. More... | |
#define | EKEYBIND_NOMEM 1 |
void bind_key | ( | char * | params | ) |
Implements the "bind" command when entered as a text command.
It parses the command options, records the command to bind, then prompts the user to press a key to bind. It also shows help for the bind command if the player types bind with no parameters.
params | If null, show bind command help in the message pane. |
Definition at line 1095 of file keys.c.
References altkeysym, bind_buf, bind_flags, bind_keysym, commandkeysym, completekeysym, Configure_Keys, cpl, draw_ext_info(), firekeysym, Player_Struct::input_state, KEYF_ANY, KEYF_EDIT, KEYF_R_GLOBAL, MAX_BUF, metakeysym, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_ERROR, MSG_TYPE_CLIENT_NOTICE, MSG_TYPE_CLIENT_QUERY, NDI_BLACK, NDI_RED, nextkeysym, prevkeysym, and runkeysym.
|
static |
keysym |
Definition at line 1372 of file keys.c.
References Player_Struct::alt_on, altkeysym, bind_buf, bind_flags, bind_keysym, keybind::command, cpl, draw_ext_info(), draw_message_window(), Player_Struct::fire_on, firekeysym, Player_Struct::input_state, keybind_find(), keybind_insert(), KEYF_ANY, KEYF_MOD_ALT, KEYF_MOD_CTRL, KEYF_MOD_META, KEYF_MOD_SHIFT, KEYF_R_GLOBAL, keybind::keysym, MAX_BUF, Player_Struct::meta_on, metakeysym, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, MSG_TYPE_CLIENT_ERROR, NDI_BLACK, NDI_RED, Playing, Player_Struct::run_on, runkeysym, and save_keys().
Referenced by keyfunc().
void draw_prompt | ( | const char * | str | ) |
Draws a prompt.
Don't deal with popups for the time being.
str |
Definition at line 1719 of file keys.c.
References draw_ext_info(), entry_commands, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_QUERY, and NDI_WHITE.
Referenced by handle_query().
void focusoutfunc | ( | GtkWidget * | widget, |
GdkEventKey * | event, | ||
GtkWidget * | window | ||
) |
When the main window looses its focus, act as if all keys have been released.
Definition at line 1532 of file keys.c.
References Player_Struct::alt_on, clear_fire(), clear_run(), cpl, fire_label, Player_Struct::fire_on, Player_Struct::meta_on, run_label, and Player_Struct::run_on.
Referenced by init_ui().
|
static |
key | |
save_mode | If true, it means that the format used for saving the information is used, instead of the usual format for displaying the information in a friendly manner. |
Definition at line 994 of file keys.c.
References bind_buf, keybind::command, get_key_modchars(), keybind::keysym, and MAX_BUF.
Referenced by save_individual_key(), show_keys(), and unbind_key().
|
static |
Definition at line 956 of file keys.c.
References keybind::flags, KEYF_ANY, KEYF_EDIT, KEYF_MOD_ALT, KEYF_MOD_CTRL, KEYF_MOD_MASK, KEYF_MOD_META, and KEYF_MOD_SHIFT.
Referenced by get_key_info(), and keybind_overwrite_confirm().
void gtk_command_history | ( | int | direction | ) |
Deals with command history.
direction | If 0, we are going backwards, if 1, we are moving forward. |
Definition at line 1729 of file keys.c.
References Command_Mode, cpl, cur_history_position, keybind::direction, entry_commands, history, Player_Struct::input_state, MAX_HISTORY, and scroll_history_position.
Referenced by keyfunc().
void gtk_complete_command | ( | void | ) |
Executes when the TAB key is pressed while the command input box has focus to give hints on what commands begin with the text already entered to this point.
It is almost like tab completion, except for the completion. The TAB key is also known by GDK_Tab, completekey, or completekeysym.
Definition at line 1776 of file keys.c.
References complete_command(), and entry_commands.
Referenced by keyfunc().
|
static |
Load pre-compiled built-in default keybindings.
Definition at line 519 of file keys.c.
References in, KEYF_R_GLOBAL, LOG(), LOG_DEBUG, and parse_keys_file().
Referenced by keybindings_init().
|
static |
Find a keybinding for keysym.
Make it possible to match a specific keysym-and-key-modifier combo (useful in game play), or to match keysym regardless of modifier.
flags | If flags has got KEYF_ANY set, the keybinding's own flags are ignored and any match is returned. If a keybinding matching keysym which has got KEYF_ANY set is found, the flags param is ignored and the binding is returned. Otherwise, return only bindings with matching modifier flags. |
scope | Determines which scope to search for the binding. 0 meaning char scope, non zero meaning global scope. |
Definition at line 200 of file keys.c.
References keybind::flags, KEYF_ANY, KEYF_MOD_MASK, KEYHASH, keys_char, keys_global, keybind::keysym, and keybind::next.
Referenced by configure_keys(), keybind_insert(), on_keybinding_button_bind_clicked(), parse_key(), and toggle_keybind_scope().
|
static |
Definition at line 303 of file keys.c.
Referenced by keybind_insert(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), toggle_keybind_scope(), and unbind_key().
|
static |
Updates the keys array with the keybinding that is passed.
It allocates memory for the array entry, then uses strdup_local() to allocate memory for the command being bound. This function is common to both gdk and x11 client.
keysym | A key to bind. |
flags | State that the keyboard is in. |
command | A command to bind to the key specified in keysym. |
Definition at line 229 of file keys.c.
References keybind::command, directions, EKEYBIND_NOMEM, keybind::flags, keybind_find(), keybind_free(), keybind_remove(), KEYF_R_GLOBAL, KEYHASH, keys_char, keys_global, keybind::keysym, LOG(), LOG_DEBUG, and keybind::next.
Referenced by configure_keys(), on_keybinding_button_bind_clicked(), on_keybinding_button_update_clicked(), parse_keybind_line(), and toggle_keybind_scope().
|
static |
Definition at line 283 of file keys.c.
References keybind::flags, KEYF_R_GLOBAL, KEYHASH, keys_char, keys_global, keybind::keysym, and keybind::next.
Referenced by keybind_insert(), keybindings_init(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), toggle_keybind_scope(), and unbind_key().
void keybindings_init | ( | const char * | character_name | ) |
Reads in the keybindings, and initializes special values.
Called from main() as part of the client start up. The function is common to both the x11 and gdk clients.
Definition at line 534 of file keys.c.
References altkeysym, BIG_BUF, cancelkeysym, commandkeysym, completekeysym, config_dir, cpl, csocket, firekeysym, history, in, init_default_keybindings(), keybind_remove(), KEYF_R_CHAR, KEYF_R_GLOBAL, KEYHASH, keys_char, keys_global, LOG(), LOG_DEBUG, MAX_HISTORY, metakeysym, Player_Struct::name, nextkeysym, parse_keys_file(), prevkeysym, runkeysym, and ClientSocket::servername.
Referenced by new_player(), send_create_player_to_server(), and toggle_keybind_scope().
void keyfunc | ( | GtkWidget * | widget, |
GdkEventKey * | event, | ||
GtkWidget * | window | ||
) |
GTK Callback function used to handle client key press events.
widget | |
event | GDK Key Press Event |
window |
Definition at line 1573 of file keys.c.
References cancelkeysym, client_disconnect(), Command_Mode, ClientSocket::command_received, ClientSocket::command_sent, completekeysym, CONFIG_DEBOUNCE, CONFIG_POPUPS, Configure_Keys, configure_keys(), cpl, csocket, debounce, entry_commands, fire_label, Player_Struct::fire_on, gtk_command_history(), gtk_complete_command(), Player_Struct::input_state, LOG(), LOG_ERROR, Metaserver_Select, nextkeysym, parse_key(), Playing, prevkeysym, Reply_Many, Reply_One, run_label, Player_Struct::run_on, send_reply(), stop_fire(), stop_run(), and use_config.
Referenced by init_ui().
void keyrelfunc | ( | GtkWidget * | widget, |
GdkEventKey * | event, | ||
GtkWidget * | window | ||
) |
GTK callback function used to handle client key release events.
widget | |
event | GDK Key Release Event |
window |
Definition at line 1558 of file keys.c.
References debounce, entry_commands, and parse_key_release().
Referenced by init_ui().
void keys_init | ( | GtkWidget * | window_root | ) |
One-time initialization of windows and signals for the keybindings dialog.
It is called from main() as part of the client start up. The function is common to both the x11 and gdk clients.
window_root | The client's main window. |
Definition at line 650 of file keys.c.
References dialog_xml, entry_commands, fire_label, kb_scope_togglebutton_character, kb_scope_togglebutton_global, keybinding_button_bind, keybinding_button_remove, keybinding_button_update, keybinding_checkbutton_alt, keybinding_checkbutton_any, keybinding_checkbutton_control, keybinding_checkbutton_edit, keybinding_checkbutton_meta, keybinding_checkbutton_shift, keybinding_entry_command, keybinding_entry_key, keybinding_selection, keybinding_selection_func(), keybinding_store, keybinding_treeview, keybinding_window, KEYHASH, keys_char, keys_global, KLIST_COMMAND, KLIST_EDIT, KLIST_KEY, KLIST_MODS, KLIST_SCOPE, on_count_changed(), on_entry_commands_activate(), on_kb_scope_togglebutton_character_toggled(), on_kb_scope_togglebutton_global_toggled(), on_keybinding_button_bind_clicked(), on_keybinding_button_clear_clicked(), on_keybinding_button_close_clicked(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), on_keybinding_checkbutton_any_clicked(), on_keybinding_entry_key_key_press_event(), run_label, spinbutton_count, and window_xml.
Referenced by init_ui().
|
static |
Definition at line 639 of file keys.c.
References Player_Struct::count, and cpl.
Referenced by keys_init().
void on_entry_commands_activate | ( | GtkEntry * | entry, |
gpointer | user_data | ||
) |
Used to process keyboard input whenever the player types commands into the command entry box.
entry | |
user_data |
Definition at line 1797 of file keys.c.
References CONFIG_POPUPS, Player_Struct::count, cpl, cur_history_position, extended_command(), history, Player_Struct::input_state, Player_Struct::input_text, MAX_COMMAND_LEN, MAX_HISTORY, Metaserver_Select, Playing, Reply_Many, Reply_One, scroll_history_position, send_reply(), spinbutton_count, treeview_look, and use_config.
Referenced by keys_init().
|
static |
Parses a keypress.
It should only be called when in Playing mode.
key | |
keysym |
Definition at line 841 of file keys.c.
References Player_Struct::alt_on, altkeysym, keybind::command, Command_Mode, commandkeysym, Player_Struct::count, COUNT_MAX, cpl, keybind::direction, draw_ext_info(), entry_commands, extended_command(), fire_dir(), fire_label, Player_Struct::fire_on, firekeysym, keybind::flags, Player_Struct::input_state, Player_Struct::input_text, keybind_find(), KEYF_EDIT, KEYF_MOD_ALT, KEYF_MOD_CTRL, KEYF_MOD_META, KEYF_MOD_SHIFT, keybind::keysym, MAX_BUF, Player_Struct::meta_on, metakeysym, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, Player_Struct::no_echo, run_dir(), run_label, Player_Struct::run_on, runkeysym, and spinbutton_count.
Referenced by keyfunc().
|
static |
The only things we actually care about is the run and fire keys.
Other key releases are not important. If it is the release of a run or fire key, we tell the client to stop firing or running. In some cases, it is possible that we actually are not running or firing, and in such cases, the server will just ignore the command.
This code is used by gdk and x11 client, but has a fair number of ifdefs to get the right behavior.
ks |
Definition at line 805 of file keys.c.
References Player_Struct::alt_on, altkeysym, clear_fire(), clear_run(), cpl, fire_label, Player_Struct::fire_on, firekeysym, keybind::keysym, Player_Struct::meta_on, metakeysym, run_label, Player_Struct::run_on, and runkeysym.
Referenced by keyrelfunc().
|
static |
This function is common to both gdk and x11 client.
buf | |
line | |
scope_flag | KEYF_R_GLOBAL or KEYF_R_CHAR determining scope. |
Definition at line 317 of file keys.c.
References altkeysym, bind_buf, commandkeysym, completekeysym, firekeysym, keybind::flags, keybind_insert(), KEYF_ANY, KEYF_EDIT, KEYF_MOD_ALT, KEYF_MOD_CTRL, KEYF_MOD_META, KEYF_MOD_SHIFT, keybind::keysym, LOG(), LOG_WARNING, metakeysym, nextkeysym, prevkeysym, and runkeysym.
Referenced by parse_keys_file().
|
static |
Opens a file and loads the keybinds contained in it.
filename | Name of the file to open. |
scope_flag | The scope this bindings should be loaded with. Should be one of KEYF_R_GLOBAL or KEYF_R_CHAR. Every binding in the file will have the same scope. |
Definition at line 504 of file keys.c.
References in, and parse_keybind_line().
Referenced by init_default_keybindings(), and keybindings_init().
|
static |
A recursive function that saves all the entries for a particular entry.
We save the first element first, and then go through and save the rest of the elements. In this way, the ordering of the key entries in the file remains the same.
fp | Pointer to an open file for writing key bind settings into. |
key | Pointer of a key hash record to save to the key bind file. During recursion, key takes the value key->next, and then returns when it becomes a NULL pointer. |
kc |
Definition at line 1263 of file keys.c.
References get_key_info(), and keybind::next.
Referenced by save_keys().
|
static |
Saves the keybindings into the user's .crossfire/keys file.
The output file is opened, then the special shift/modifier keys are written first. Next, the entire key hash is traversed and the contents of each slot is dumped to the file, and the output file is closed. Success or failure is reported to the message pane.
Definition at line 1277 of file keys.c.
References altkeysym, completekeysym, config_dir, cpl, csocket, draw_ext_info(), firekeysym, KEYHASH, keys_char, keys_global, LOG(), LOG_INFO, LOG_WARNING, make_path_to_file(), MAX_BUF, metakeysym, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, MSG_TYPE_CLIENT_ERROR, Player_Struct::name, NDI_BLACK, nextkeysym, prevkeysym, runkeysym, save_individual_key(), and ClientSocket::servername.
Referenced by configure_keys(), on_keybinding_button_bind_clicked(), on_keybinding_button_remove_clicked(), on_keybinding_button_update_clicked(), toggle_keybind_scope(), and unbind_key().
|
static |
Shows all the keybindings.
allbindings | Also shows the standard (default) keybindings. |
Definition at line 1031 of file keys.c.
References altkeysym, commandkeysym, completekeysym, draw_ext_info(), firekeysym, get_key_info(), KEYHASH, keys_char, keys_global, MAX_BUF, metakeysym, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, keybind::next, nextkeysym, prevkeysym, and runkeysym.
Referenced by unbind_key().
void unbind_key | ( | const char * | params | ) |
params |
Definition at line 1471 of file keys.c.
References draw_ext_info(), get_key_info(), keybind_free(), keybind_remove(), KEYHASH, keys_char, keys_global, LOG(), LOG_ERROR, MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, keybind::next, save_keys(), show_keys(), and unbind_usage().
|
static |
Show help for the unbind command in the message pane.
Definition at line 1460 of file keys.c.
References draw_ext_info(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, and NDI_BLACK.
Referenced by unbind_key().
void x_set_echo | ( | void | ) |
Definition at line 1710 of file keys.c.
References cpl, entry_commands, and Player_Struct::no_echo.
Referenced by handle_query(), and send_reply().
char* keybind::command |
Command string bound to a key.
Definition at line 105 of file keys.c.
Referenced by configure_keys(), get_key_info(), keybind_insert(), keybind_overwrite_confirm(), keybinding_get_data(), keybinding_selection_func(), on_keybinding_button_bind_clicked(), on_keybinding_button_update_clicked(), parse_key(), toggle_keybind_scope(), and update_keybinding_list().
|
static |
When a key is held down, prevent multiple commands from being sent without server acknowledgement by setting debounce when keys are pressed, and clearing it when the server acknowledges or when a key is released.
Definition at line 182 of file keys.c.
Referenced by keyfunc(), and keyrelfunc().
gint8 keybind::direction |
-1 non-direction key, else >= 0.
Definition at line 103 of file keys.c.
Referenced by gtk_command_history(), and parse_key().
guint8 keybind::flags |
KEYF_* flags set for the record.
Definition at line 102 of file keys.c.
Referenced by get_key_modchars(), keybind_find(), keybind_insert(), keybind_remove(), keybinding_get_data(), keybinding_selection_func(), on_keybinding_button_bind_clicked(), on_keybinding_button_update_clicked(), parse_key(), parse_keybind_line(), toggle_keybind_scope(), and update_keybinding_list().
guint32 keybind::keysym |
Key this binding record is for.
Definition at line 104 of file keys.c.
Referenced by configure_keys(), get_key_info(), keybind_find(), keybind_insert(), keybind_overwrite_confirm(), keybind_remove(), keybinding_get_data(), keybinding_selection_func(), on_keybinding_button_bind_clicked(), on_keybinding_button_update_clicked(), parse_key(), parse_key_release(), parse_keybind_line(), toggle_keybind_scope(), and update_keybinding_list().
struct keybind* keybind::next |
Definition at line 106 of file keys.c.
Referenced by keybind_find(), keybind_insert(), keybind_remove(), save_individual_key(), show_keys(), toggle_keybind_scope(), unbind_key(), and update_keybinding_list().