Crossfire Client, Branch  R11627
Data Structures | Defines | Functions | Variables
keys.c File Reference

Handles most of the keyboard related functions - binding and unbinding keys, and handling keypresses and looking up the keys. More...

#include <config.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include "client-types.h"
#include "main.h"
#include "client.h"
#include "proto.h"
#include "def-keys.h"
#include "image.h"
#include "gtk2proto.h"
#include "p_cmd.h"
Include dependency graph for keys.c:

Go to the source code of this file.

Data Structures

struct  Keys

Defines

#define KEYF_ALT   0x20
 For ALT key modifier.
#define KEYF_EDIT   0x08
 Line editor.
#define KEYF_FIRE   0x02
 Used in fire mode.
#define KEYF_META   0x40
 For Meta key modifier.
#define KEYF_MODIFIERS   0x67
 Mask for actual keyboard modifiers, not action modifiers.
#define KEYF_NORMAL   0x01
 Used in normal mode.
#define KEYF_RUN   0x04
 Used in run mode.
#define KEYF_STANDARD   0x10
 For standard/built-in keybinds.
#define KEYHASH   257

Typedefs

Key Entry Struct

EndOf Bind Log

A keybinding hash record structure.

typedef struct Keys Key_Entry

Enumerations

KList Enum

EndOf UI Widgets

Changed to KLIST_* to avoid conflicts in Win2000 and up

enum  {
  KLIST_ENTRY, KLIST_KEY, KLIST_MODS, KLIST_EDIT,
  KLIST_COMMAND, KLIST_KEY_ENTRY
}

Functions

void bind_key (char *params)
 Implements the "bind" command when entered as a text command.
static void configure_keys (uint32 keysym)
void draw_keybindings (GtkWidget *keylist)
 Output the current list of keybindings to the message pane.
void draw_prompt (const char *str)
 Draws a prompt.
static char * get_key_info (Key_Entry *key, int save_mode)
void gtk_command_history (int direction)
 Deals with command history.
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.
static void init_default_keybindings (void)
 Initialize the standard keybindings as specified in the def-keys.h file.
static void insert_key (uint32 keysym, int flags, const char *command)
 Updates the keys array with the keybinding that is passed.
static void keybinding_get_data (uint32 *keysym, uint8 *flags, const char **command)
 Gets the state information from what checkboxes and other data in the window and puts it in the variables passed passed.
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.
void keyfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 GTK Callback function used to handle client key press events.
void keyrelfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 GTK callback function used to handle client key release events.
void keys_init (GtkWidget *window_root)
 Reads in the keybindings, and initializes special values.
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.
void on_keybinding_button_bind_clicked (GtkButton *button, gpointer user_data)
 Sets up a new binding when the "Add" button is clicked.
void on_keybinding_button_clear_clicked (GtkButton *button, gpointer user_data)
 Implements the "Clear Fields" button function on the keybinding dialog.
void on_keybinding_button_close_clicked (GtkButton *button, gpointer user_data)
 Deactivates the keybinding dialog when the "Close Window" button is clicked.
void on_keybinding_button_remove_clicked (GtkButton *button, gpointer user_data)
 Implements the "Remove Binding" button function that unbinds the currently selected keybinding.
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.
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.
void on_keybindings_activate (GtkMenuItem *menuitem, gpointer user_data)
 Menubar item to activate keybindings window.
static void parse_key (char key, uint32 keysym)
 Parses a keypress.
static void parse_key_release (uint32 ks)
 The only things we actually care about is the run and fire keys.
static void parse_keybind_line (char *buf, int line, int standard)
 This function is common to both gdk and x11 client.
void reset_keybinding_status (void)
 Reset the state of the keybinding dialog.
static void save_individual_key (FILE *fp, Key_Entry *key, KeyCode kc)
 A recursive function that saves all the entries for a particular entry.
static void save_keys (void)
 Saves the keybindings into the user's .crossfire/keys file.
static void show_keys (int allbindings)
 Shows all the keybindings.
void unbind_key (const char *params)
static void unbind_usage (void)
 Show help for the unbind command in the message pane.
void update_keybinding_list (void)
 Update the keybinding dialog to reflect the current state of the keys file.
void x_set_echo (void)

Variables

static uint32 altkeysym [2]
static char bind_buf [MAX_BUF]
static int bind_flags = 0
static uint32bind_keysym
static uint32 cancelkeysym
static uint32 commandkeysym
static uint32 completekeysym
const char *const directions [9]
static uint32 firekeysym [2]
 EndOf Key Entry Struct.
static Key_Entrykeys [KEYHASH]
 Platform independence defines that we can't use keycodes.
static uint32 metakeysym [2]
static uint32 nextkeysym
static uint32 prevkeysym
const char *const rcsid_gtk2_keys_c = "$Id: keys.c 10827 2008-12-04 05:12:23Z kbulgrien $"
static uint32 runkeysym [2]
UI Widgets

Widgets for the keybinding dialog

static GtkWidget * fire_label
static GtkWidget * run_label
static GtkWidget * keybinding_window
static GtkWidget * keybinding_checkbutton_control
static GtkWidget * keybinding_checkbutton_shift
static GtkWidget * keybinding_checkbutton_alt
static GtkWidget * keybinding_checkbutton_meta
static GtkWidget * keybinding_checkbutton_edit
static GtkWidget * keybinding_entry_key
static GtkWidget * keybinding_entry_command
static GtkWidget * keybinding_treeview
static GtkWidget * keybinding_button_remove
static GtkWidget * keybinding_button_update
static GtkWidget * keybinding_button_bind
static GtkListStore * keybinding_store
 Bound key list for bind dialog.
