![]() |
Crossfire Client, Trunk
|
#include "client.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "main.h"
#include "proto.h"
#include "image.h"
#include "gtk2proto.h"
#include "p_cmd.h"
Go to the source code of this file.
Data Structures | |
struct | keybind |
Enumerations | |
KList Enum | |
EndOf UI Widgets Changed to KLIST_* to avoid conflicts in Win2000 and up | |
enum | { KLIST_ENTRY, KLIST_KEY, KLIST_MODS, KLIST_SCOPE, KLIST_EDIT, KLIST_COMMAND, KLIST_KEY_ENTRY } |
Functions | |
static int | keybind_overwrite_confirm (struct keybind *kb) |
Shows a dialog that prompts for confirmation before overwriting a keybind, showing details of the keybind we are about to overwrite. More... | |
static void | keybinding_get_data (guint32 *keysym, guint8 *flags, const char **command) |
Gets the state information from checkboxes and other data in the window and puts it in the variables passed. More... | |
gboolean | keybinding_selection_func (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata) |
Called when the user clicks one of the entries in the list of keybindings and places information about it into the input fields on the dialog. More... | |
void | on_kb_scope_togglebutton_character_toggled (GtkToggleButton *toggle_button, gpointer user_data) |
Called when "This character" is clicked. More... | |
void | on_kb_scope_togglebutton_global_toggled (GtkToggleButton *toggle_button, gpointer user_data) |
Called when "All characters" is clicked. More... | |
void | on_keybinding_button_bind_clicked (GtkButton *button, gpointer user_data) |
Sets up a new binding when the "Add" button is clicked. More... | |
void | on_keybinding_button_clear_clicked (GtkButton *button, gpointer user_data) |
Implements the "Clear Fields" button function on the keybinding dialog. More... | |
void | on_keybinding_button_close_clicked (GtkButton *button, gpointer user_data) |
Deactivates the keybinding dialog when the "Close Window" button is clicked. More... | |
void | on_keybinding_button_remove_clicked (GtkButton *button, gpointer user_data) |
Implements the "Remove Binding" button function that unbinds the currently selected keybinding. More... | |
void | on_keybinding_button_update_clicked (GtkButton *button, gpointer user_data) |
Implements the "Update Binding" button to update the currently selected keybinding to match the currently shown identifiers, key, or command input fields. More... | |
void | on_keybinding_checkbutton_any_clicked (GtkCheckButton *cb, gpointer user_data) |
Deactivate the modifier checkboxes if "Any" is selected. More... | |
gboolean | on_keybinding_entry_key_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) |
Respond to a key press in the "Key" input box. More... | |
void | on_keybindings_activate (GtkMenuItem *menuitem, gpointer user_data) |
Menubar item to activate keybindings window. More... | |
void | reset_keybinding_status (void) |
Reset the state of the keybinding dialog. More... | |
void | toggle_buttons_scope (int scope) |
Toggles buttons state to reflect a scope state. More... | |
void | toggle_keybind_scope (int scope, struct keybind *kb) |
Toggles a keybinding's scope to the desired value. More... | |
void | update_keybinding_list (void) |
Update the keybinding dialog to reflect the current state of the keys file. More... | |
Variables | |
const int | COUNT_MAX = 10000000 |
UI Widgets | |
Widgets for the keybinding dialog | |
GtkWidget * | entry_commands |
static GtkWidget * | fire_label |
static GtkWidget * | kb_scope_togglebutton_character |
static GtkWidget * | kb_scope_togglebutton_global |
static GtkWidget * | keybinding_button_bind |
static GtkWidget * | keybinding_button_remove |
static GtkWidget * | keybinding_button_update |
static GtkWidget * | keybinding_checkbutton_alt |
static GtkWidget * | keybinding_checkbutton_any |
static GtkWidget * | keybinding_checkbutton_control |
static GtkWidget * | keybinding_checkbutton_edit |
static GtkWidget * | keybinding_checkbutton_meta |
static GtkWidget * | keybinding_checkbutton_shift |
static GtkWidget * | keybinding_entry_command |
static GtkWidget * | keybinding_entry_key |
static GtkTreeSelection * | keybinding_selection |
static GtkListStore * | keybinding_store |
Bound key list for bind dialog. More... | |
static GtkWidget * | keybinding_treeview |
static GtkWidget * | keybinding_window |
static GtkWidget * | run_label |
GtkWidget * | spinbutton_count |
Bind Log | |
static int | cur_history_position = 0 |
char | history [MAX_HISTORY][MAX_COMMAND_LEN] |
#define | MAX_COMMAND_LEN 256 |
#define | MAX_HISTORY 50 |
static int | scroll_history_position = 0 |
key_entry struct | |
A keybinding hash record structure. | |
static guint32 | altkeysym [2] |
static char | bind_buf [MAX_BUF] |
static int | bind_flags = 0 |
void | bind_key (char *params) |
Implements the "bind" command when entered as a text command. More... | |
static guint32 * | bind_keysym |
static guint32 | cancelkeysym |
static guint32 | commandkeysym |
static guint32 | completekeysym |
static void | configure_keys (guint32 keysym) |
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... | |
const char *const | directions [9] |
256-length array to keep track of when commands were sent to the server More... | |
void | draw_prompt (const char *str) |
Draws a prompt. More... | |
#define | EKEYBIND_NOMEM 1 |
static guint32 | firekeysym [2] |
void | focusoutfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
When the main window looses its focus, act as if all keys have been released. More... | |
static char * | get_key_info (struct keybind *kb, int save_mode) |
static void | get_key_modchars (struct keybind *kb, int save_mode, char *buf) |
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... | |
static void | init_default_keybindings () |
Load pre-compiled built-in default keybindings. More... | |
static struct keybind * | keybind_find (guint32 keysym, unsigned int flags, int scope) |
Find a keybinding for keysym. More... | |
static void | keybind_free (struct keybind **entry) |
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) |
void | keybindings_init (const char *character_name) |
Reads in the keybindings, and initializes special values. More... | |
#define | KEYF_ANY (1 << 4) |
Don't care about modifiers. More... | |
#define | KEYF_EDIT (1 << 5) |
Enter command mode. More... | |
#define | KEYF_MOD_ALT (1 << 2) |
For ALT key modifier. More... | |
#define | KEYF_MOD_CTRL (1 << 1) |
Used in run mode. More... | |
#define | KEYF_MOD_MASK |
#define | KEYF_MOD_META (1 << 3) |
For Meta key modifier. More... | |
#define | KEYF_MOD_SHIFT (1 << 0) |
Used in fire mode. More... | |
#define | KEYF_R_CHAR (1 << 7) |
Character specific. More... | |
#define | KEYF_R_GLOBAL (1 << 6) |
Save at user's file. More... | |
void | keyfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
GTK Callback function used to handle client key press events. More... | |
#define | KEYHASH 257 |
void | keyrelfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window) |
GTK callback function used to handle client key release events. More... | |
static struct keybind * | keys_char [KEYHASH] |
static struct keybind * | keys_global [KEYHASH] |
Will hold the keybindings into two separate hashes depending on the scope they afect (global or character). More... | |
void | keys_init (GtkWidget *window_root) |
One-time initialization of windows and signals for the keybindings dialog. More... | |
static guint32 | metakeysym [2] |
static guint32 | nextkeysym |
static void | on_count_changed (GtkSpinButton *spinbutton, gpointer *data) |
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... | |
static void | parse_key (char key, guint32 keysym) |
Parses a keypress. 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_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 guint32 | prevkeysym |
static guint32 | runkeysym [2] |
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 | show_keys (void) |
Shows all the keybindings. More... | |
void | unbind_key (const char *params) |
static void | unbind_usage (void) |
Show help for the unbind command in the message pane. More... | |
void | x_set_echo (void) |
Handles most of the keyboard related functions - binding and unbinding keys, and handling keypresses and looking up the keys.
Definition in file keys.c.
#define KEYF_MOD_MASK |
anonymous enum |
|
static |
Definition at line 122 of file keys.c.
Referenced by bind_key(), configure_keys(), keybindings_init(), parse_key(), parse_key_release(), parse_keybind_line(), save_keys(), and show_keys().
|
static |
Definition at line 126 of file keys.c.
Referenced by bind_key(), configure_keys(), get_key_info(), keybinding_get_data(), and parse_keybind_line().
|
static |
Definition at line 125 of file keys.c.
Referenced by bind_key(), and configure_keys().
|
static |
Definition at line 121 of file keys.c.
Referenced by bind_key(), and configure_keys().
|
static |
Definition at line 123 of file keys.c.
Referenced by keybindings_init(), and keyfunc().
|
static |
Definition at line 121 of file keys.c.
Referenced by bind_key(), keybindings_init(), parse_key(), parse_keybind_line(), and show_keys().
|
static |
Definition at line 122 of file keys.c.
Referenced by bind_key(), keybindings_init(), keyfunc(), parse_keybind_line(), save_keys(), and show_keys().
const int COUNT_MAX = 10000000 |
Definition at line 40 of file keys.c.
Referenced by parse_key().
|
static |
Definition at line 91 of file keys.c.
Referenced by gtk_command_history(), and on_entry_commands_activate().
const char* const directions[9] |
256-length array to keep track of when commands were sent to the server
Array for direction strings for each numeric direction.
Definition at line 41 of file player.c.
Referenced by command_to_direction(), dir_to_command(), and keybind_insert().
GtkWidget* entry_commands |
Definition at line 65 of file keys.c.
Referenced by draw_prompt(), gtk_command_history(), gtk_complete_command(), keyfunc(), keyrelfunc(), keys_init(), parse_key(), and x_set_echo().
|
static |
Definition at line 51 of file keys.c.
Referenced by focusoutfunc(), keyfunc(), keys_init(), parse_key(), and parse_key_release().
|
static |
Definition at line 121 of file keys.c.
Referenced by bind_key(), configure_keys(), keybindings_init(), parse_key(), parse_key_release(), parse_keybind_line(), save_keys(), and show_keys().
char history[MAX_HISTORY][MAX_COMMAND_LEN] |
Definition at line 89 of file keys.c.
Referenced by gtk_command_history(), keybindings_init(), and on_entry_commands_activate().
|
static |
Definition at line 52 of file keys.c.
Referenced by keys_init(), on_kb_scope_togglebutton_character_toggled(), and toggle_buttons_scope().
|
static |
Definition at line 52 of file keys.c.
Referenced by keybinding_get_data(), keys_init(), on_kb_scope_togglebutton_global_toggled(), and toggle_buttons_scope().
|
static |
Definition at line 59 of file keys.c.
Referenced by keys_init().
|
static |
Definition at line 58 of file keys.c.
Referenced by keybinding_selection_func(), keys_init(), and reset_keybinding_status().
|
static |
Definition at line 58 of file keys.c.
Referenced by keybinding_selection_func(), keys_init(), and reset_keybinding_status().
|
static |
Definition at line 55 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), on_keybinding_checkbutton_any_clicked(), on_keybinding_entry_key_key_press_event(), and reset_keybinding_status().
|
static |
Definition at line 53 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), and reset_keybinding_status().
|
static |
Definition at line 54 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), on_keybinding_checkbutton_any_clicked(), on_keybinding_entry_key_key_press_event(), and reset_keybinding_status().
|
static |
Definition at line 56 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), and reset_keybinding_status().
|
static |
Definition at line 55 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), on_keybinding_checkbutton_any_clicked(), on_keybinding_entry_key_key_press_event(), and reset_keybinding_status().
|
static |
Definition at line 54 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), on_keybinding_checkbutton_any_clicked(), on_keybinding_entry_key_key_press_event(), and reset_keybinding_status().
|
static |
Definition at line 57 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), and reset_keybinding_status().
|
static |
Definition at line 56 of file keys.c.
Referenced by keybinding_get_data(), keybinding_selection_func(), keys_init(), on_keybinding_entry_key_key_press_event(), and reset_keybinding_status().
|
static |
Definition at line 62 of file keys.c.
Referenced by keys_init(), on_kb_scope_togglebutton_character_toggled(), on_kb_scope_togglebutton_global_toggled(), on_keybinding_button_clear_clicked(), on_keybinding_button_remove_clicked(), and on_keybinding_button_update_clicked().
|
static |
Bound key list for bind dialog.
Definition at line 61 of file keys.c.
Referenced by keys_init(), and update_keybinding_list().
|
static |
Definition at line 57 of file keys.c.
Referenced by keys_init().
|
static |
Definition at line 51 of file keys.c.
Referenced by keybind_overwrite_confirm(), keys_init(), on_keybinding_button_close_clicked(), and on_keybindings_activate().
Definition at line 168 of file keys.c.
Referenced by keybind_find(), keybind_insert(), keybind_remove(), keybindings_init(), keys_init(), save_keys(), show_keys(), unbind_key(), and update_keybinding_list().
Will hold the keybindings into two separate hashes depending on the scope they afect (global or character).
This allows editting both scopes at the same time and switch scopes for a certain binding with ease.
Platform independence defines that we can't use keycodes. Instead, make it a hash, and set KEYHASH to a prime number for this purpose.
Definition at line 168 of file keys.c.
Referenced by keybind_find(), keybind_insert(), keybind_remove(), keybindings_init(), keys_init(), save_keys(), show_keys(), toggle_keybind_scope(), unbind_key(), and update_keybinding_list().
|
static |
Definition at line 122 of file keys.c.
Referenced by bind_key(), configure_keys(), keybindings_init(), parse_key(), parse_key_release(), parse_keybind_line(), save_keys(), and show_keys().
|
static |
Definition at line 122 of file keys.c.
Referenced by bind_key(), keybindings_init(), keyfunc(), parse_keybind_line(), save_keys(), and show_keys().
|
static |
Definition at line 122 of file keys.c.
Referenced by bind_key(), keybindings_init(), keyfunc(), parse_keybind_line(), save_keys(), and show_keys().
|
static |
Definition at line 51 of file keys.c.
Referenced by focusoutfunc(), keyfunc(), keys_init(), parse_key(), and parse_key_release().
|
static |
Definition at line 121 of file keys.c.
Referenced by bind_key(), configure_keys(), keybindings_init(), parse_key(), parse_key_release(), parse_keybind_line(), save_keys(), and show_keys().
|
static |
Definition at line 91 of file keys.c.
Referenced by gtk_command_history(), and on_entry_commands_activate().
GtkWidget* spinbutton_count |
Definition at line 64 of file keys.c.
Referenced by keys_init(), list_item_drop(), on_entry_commands_activate(), and parse_key().