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 <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include "client-types.h"
#include "gx11.h"
#include "client.h"
#include "p_cmd.h"
#include "def-keys.h"
#include "gtkproto.h"
+ Include dependency graph for keys.c:

Go to the source code of this file.

Data Structures

struct  Keys
 

Macros

#define KEYF_EDIT   0x08 /* Line editor */
 
#define KEYF_FIRE   0x02 /* Used in fire mode */
 
#define KEYF_MODIFIERS   0x07 /* Mask for actual keyboard 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) key definitions */
 
#define KEYHASH   257
 

Typedefs

typedef struct Keys Key_Entry
 

Functions

void bind_callback (GtkWidget *gtklist, GdkEventButton *event)
 
void bind_key (const char *params)
 
void ckeyclear (void)
 
void ckeyentry_callback (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 
void ckeyunbind (GtkWidget *gtklist, GdkEventButton *event)
 
static void configure_keys (uint32 keysym)
 
void disconnect (GtkWidget *)
 
void draw_keybindings (GtkWidget *keylist)
 
static char * get_key_info (Key_Entry *key, int save_mode)
 
static void init_default_keybindings (void)
 
void init_keys (void)
 
static void insert_key (uint32 keysym, int flags, const char *command)
 
void keyfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 
void keyrelfunc (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
 
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)
 
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)
 

Variables

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 nextkeysym
 
static uint32 prevkeysym
 
const char *const rcsid_gtk_keys_c
 
static uint32 runkeysym [2]
 

Detailed Description

Handles most of the GTK V1 client keyboard related functions. This includes binding and unbinding keys, handling keypresses, and looking up the keys.

Definition in file keys.c.

Macro Definition Documentation

#define KEYF_EDIT   0x08 /* Line editor */

Definition at line 97 of file keys.c.

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

#define KEYF_FIRE   0x02 /* Used in fire mode */
#define KEYF_MODIFIERS   0x07 /* Mask for actual keyboard modifiers, */
#define KEYF_NORMAL   0x01 /* Used in normal mode */

Definition at line 92 of file keys.c.

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

#define KEYF_RUN   0x04 /* Used in run mode */
#define KEYF_STANDARD   0x10 /* For standard (built in) key definitions */

Definition at line 98 of file keys.c.

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

#define KEYHASH   257

Typedef Documentation

typedef struct Keys Key_Entry

Function Documentation

void bind_callback ( GtkWidget *  gtklist,
GdkEventButton *  event 
)

Definition at line 1181 of file keys.c.

References bind_flags, cclist, ckentrytext, ckeyentrytext, cmodentrytext, draw_info(), draw_keybindings(), insert_key(), KEYF_FIRE, KEYF_MODIFIERS, KEYF_RUN, Keys::keysym, MAX_BUF, NDI_BLACK, and save_keys().

Referenced by configdialog().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void bind_key ( const char *  params)

Definition at line 648 of file keys.c.

void ckeyclear ( void  )

Definition at line 1251 of file keys.c.

References ckentrytext, ckeyentrytext, cmodentrytext, and cnumentrytext.

Referenced by configdialog().

+ Here is the caller graph for this function:

void ckeyentry_callback ( GtkWidget *  widget,
GdkEventKey *  event,
GtkWidget *  window 
)

Definition at line 1233 of file keys.c.

References ckeyentrytext, and cmodentrytext.

Referenced by configdialog().

+ Here is the caller graph for this function:

void ckeyunbind ( GtkWidget *  gtklist,
GdkEventButton *  event 
)

Definition at line 1214 of file keys.c.

References cclist, draw_keybindings(), and unbind_key().

Referenced by configdialog().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void configure_keys ( uint32  keysym)
static

Definition at line 855 of file keys.c.

References bind_buf, bind_flags, bind_keysym, cpl, draw_info(), draw_message_window(), Player_Struct::fire_on, firekeysym, Player_Struct::input_state, insert_key(), KEYF_FIRE, KEYF_MODIFIERS, KEYF_RUN, Keys::keysym, MAX_BUF, NDI_BLACK, Playing, Player_Struct::run_on, runkeysym, and save_keys().

Referenced by do_key_press(), and keyfunc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void disconnect ( GtkWidget *  )

Definition at line 2773 of file gx11.c.

References cleanup_textmanagers(), csocket, csocket_fd, and ClientSocket::fd.

Referenced by cancelConnection(), get_menu_display(), and keyfunc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void draw_keybindings ( GtkWidget *  keylist)

Definition at line 1129 of file keys.c.

Referenced by bind_callback(), and ckeyunbind().

+ Here is the caller graph for this function:

static char* get_key_info ( Key_Entry key,
int  save_mode 
)
static

Definition at line 544 of file keys.c.

