Crossfire Client, Branches  R11627
keys.c File Reference
#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
 

Macros

#define KEYF_ALT   0x20
 
#define KEYF_EDIT   0x08
 
#define KEYF_FIRE   0x02
 
#define KEYF_META   0x40
 
#define KEYF_MODIFIERS   0x67
 
#define KEYF_NORMAL   0x01
 
#define KEYF_RUN   0x04
 
#define KEYF_STANDARD   0x10
 
#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)
 
static void configure_keys (uint32 keysym)
 
void draw_keybindings (GtkWidget *keylist)
 
void draw_prompt (const char *str)
 
static char * get_key_info (Key_Entry *key, int save_mode)
 
void gtk_command_history (int direction)
 
void gtk_complete_command (void)
 
static void init_default_keybindings (void)
 
static void insert_key (uint32 keysym, int flags, const char *command)
 
static void keybinding_get_data (uint32 *keysym, uint8 *flags, const char **command)
 
gboolean keybinding_selection_func (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata)
 
void keyfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 
void keyrelfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 
void keys_init (GtkWidget *window_root)
 
void on_entry_commands_activate (GtkEntry *entry, gpointer user_data)
 
void on_keybinding_button_bind_clicked (GtkButton *button, gpointer user_data)
 
void on_keybinding_button_clear_clicked (GtkButton *button, gpointer user_data)
 
void on_keybinding_button_close_clicked (GtkButton *button, gpointer user_data)
 
void on_keybinding_button_remove_clicked (GtkButton *button, gpointer user_data)
 
void on_keybinding_button_update_clicked (GtkButton *button, gpointer user_data)
 
gboolean on_keybinding_entry_key_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
void on_keybindings_activate (GtkMenuItem *menuitem, gpointer user_data)
 
static void parse_key (char key, uint32 keysym)
 
static void parse_key_release (uint32 ks)
 
static void parse_keybind_line (char *buf, int line, int standard)
 
void reset_keybinding_status (void)
 
static void save_individual_key (FILE *fp, Key_Entry *key, KeyCode kc)
 
static void save_keys (void)
 
static void show_keys (int allbindings)
 
void unbind_key (const char *params)
 
static void unbind_usage (void)
 
void update_keybinding_list (void)
 
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]
 
static Key_Entrykeys [KEYHASH]
 
static uint32 metakeysym [2]
 
static uint32 nextkeysym
 
static uint32 prevkeysym
 
const char *const rcsid_gtk2_keys_c
 
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
 
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.

Macro Definition 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(), 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(), 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 get_key_info(), parse_keybind_line(), show_keys(), unbind_key(), and update_keybinding_list().

#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().

uint32 commandkeysym
static

Definition at line 135 of file keys.c.

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

uint32 completekeysym
static

Definition at line 135 of file keys.c.

Referenced by bind_key(), 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.

Referenced by keyfunc(), keys_init(), parse_key(), and parse_key_release().

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_keybind_line(), save_keys(), and show_keys().

char history[MAX_HISTORY][MAX_COMMAND_LEN]

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

uint32 metakeysym[2]
static
uint32 nextkeysym
static

Definition at line 135 of file keys.c.

Referenced by bind_key(), 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(), keys_init(), parse_keybind_line(), save_keys(), and show_keys().

const char* const rcsid_gtk2_keys_c
Initial value:
=
"$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.

Referenced by keyfunc(), keys_init(), parse_key(), and parse_key_release().

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().