* Boston, MA 02111-1307, USA.
*/
+#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
static AccessibleKeystrokeListener *key_listener;
static AccessibleKeystrokeListener *switch_listener;
-static boolean shift_latched = False;
-static boolean caps_lock = False;
+static gboolean shift_latched = False;
+static gboolean caps_lock = False;
static GtkButton **buttons[MAX_ROWS];
typedef enum {
}
static void
-label_buttons(boolean shifted)
+label_buttons(gboolean shifted)
{
int i, j;
KeySym keysym;
}
static void
-show_shift (GtkButton *button, boolean *is_shifted)
+show_shift (GtkButton *button, gboolean *is_shifted)
{
label_buttons (*is_shifted ^ caps_lock);
}
keysynth_exit();
}
-static boolean
-is_command_key (void *p)
+static SPIBoolean
+is_command_key (AccessibleKeystroke *key)
{
- AccessibleKeyStroke *key = (AccessibleKeyStroke *)p;
switch (key->keyID)
{
case 'Q':
keysynth_exit();
return TRUE; /* not reached */
}
+ return FALSE;
}
-static boolean
-switch_callback (void *p)
+static SPIBoolean
+switch_callback (AccessibleKeystroke *key)
{
- AccessibleKeyStroke *key = (AccessibleKeyStroke *)p;
- static is_down = FALSE;
- if (key->type == Accessibility_KEY_RELEASED)
+ static gboolean is_down = FALSE;
+ if (key->type == SPI_KEY_RELEASED)
{
g_print ("spacebar up\n");
is_down = FALSE;
static void
create_vkbd()
{
- GtkWidget *window, *button, *container, *hbox;
+ GtkWidget *window, *container, *hbox;
int i, j;
KeyCode *keycodeptr, keycode = MIN_KEYCODE;
- static boolean true_val = True;
- static boolean false_val = False;
+ static gboolean true_val = True;
+ static gboolean false_val = False;
window = g_object_connect (gtk_widget_new (gtk_window_get_type (),
"user_data", NULL,
AccessibleKeySet switch_set;
if ((argc > 1) && (!strncmp(argv[1],"-h",2)))
- {
- printf ("Usage: keysynth-demo\n");
- exit(0);
- }
+ {
+ printf ("Usage: keysynth-demo\n");
+ exit (1);
+ }
gtk_init (&argc, &argv); /* must call, because this program uses GTK+ */
- SPI_init();
+ SPI_init ();
- key_listener = createAccessibleKeystrokeListener(is_command_key);
+ key_listener = createAccessibleKeystrokeListener (is_command_key);
/* will listen only to Alt-key combinations */
- registerAccessibleKeystrokeListener(key_listener,
- (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
- SPI_KEYMASK_ALT,
- (unsigned long) ( KeyPress | KeyRelease),
- SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS);
- create_vkbd();
+ registerAccessibleKeystrokeListener (key_listener,
+ (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
+ SPI_KEYMASK_ALT,
+ (unsigned long) ( KeyPress | KeyRelease),
+ SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS);
+ create_vkbd ();
/*
* Register a listener on an 'unused' key, to serve as a 'single switch'.
* On most Intel boxes there is at least one 'special' system key that does not
* have a non-zero keycode assigned in the Xserver, so we will intercept any keycode
- * that is 'zero'. Often these the "windows" key or the "menu" key.
+ * that is 'zero'. Often these the are the "windows" or the "menu" keys.
*/
switch_set.keysyms = g_new0 (unsigned long, 1);
switch_set.keycodes = g_new0 (unsigned short, 1);
switch_set.len = 1;
switch_set.keysyms[0] = (unsigned long) 0;
switch_set.keycodes[0] = (unsigned short) 0;
- switch_listener = createAccessibleKeystrokeListener(switch_callback);
- registerAccessibleKeystrokeListener(switch_listener,
- &switch_set,
- SPI_KEYMASK_UNMODIFIED,
- (unsigned long) ( KeyPress | KeyRelease),
- SPI_KEYLISTENER_CANCONSUME);
+ switch_listener = createAccessibleKeystrokeListener (switch_callback);
+ registerAccessibleKeystrokeListener (switch_listener,
+ &switch_set,
+ SPI_KEYMASK_UNMODIFIED,
+ (unsigned long) ( KeyPress | KeyRelease),
+ SPI_KEYLISTENER_CANCONSUME);
- SPI_event_main(TRUE);
+ SPI_event_main (TRUE);
+
+ return 0;
}