References bind_buf, Keys::command, Keys::flags, KEYF_EDIT, KEYF_FIRE, KEYF_MODIFIERS, KEYF_NORMAL, KEYF_RUN, KEYF_STANDARD, Keys::keysym, and MAX_BUF.

Referenced by save_individual_key(), show_keys(), and unbind_key().

+ Here is the caller graph for this function:

static void init_default_keybindings ( void  )
static

Definition at line 285 of file keys.c.

References def_keys, MAX_BUF, and parse_keybind_line().

Referenced by init_keys().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void init_keys ( void  )

Definition at line 302 of file keys.c.

static void insert_key ( uint32  keysym,
int  flags,
const char *  command 
)
static

Definition at line 116 of file keys.c.

References Keys::command, Keys::direction, directions, Keys::flags, KEYHASH, Keys::keysym, Keys::next, and strdup_local().

Referenced by bind_callback(), configure_keys(), and parse_keybind_line().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void keyfunc ( GtkWidget *  widget,
GdkEventKey *  event,
GtkWidget *  window 
)

Definition at line 1008 of file keys.c.

void keyrelfunc ( GtkWidget *  widget,
GdkEventKey *  event,
GtkWidget *  window 
)

Definition at line 994 of file keys.c.

static void parse_key_release ( uint32  ks)
static

Definition at line 407 of file keys.c.

References clear_fire(), clear_run(), CONFIG_ECHO, cpl, draw_info(), fire_label, Player_Struct::fire_on, firekeysym, NDI_BLACK, run_label, Player_Struct::run_on, runkeysym, and use_config.

Referenced by check_x_events(), and keyrelfunc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void parse_keybind_line ( char *  buf,
int  line,
int  standard 
)
static

Definition at line 156 of file keys.c.

References bind_buf, commandkeysym, completekeysym, firekeysym, Keys::flags, insert_key(), KEYF_EDIT, KEYF_FIRE, KEYF_NORMAL, KEYF_RUN, KEYF_STANDARD, Keys::keysym, LOG(), LOG_WARNING, nextkeysym, prevkeysym, and runkeysym.

Referenced by init_default_keybindings(), and init_keys().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void save_individual_key ( FILE *  fp,
Key_Entry key,
KeyCode  kc 
)
static

Definition at line 781 of file keys.c.

References get_key_info(), and Keys::next.

Referenced by save_keys().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void save_keys ( void  )
static

Definition at line 788 of file keys.c.

References commandkeysym, completekeysym, cpl, draw_info(), firekeysym, KEYHASH, LOG(), LOG_WARNING, make_path_to_file(), MAX_BUF, Player_Struct::name, NDI_BLACK, nextkeysym, prevkeysym, runkeysym, and save_individual_key().

Referenced by bind_callback(), configure_keys(), and unbind_key().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void show_keys ( int  allbindings)
static

Definition at line 599 of file keys.c.

References bind_buf, commandkeysym, completekeysym, draw_info(), firekeysym, Keys::flags, get_key_info(), KEYF_STANDARD, KEYHASH, MAX_BUF, NDI_BLACK, Keys::next, nextkeysym, prevkeysym, and runkeysym.

Referenced by unbind_key().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void unbind_key ( const char *  params)

Definition at line 918 of file keys.c.

Referenced by ckeyunbind().

+ Here is the caller graph for this function:

static void unbind_usage ( void  )
static

Definition at line 910 of file keys.c.

References draw_info(), and NDI_BLACK.

Referenced by unbind_key().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

char bind_buf[MAX_BUF]
static

Definition at line 90 of file keys.c.

Referenced by bind_key(), configure_keys(), get_key_info(), parse_keybind_line(), show_keys(), and unbind_key().

int bind_flags =0
static

Definition at line 89 of file keys.c.

Referenced by bind_callback(), bind_key(), and configure_keys().

uint32 * bind_keysym
static

Definition at line 87 of file keys.c.

Referenced by bind_key(), and configure_keys().

uint32 cancelkeysym
static

Definition at line 87 of file keys.c.

Referenced by init_keys(), and keyfunc().

uint32 commandkeysym
static

Definition at line 87 of file keys.c.

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

uint32 completekeysym
static

Definition at line 87 of file keys.c.

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

const char* const directions[9]

Definition at line 48 of file player.c.

Referenced by insert_key().

uint32 firekeysym[2]
static
Key_Entry* keys[KEYHASH]
static

Definition at line 107 of file keys.c.

uint32 nextkeysym
static

Definition at line 87 of file keys.c.

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

uint32 prevkeysym
static

Definition at line 87 of file keys.c.

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

const char* const rcsid_gtk_keys_c
Initial value:
=
"$Id: keys.c 10997 2008-12-17 03:36:53Z kbulgrien $"

Definition at line 1 of file keys.c.

uint32 runkeysym[2]
static