Ejemplo n.º 1
0
/**
 * keyboard_cb
 * @widget: widget
 * @event: event
 * @data: callback data
 *
 * Description:
 * handles keyboard events
 *
 * Returns:
 * TRUE if the event is handled
 **/
gint
keyboard_cb (GtkWidget * widget, GdkEventKey * event, gpointer data)
{
  gint i, keyval;

  /* This is a bit of a kludge to let through accelerator keys, otherwise
   * if N is used as a key, then Ctrl-N is never picked up. The cleaner
   * option, making the signal a connect_after signal skims the arrow keys
   * before we can get to them which is a bigger problem. */
  if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
    return FALSE;

  keyval = toupper(event->keyval);

  for (i = 0; i < 12; ++i) {
    if (keyval == toupper(control_keys[i])) {
      game_keypress (i);
      return TRUE;
    }
  }

  return FALSE;
}
Ejemplo n.º 2
0
static void
wait_cb (GtkAction * action, gpointer data)
{
  game_keypress (KBD_WAIT);
}
Ejemplo n.º 3
0
static void
randteleport_cb (GtkAction * action, gpointer data)
{
  game_keypress (KBD_RTEL);
}