1.1 --- a/src/display.c Tue Jan 01 05:08:38 2008 +0000
1.2 +++ b/src/display.c Sat Jan 26 02:45:27 2008 +0000
1.4 input_key_callback_t callback;
1.7 + struct keymap_entry *next; // allow chaining
1.10 +typedef struct mouse_entry {
1.11 + gboolean relative;
1.12 + input_mouse_callback_t callback;
1.14 + struct mouse_entry *next;
1.18 * Colour format information
1.21 * FIXME: make this more memory efficient
1.23 struct keymap_entry *keymap[65536];
1.25 +struct keymap_entry *keyhooks = NULL;
1.26 +struct mouse_entry *mousehooks = NULL;
1.28 static struct keymap_entry *input_create_key( uint16_t keycode )
1.30 @@ -113,14 +122,85 @@
1.31 void input_unregister_key( const gchar *keysym, input_key_callback_t callback,
1.32 void *data, uint32_t value )
1.34 - if( display_driver == NULL || keysym == NULL )
1.35 + if( display_driver == NULL || keysym == NULL || display_driver->resolve_keysym == NULL )
1.37 uint16_t keycode = display_driver->resolve_keysym(keysym);
1.40 input_delete_key( keycode, callback, data, value );
1.44 +gboolean input_register_hook( input_key_callback_t callback,
1.47 + keymap_entry_t key = malloc( sizeof( struct keymap_entry ) );
1.48 + assert( key != NULL );
1.49 + key->callback = callback;
1.51 + key->next = keyhooks;
1.56 +void input_unregister_hook( input_key_callback_t callback,
1.59 + keymap_entry_t key = keyhooks;
1.60 + if( key != NULL ) {
1.61 + keymap_entry_t next = key->next;
1.62 + if( key->callback == callback && key->data == data ) {
1.67 + while( next != NULL ) {
1.68 + if( next->callback == callback && next->data == data ) {
1.69 + key->next = next->next;
1.76 +gboolean input_register_mouse_hook( gboolean relative, input_mouse_callback_t callback,
1.79 + mouse_entry_t ent = malloc( sizeof( struct mouse_entry ) );
1.80 + assert( ent != NULL );
1.81 + ent->callback = callback;
1.83 + ent->next = mousehooks;
1.88 +void input_unregister_mouse_hook( input_mouse_callback_t callback, void *data )
1.90 + mouse_entry_t ent = mousehooks;
1.91 + if( ent != NULL ) {
1.92 + mouse_entry_t next = ent->next;
1.93 + if( ent->callback == callback && ent->data == data ) {
1.95 + mousehooks = next;
1.98 + while( next != NULL ) {
1.99 + if( next->callback == callback && next->data == data ) {
1.100 + ent->next = next->next;
1.107 +void input_event_mouse( uint32_t buttons, int32_t x, int32_t y )
1.109 + mouse_entry_t ent = mousehooks;
1.110 + while( ent != NULL ) {
1.111 + ent->callback(ent->data, buttons, x, y);
1.116 gboolean input_is_key_valid( const gchar *keysym )
1.118 @@ -144,7 +224,12 @@
1.119 struct keymap_entry *key = input_get_key(keycode);
1.120 if( key != NULL ) {
1.121 key->callback( key->data, key->value, TRUE );
1.125 + while( key != NULL ) {
1.126 + key->callback( key->data, keycode, TRUE );
1.131 void input_event_keyup( uint16_t keycode )
1.132 @@ -153,6 +238,16 @@
1.133 if( key != NULL ) {
1.134 key->callback( key->data, key->value, FALSE );
1.137 + while( key != NULL ) {
1.138 + key->callback( key->data, keycode, FALSE );
1.143 +uint16_t input_keycode_to_dckeysym( uint16_t keycode )
1.145 + return display_driver->convert_to_dckeysym(keycode);
1.148 display_driver_t get_display_driver_by_name( const char *name )