Search
lxdream.org :: lxdream/src/display.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/display.c
changeset 614:a2d239d4438a
prev608:4f588e52bce0
next615:38b69ec2f4c8
author nkeynes
date Mon Jan 28 02:38:09 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Bug #49: Joystick support work in progress
file annotate diff log raw
nkeynes@144
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@144
     3
 *
nkeynes@144
     4
 * Generic support for keyboard and other input sources. The active display
nkeynes@144
     5
 * driver is expected to deliver events here, where they're translated and
nkeynes@144
     6
 * passed to the appropriate dreamcast controllers (if any).
nkeynes@144
     7
 *
nkeynes@144
     8
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@144
     9
 *
nkeynes@144
    10
 * This program is free software; you can redistribute it and/or modify
nkeynes@144
    11
 * it under the terms of the GNU General Public License as published by
nkeynes@144
    12
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@144
    13
 * (at your option) any later version.
nkeynes@144
    14
 *
nkeynes@144
    15
 * This program is distributed in the hope that it will be useful,
nkeynes@144
    16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@144
    17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@144
    18
 * GNU General Public License for more details.
nkeynes@144
    19
 */
nkeynes@144
    20
nkeynes@144
    21
#include <stdint.h>
nkeynes@144
    22
#include <assert.h>
nkeynes@144
    23
#include "dream.h"
nkeynes@144
    24
#include "display.h"
nkeynes@431
    25
#include "pvr2/pvr2.h"
nkeynes@144
    26
nkeynes@531
    27
display_driver_t display_driver_list[] = { 
nkeynes@541
    28
#ifdef HAVE_GTK
nkeynes@531
    29
					   &display_gtk_driver,
nkeynes@541
    30
#endif
nkeynes@531
    31
					   &display_null_driver,
nkeynes@531
    32
					   NULL };
nkeynes@531
    33
nkeynes@614
    34
/* Some explanation:
nkeynes@614
    35
 *   The system has at least one "root" device representing the main display 
nkeynes@614
    36
 * (which may be the null display). This device is part of the display_driver
nkeynes@614
    37
 * and generates events with no input_driver. The root device has no id
nkeynes@614
    38
 * as such (for the purposes of event names)
nkeynes@614
    39
 *
nkeynes@614
    40
 *   The system may also have one or more auxilliary devices which each have
nkeynes@614
    41
 * an input_driver and an id (eg "JS0"). So the keysym "Return" is (de)coded by
nkeynes@614
    42
 * the root device, and the keysym "JS0: Button0" is (de)coded by the JS0 input
nkeynes@614
    43
 * device as "Button0".
nkeynes@614
    44
 *
nkeynes@614
    45
 *   For the moment, mice are handled specially, as they behave a little
nkeynes@614
    46
 * differently from other devices (although this will probably change in the 
nkeynes@614
    47
 * future.
nkeynes@614
    48
 */
nkeynes@614
    49
nkeynes@614
    50
nkeynes@144
    51
typedef struct keymap_entry {
nkeynes@144
    52
    input_key_callback_t callback;
nkeynes@144
    53
    void *data;
nkeynes@144
    54
    uint32_t value;
nkeynes@608
    55
    struct keymap_entry *next; // allow chaining
nkeynes@144
    56
} *keymap_entry_t;
nkeynes@144
    57
nkeynes@608
    58
typedef struct mouse_entry {
nkeynes@608
    59
    gboolean relative;
nkeynes@608
    60
    input_mouse_callback_t callback;
nkeynes@608
    61
    void *data;
nkeynes@608
    62
    struct mouse_entry *next;
nkeynes@608
    63
} *mouse_entry_t;
nkeynes@608
    64
nkeynes@614
    65
typedef struct input_driver_entry {
nkeynes@614
    66
    input_driver_t driver;
nkeynes@614
    67
    uint16_t entry_count;
nkeynes@614
    68
    struct keymap_entry *keymap[0];
nkeynes@614
    69
} *input_driver_entry_t;
nkeynes@614
    70
nkeynes@144
    71
/**
nkeynes@327
    72
 * Colour format information
nkeynes@327
    73
 */
nkeynes@327
    74