static GtkTreeSelection * keybinding_selection
GtkWidget * spinbutton_count
GtkWidget * entry_commands

Bind Log

EndOf KList Enum

#define MAX_HISTORY   50
#define MAX_COMMAND_LEN   256
char history [MAX_HISTORY][MAX_COMMAND_LEN]
static int cur_history_position = 0
static int scroll_history_position = 0

Detailed Description

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 Documentation

#define KEYF_ALT   0x20
#define KEYF_EDIT   0x08
#define KEYF_FIRE   0x02
#define KEYF_META   0x40
#define KEYF_MODIFIERS   0x67

Mask for actual keyboard modifiers, not action modifiers.

Definition at line 149 of file keys.c.

Referenced by bind_key(), configure_keys(), draw_keybindings(), get_key_info(), keybinding_get_data(), parse_key(), and update_keybinding_list().

#define KEYF_NORMAL   0x01

Used in normal mode.

Definition at line 142 of file keys.c.

Referenced by bind_key(), draw_keybindings(), get_key_info(), keybinding_get_data(), parse_key(), and parse_keybind_line().

#define KEYF_RUN   0x04
#define KEYF_STANDARD   0x10

For standard/built-in keybinds.

Definition at line 146 of file keys.c.

Referenced by draw_keybindings(), get_key_info(), parse_keybind_line(), show_keys(), unbind_key(), and update_keybinding_list().

#define KEYHASH   257
#define MAX_COMMAND_LEN   256

Definition at line 100 of file keys.c.

Referenced by on_entry_commands_activate().

#define MAX_HISTORY   50

Definition at line 99 of file keys.c.

Referenced by gtk_command_history(), keys_init(), and on_entry_commands_activate().


Typedef Documentation

typedef struct Keys Key_Entry

Enumeration Type Documentation

anonymous enum
Enumerator:
KLIST_ENTRY 
KLIST_KEY 
KLIST_MODS 
KLIST_EDIT 
KLIST_COMMAND 
KLIST_KEY_ENTRY 

Definition at line 87 of file keys.c.


Variable Documentation

uint32 altkeysym[2] [static]
char bind_buf[MAX_BUF] [static]
int bind_flags = 0 [static]

Definition at line 139 of file keys.c.

Referenced by bind_key(), and configure_keys().

uint32 * bind_keysym [static]

Definition at line 135 of file keys.c.

Referenced by bind_key(), and configure_keys().

uint32 cancelkeysym [static]

Definition at line 135 of file keys.c.

Referenced by keyfunc(), and keys_init().

Definition at line 135 of file keys.c.

Referenced by bind_key(), keys_init(), parse_key(), parse_keybind_line(), save_keys(), and show_keys().

Definition at line 135 of file keys.c.

Referenced by bind_key(), keyfunc(), keys_init(), parse_keybind_line(), save_keys(), and show_keys().

int cur_history_position = 0 [static]

Definition at line 103 of file keys.c.

Referenced by gtk_command_history(), and on_entry_commands_activate().

const char* const directions[9]

Definition at line 48 of file player.c.

GtkWidget* entry_commands
GtkWidget* fire_label [static]

Definition at line 65 of file keys.c.

uint32 firekeysym[2] [static]

EndOf Key Entry Struct.

Definition at line 135 of file keys.c.

Referenced by bind_key(), configure_keys(), keys_init(), parse_key(), parse_key_release(), parse_keybind_line(), save_keys(), and show_keys().

Definition at line 101 of file keys.c.

Referenced by gtk_command_history(), keys_init(), and on_entry_commands_activate().

GtkWidget * keybinding_button_bind [static]

Definition at line 65 of file keys.c.

Referenced by keys_init().

GtkWidget * keybinding_button_remove [static]

Definition at line 65 of file keys.c.

Referenced by keybinding_selection_func(), keys_init(), and reset_keybinding_status().

GtkWidget * keybinding_button_update [static]

Definition at line 65 of file keys.c.

Referenced by keybinding_selection_func(), keys_init(), and reset_keybinding_status().

GtkWidget * keybinding_checkbutton_alt [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 [static]

Bound key list for bind dialog.

Definition at line 73 of file keys.c.

Referenced by keys_init(), and update_keybinding_list().

GtkWidget * keybinding_treeview [static]

Definition at line 65 of file keys.c.

Referenced by keys_init().

GtkWidget * keybinding_window [static]

Definition at line 65 of file keys.c.

Referenced by keys_init(), on_keybinding_button_close_clicked(), and on_keybindings_activate().

Key_Entry* keys[KEYHASH] [static]

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 155 of file keys.c.

uint32 metakeysym[2] [static]
uint32 nextkeysym [static]

Definition at line 135 of file keys.c.

Referenced by bind_key(), keyfunc(), keys_init(), parse_keybind_line(), save_keys(), and show_keys().

uint32 prevkeysym [static]

Definition at line 135 of file keys.c.

Referenced by bind_key(), keyfunc(), keys_init(), parse_keybind_line(), save_keys(), and show_keys().

const char* const rcsid_gtk2_keys_c = "$Id: keys.c 10827 2008-12-04 05:12:23Z kbulgrien $"

Definition at line 1 of file keys.c.

GtkWidget * run_label [static]

Definition at line 65 of file keys.c.

uint32 runkeysym[2] [static]
int scroll_history_position = 0 [static]

Definition at line 103 of file keys.c.

Referenced by gtk_command_history(), and on_entry_commands_activate().

GtkWidget* spinbutton_count

Definition at line 76 of file keys.c.

Referenced by keys_init(), list_item_action(), and parse_key().