2 #include <atspi/atspi.h>
3 #include "keyboard_tracker.h"
6 static AtspiDeviceListener *listener;
7 static Keyboard_Tracker_Cb user_cb;
8 static void *user_data;
10 static gboolean device_cb(const AtspiDeviceEvent *stroke, void *data)
13 if (!strcmp(stroke->event_string, "KP_Up"))
15 else if (!strcmp(stroke->event_string, "KP_Down"))
17 else if (!strcmp(stroke->event_string, "KP_Left"))
19 else if (!strcmp(stroke->event_string, "KP_Right"))
25 user_cb(user_data, k);
30 void keyboard_tracker_init(void)
33 listener = atspi_device_listener_new(device_cb, NULL, NULL);
34 atspi_register_keystroke_listener(listener, NULL, 0, ATSPI_KEY_PRESSED, ATSPI_KEYLISTENER_SYNCHRONOUS|ATSPI_KEYLISTENER_CANCONSUME, NULL);
35 DEBUG("keyboard tracker init");
38 void keyboard_tracker_register(Keyboard_Tracker_Cb cb, void *data)
44 void keyboard_tracker_shutdown(void)
46 atspi_deregister_keystroke_listener(listener, NULL, 0, ATSPI_KEY_PRESSED, NULL);
47 DEBUG("keyboard tracker shutdown");