struct colour_format colour_formats[] = {
nkeynes@329
    75
    { GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_RGB5_A1, 2 },
nkeynes@327
    76
    { GL_UNSIGNED_SHORT_5_6_5, GL_RGB, GL_RGB5, 2 },
nkeynes@327
    77
    { GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_BGRA, GL_RGBA4, 2 },
nkeynes@451
    78
    { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* YUV decoded to ARGB8888 */
nkeynes@327
    79
    { GL_UNSIGNED_BYTE, GL_BGR, GL_RGB, 3 },
nkeynes@451
    80
    { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },
nkeynes@477
    81
    { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* Index4 decoded */
nkeynes@477
    82
    { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* Index8 decoded */
nkeynes@477
    83
    { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },
nkeynes@477
    84
    { GL_UNSIGNED_BYTE, GL_RGB, GL_RGB, 3 },
nkeynes@352
    85
    
nkeynes@327
    86
};
nkeynes@327
    87
nkeynes@327
    88
/**
nkeynes@144
    89
 * FIXME: make this more memory efficient
nkeynes@144
    90
 */
nkeynes@614
    91
static struct keymap_entry *root_keymap[65535];
nkeynes@614
    92
static struct keymap_entry *keyhooks = NULL;
nkeynes@614
    93
static struct mouse_entry *mousehooks = NULL;
nkeynes@614
    94
static gboolean display_focused = TRUE;
nkeynes@614
    95
static GList *input_drivers= NULL;
nkeynes@614
    96
static display_keysym_callback_t display_keysym_hook = NULL;
nkeynes@614
    97
void *display_keysym_hook_data;
nkeynes@144
    98
nkeynes@614
    99
gboolean input_register_device( input_driver_t driver, uint16_t max_keycode )
nkeynes@144
   100
{
nkeynes@614
   101
    GList *ptr;
nkeynes@614
   102
    for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {
nkeynes@614
   103
	input_driver_entry_t entry = (input_driver_entry_t)ptr->data;
nkeynes@614
   104
	if( strcasecmp( entry->driver->id, driver->id ) == 0 ) {
nkeynes@614
   105
	    return FALSE;
nkeynes@614
   106
	}
nkeynes@144
   107
    }
nkeynes@614
   108
nkeynes@614
   109
    input_driver_entry_t entry = g_malloc0( sizeof(struct input_driver_entry) + (sizeof(keymap_entry_t) * max_keycode) );
nkeynes@614
   110
    entry->driver = driver;
nkeynes@614
   111
    entry->entry_count = max_keycode;
nkeynes@614
   112
    input_drivers = g_list_append( input_drivers, entry );
nkeynes@614
   113
    return TRUE;
nkeynes@144
   114
}
nkeynes@144
   115
nkeynes@614
   116
void input_unregister_device( input_driver_t driver )
nkeynes@144
   117
{
nkeynes@614
   118
    GList *ptr;
nkeynes@614
   119
    for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {
nkeynes@614
   120
	input_driver_entry_t entry = (input_driver_entry_t)ptr->data;
nkeynes@614
   121
	if( entry->driver == driver ) {
nkeynes@614
   122
	    if( driver->destroy != NULL ) {
nkeynes@614
   123
		driver->destroy(driver);
nkeynes@614
   124
	    }
nkeynes@614
   125
	    input_drivers = g_list_remove(input_drivers, (gpointer)entry);
nkeynes@614
   126
	    g_free( entry );
nkeynes@614
   127
	    return;
nkeynes@614
   128
	}
nkeynes@144
   129
    }
nkeynes@144
   130
}
nkeynes@144
   131
nkeynes@614
   132
/**
nkeynes@614
   133
 * Resolve the keysym and return a pointer to the keymap entry pointer
nkeynes@614
   134
 * @return keymap pointer or NULL if the key was unresolved
nkeynes@614
   135
 */
nkeynes@614
   136
static struct keymap_entry **input_entry_from_keysym( const gchar *keysym )
nkeynes@144
   137
{
nkeynes@614
   138
    if( keysym == NULL || keysym[0] == 0 ) {
nkeynes@614
   139
	return NULL;
nkeynes@614
   140
    }
nkeynes@614
   141
    char **strv = g_strsplit(keysym,":",2);
nkeynes@614
   142
    if( strv[1] == NULL ) {
nkeynes@614
   143
	/* root device */
nkeynes@614
   144
	if( display_driver == NULL || display_driver->resolve_keysym == NULL) {
nkeynes@614
   145
	    // Root device has no input handling
nkeynes@614
   146
	    g_strfreev(strv);
nkeynes@614
   147
	    return NULL;
nkeynes@614
   148
	}
nkeynes@614
   149
	uint16_t keycode = display_driver->resolve_keysym(g_strstrip(strv[0]));
nkeynes@614
   150
	g_strfreev(strv);
nkeynes@614
   151
	if( keycode == 0 ) {
nkeynes@614
   152
	    return NULL;
nkeynes@614
   153
	}
nkeynes@614
   154
	return &root_keymap[keycode-1];
nkeynes@614
   155
    } else {
nkeynes@614
   156
	char *id = g_strstrip(strv[0]);
nkeynes@614
   157
	GList *ptr;
nkeynes@614
   158
	for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {
nkeynes@614
   159
	    input_driver_entry_t entry = (input_driver_entry_t)ptr->data;
nkeynes@614
   160
	    if( strcasecmp( entry->driver->id, id ) == 0 ) {
nkeynes@614
   161
		/* we have ze device */
nkeynes@614
   162
		if( entry->driver->resolve_keysym == NULL ) {
nkeynes@614
   163
		    g_strfreev(strv);
nkeynes@614
   164
		    return NULL;
nkeynes@614
   165
		} 
nkeynes@614
   166
		uint16_t keycode = entry->driver->resolve_keysym(entry->driver, g_strstrip(strv[1]));
nkeynes@614
   167
		g_strfreev(strv);
nkeynes@614
   168
		if( keycode == 0 || keycode > entry->entry_count ) {
nkeynes@614
   169
		    return NULL;
nkeynes@614
   170
		}
nkeynes@614
   171
		return &entry->keymap[keycode-1];
nkeynes@614
   172
	    }
nkeynes@614
   173
	}
nkeynes@614
   174
	g_strfreev(strv);
nkeynes@614
   175
	return NULL; // device not found
nkeynes@614
   176
    }
nkeynes@144
   177
}
nkeynes@144
   178
nkeynes@614
   179
static struct keymap_entry **input_entry_from_keycode( input_driver_t driver, uint16_t keycode )
nkeynes@614
   180
{
nkeynes@614
   181
    GList *ptr;
nkeynes@614
   182
nkeynes@614
   183
    if( keycode == 0 ) {
nkeynes@614
   184
	return NULL;
nkeynes@614
   185
    }
nkeynes@614
   186
nkeynes@614
   187
    if( driver == NULL ) {
nkeynes@614
   188
	return &root_keymap[keycode-1];
nkeynes@614
   189
    }
nkeynes@614
   190
nkeynes@614
   191
    for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {
nkeynes@614
   192
	input_driver_entry_t entry = (input_driver_entry_t)ptr->data;
nkeynes@614
   193
	if( entry->driver == driver ) {
nkeynes@614
   194
	    if( keycode > entry->entry_count ) {
nkeynes@614
   195
		return NULL;
nkeynes@614
   196
	    } else {
nkeynes@614
   197
		return &entry->keymap[keycode-1];
nkeynes@614
   198
	    }
nkeynes@614
   199
	}
nkeynes@614
   200
    }
nkeynes@614
   201
    return NULL;
nkeynes@614
   202
}
nkeynes@614
   203
nkeynes@614
   204
static gchar *input_keysym_for_keycode( input_driver_t driver, uint16_t keycode )
nkeynes@614
   205
{
nkeynes@614
   206
    if( keycode == 0 ) {
nkeynes@614
   207
	return NULL;
nkeynes@614
   208
    }
nkeynes@614
   209
    if( driver == NULL ) {
nkeynes@614
   210
	if( display_driver != NULL && display_driver->get_keysym_for_keycode != NULL ) {
nkeynes@614
   211
	    return display_driver->get_keysym_for_keycode(keycode);
nkeynes@614
   212
	}
nkeynes@614
   213
    } else if( driver->get_keysym_for_keycode ) {
nkeynes@614
   214
	gchar *sym = driver->get_keysym_for_keycode(driver,keycode);
nkeynes@614
   215
	if( sym != NULL ) {
nkeynes@614
   216
	    gchar *result = g_strdup_printf( "%s: %s", driver->id, sym );
nkeynes@614
   217
	    g_free(sym);
nkeynes@614
   218
	    return result;
nkeynes@614
   219
	}
nkeynes@614
   220
    }
nkeynes@614
   221
    return NULL;
nkeynes@614
   222
}
nkeynes@614
   223
nkeynes@614
   224
nkeynes@144
   225
gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,
nkeynes@144
   226
			     void *data, uint32_t value )
nkeynes@144
   227
{
nkeynes@614
   228
    if( keysym == NULL ) {
nkeynes@614
   229
	return FALSE;
nkeynes@614
   230
    }
nkeynes@614
   231
    int keys = 0;
nkeynes@271
   232
    gchar **strv = g_strsplit(keysym, ",", 16);
nkeynes@271
   233
    gchar **s = strv;
nkeynes@271
   234
    while( *s != NULL ) {
nkeynes@614
   235
	keymap_entry_t *entryp = input_entry_from_keysym(*s);
nkeynes@614
   236
	if( entryp != NULL ) {
nkeynes@614
   237
	    *entryp = g_malloc0(sizeof(struct keymap_entry));
nkeynes@614
   238
	    (*entryp)->callback = callback;
nkeynes@614
   239
	    (*entryp)->data = data;
nkeynes@614
   240
	    (*entryp)->value = value;
nkeynes@614
   241
	    keys++;
nkeynes@614
   242
	}
nkeynes@271
   243
	s++;
nkeynes@271
   244
    }
nkeynes@271
   245
    g_strfreev(strv);
nkeynes@614
   246
    return keys != 0;
nkeynes@144
   247
}
nkeynes@144
   248
nkeynes@451
   249
void input_unregister_key( const gchar *keysym, input_key_callback_t callback,
nkeynes@451
   250
			   void *data, uint32_t value )
nkeynes@144
   251
{
nkeynes@614
   252
    if( keysym == NULL ) {
nkeynes@144
   253
	return;
nkeynes@614
   254
    }
nkeynes@614
   255
nkeynes@614
   256
    gchar **strv = g_strsplit(keysym, ",", 16);
nkeynes@614
   257
    gchar **s = strv;
nkeynes@614
   258
    while( *s != NULL ) {
nkeynes@614
   259
	keymap_entry_t *entryp = input_entry_from_keysym(*s);
nkeynes@614
   260
	if( entryp != NULL && *entryp != NULL && (*entryp)->callback == callback &&
nkeynes@614
   261
	    (*entryp)->data == data && (*entryp)->value == value ) {
nkeynes@614
   262
	    g_free( *entryp );
nkeynes@614
   263
	    *entryp = NULL;
nkeynes@614
   264
	}
nkeynes@614
   265
	s++;
nkeynes@614
   266
    }
nkeynes@614
   267
    g_strfreev(strv);
nkeynes@144
   268
}
nkeynes@608
   269
nkeynes@608
   270
gboolean input_register_hook( input_key_callback_t callback,
nkeynes@608
   271
			      void *data )
nkeynes@608
   272
{
nkeynes@608
   273
    keymap_entry_t key = malloc( sizeof( struct keymap_entry ) );
nkeynes@608
   274
    assert( key != NULL );
nkeynes@608
   275
    key->callback = callback;
nkeynes@608
   276
    key->data = data;
nkeynes@608
   277
    key->next = keyhooks;
nkeynes@608
   278
    keyhooks = key;
nkeynes@608
   279
    return TRUE;
nkeynes@608
   280
}
nkeynes@608
   281
nkeynes@608
   282
void input_unregister_hook( input_key_callback_t callback,
nkeynes@608
   283
			    void *data )
nkeynes@608
   284
{
nkeynes@608
   285
    keymap_entry_t key = keyhooks;
nkeynes@608
   286
    if( key != NULL ) {
nkeynes@608
   287
	keymap_entry_t next = key->next;
nkeynes@608
   288
	if( key->callback == callback && key->data == data ) {
nkeynes@608
   289
	    free(key);
nkeynes@608
   290
	    keyhooks = next;
nkeynes@608
   291
	    return;
nkeynes@608
   292
	}
nkeynes@608
   293
	while( next != NULL ) {
nkeynes@608
   294
	    if( next->callback == callback && next->data == data ) {
nkeynes@608
   295
		key->next = next->next;
nkeynes@608
   296
		free(next);
nkeynes@608
   297
	    }
nkeynes@608
   298
	}
nkeynes@608
   299
    }
nkeynes@608
   300
}
nkeynes@608
   301
nkeynes@608
   302
gboolean input_register_mouse_hook( gboolean relative, input_mouse_callback_t callback,
nkeynes@608
   303
				void *data )
nkeynes@608
   304
{
nkeynes@608
   305
    mouse_entry_t ent = malloc( sizeof( struct mouse_entry ) );
nkeynes@608
   306
    assert( ent != NULL );
nkeynes@608
   307
    ent->callback = callback;
nkeynes@608
   308
    ent->data = data;
nkeynes@608
   309
    ent->next = mousehooks;
nkeynes@608
   310
    mousehooks = ent;
nkeynes@608
   311
    return TRUE;
nkeynes@608
   312
}    
nkeynes@608
   313
nkeynes@608
   314
void input_unregister_mouse_hook( input_mouse_callback_t callback, void *data )
nkeynes@608
   315
{
nkeynes@608
   316
    mouse_entry_t ent = mousehooks;
nkeynes@608
   317
    if( ent != NULL ) {
nkeynes@608
   318
	mouse_entry_t next = ent->next;
nkeynes@608
   319
	if( ent->callback == callback && ent->data == data ) {
nkeynes@608
   320
	    free(ent);
nkeynes@608
   321
	    mousehooks = next;
nkeynes@608
   322
	    return;
nkeynes@608
   323
	}
nkeynes@608
   324
	while( next != NULL ) {
nkeynes@608
   325
	    if( next->callback == callback && next->data == data ) {
nkeynes@608
   326
		ent->next = next->next;
nkeynes@608
   327
		free(next);
nkeynes@608
   328
	    }
nkeynes@608
   329
	}
nkeynes@608
   330
    }
nkeynes@608
   331
}
nkeynes@608
   332
nkeynes@608
   333
void input_event_mouse( uint32_t buttons, int32_t x, int32_t y )
nkeynes@608
   334
{
nkeynes@608
   335
    mouse_entry_t ent = mousehooks;
nkeynes@608
   336
    while( ent != NULL ) {
nkeynes@608
   337
	ent->callback(ent->data, buttons, x, y);
nkeynes@608
   338
	ent = ent->next;
nkeynes@608
   339
    }
nkeynes@608
   340
}
nkeynes@144
   341
nkeynes@144
   342
gboolean input_is_key_valid( const gchar *keysym )
nkeynes@144
   343
{
nkeynes@614
   344
    keymap_entry_t *ptr = input_entry_from_keysym(keysym);
nkeynes@614
   345
    return ptr != NULL;
nkeynes@144
   346
}
nkeynes@144
   347
nkeynes@144
   348
gboolean input_is_key_registered( const gchar *keysym )
nkeynes@144
   349
{
nkeynes@614
   350
    keymap_entry_t *ptr = input_entry_from_keysym(keysym);
nkeynes@614
   351
    return ptr != NULL && *ptr != NULL;
nkeynes@144
   352
}
nkeynes@144
   353
nkeynes@614
   354
void input_event_keydown( input_driver_t driver, uint16_t keycode, uint32_t pressure )
nkeynes@144
   355
{
nkeynes@614
   356
    if( display_focused ) {
nkeynes@614
   357
	keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);
nkeynes@614
   358
	if( entryp != NULL && *entryp != NULL ) {
nkeynes@614
   359
	    (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, TRUE );
nkeynes@614
   360
	}
nkeynes@614
   361
	keymap_entry_t key = keyhooks;
nkeynes@614
   362
	while( key != NULL ) {
nkeynes@614
   363
	    key->callback( key->data, keycode, pressure, TRUE );
nkeynes@614
   364
	    key = key->next;
nkeynes@614
   365
	}
nkeynes@608
   366
    }
nkeynes@614
   367
    if( display_keysym_hook != NULL ) {
nkeynes@614
   368
	gchar *sym = input_keysym_for_keycode( driver, keycode );
nkeynes@614
   369
	if( sym != NULL ) {
nkeynes@614
   370
	    display_keysym_hook(display_keysym_hook_data, sym);
nkeynes@614
   371
	    g_free(sym);
nkeynes@614
   372
	}
nkeynes@608
   373
    }
nkeynes@144
   374
}
nkeynes@144
   375
nkeynes@614
   376
void input_event_keyup( input_driver_t driver, uint16_t keycode, uint32_t pressure )
nkeynes@144
   377
{
nkeynes@614
   378
    if( display_focused ) {
nkeynes@614
   379
	keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);
nkeynes@614
   380
	if( entryp != NULL && *entryp != NULL ) {
nkeynes@614
   381
	    (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, FALSE );
nkeynes@614
   382
	}
nkeynes@614
   383
nkeynes@614
   384
	keymap_entry_t key = keyhooks;
nkeynes@614
   385
	while( key != NULL ) {
nkeynes@614
   386
	    key->callback( key->data, keycode, pressure, FALSE );
nkeynes@614
   387
	    key = key->next;
nkeynes@614
   388
	}
nkeynes@608
   389
    }
nkeynes@608
   390
}
nkeynes@608
   391
nkeynes@608
   392
uint16_t input_keycode_to_dckeysym( uint16_t keycode )
nkeynes@608
   393
{
nkeynes@608
   394
    return display_driver->convert_to_dckeysym(keycode);
nkeynes@144
   395
}
nkeynes@144
   396
nkeynes@531
   397
display_driver_t get_display_driver_by_name( const char *name )
nkeynes@531
   398
{
nkeynes@531
   399
    int i;
nkeynes@531
   400
    if( name == NULL ) {
nkeynes@531
   401
	return display_driver_list[0];
nkeynes@531
   402
    }
nkeynes@531
   403
    for( i=0; display_driver_list[i] != NULL; i++ ) {
nkeynes@531
   404
	if( strcasecmp( display_driver_list[i]->name, name ) == 0 ) {
nkeynes@531
   405
	    return display_driver_list[i];
nkeynes@531
   406
	}
nkeynes@531
   407
    }
nkeynes@531
   408
nkeynes@531
   409
    return NULL;
nkeynes@531
   410
}
nkeynes@144
   411
nkeynes@144
   412
nkeynes@370
   413
gboolean display_set_driver( display_driver_t driver )
nkeynes@144
   414
{
nkeynes@370
   415
    gboolean rv = TRUE;
nkeynes@370
   416
    if( display_driver != NULL && display_driver->shutdown_driver != NULL ) 
nkeynes@144
   417
	display_driver->shutdown_driver();
nkeynes@144
   418
nkeynes@144
   419
    display_driver = driver;
nkeynes@144
   420
    if( driver->init_driver != NULL )
nkeynes@370
   421
	rv = driver->init_driver();
nkeynes@531
   422
    if( !rv ) {
nkeynes@531
   423
	display_driver = NULL;
nkeynes@370
   424
    }
nkeynes@370
   425
    return rv;
nkeynes@144
   426
}
nkeynes@614
   427
nkeynes@614
   428
void display_set_focused( gboolean has_focus )
nkeynes@614
   429
{
nkeynes@614
   430
    display_focused = has_focus;
nkeynes@614
   431
}
nkeynes@614
   432
nkeynes@614
   433
void input_set_keysym_hook( display_keysym_callback_t hook, void *data )
nkeynes@614
   434
{
nkeynes@614
   435
    display_keysym_hook = hook;
nkeynes@614
   436
    display_keysym_hook_data = data;
nkeynes@614
   437
}
.