Search
lxdream.org :: lxdream :: r451:50622730f226
lxdream 0.9.1
released Jun 29
Download Now
changeset451:50622730f226
parent450:207461e79f21
child452:48db4ac96899
authornkeynes
dateSun Oct 21 05:15:56 2007 +0000 (12 years ago)
Unregister keys on controller detach
src/display.c
src/display.h
src/maple/controller.c
1.1 --- a/src/display.c Wed Oct 17 11:26:45 2007 +0000
1.2 +++ b/src/display.c Sun Oct 21 05:15:56 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: display.c,v 1.10 2007-10-09 08:12:29 nkeynes Exp $
1.6 + * $Id: display.c,v 1.11 2007-10-21 05:15:56 nkeynes Exp $
1.7 *
1.8 * Generic support for keyboard and other input sources. The active display
1.9 * driver is expected to deliver events here, where they're translated and
1.10 @@ -38,9 +38,9 @@
1.11 { GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_RGB5_A1, 2 },
1.12 { GL_UNSIGNED_SHORT_5_6_5, GL_RGB, GL_RGB5, 2 },
1.13 { GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_BGRA, GL_RGBA4, 2 },
1.14 - { GL_UNSIGNED_INT_8_8_8_8_REV, GL_BGRA, GL_RGBA8, 4 }, /* YUV decoded to ARGB8888 */
1.15 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* YUV decoded to ARGB8888 */
1.16 { GL_UNSIGNED_BYTE, GL_BGR, GL_RGB, 3 },
1.17 - { GL_UNSIGNED_INT_8_8_8_8_REV, GL_BGRA, GL_RGBA8, 4 },
1.18 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },
1.19
1.20 };
1.21
1.22 @@ -62,10 +62,11 @@
1.23 return key;
1.24 }
1.25
1.26 -static void input_delete_key( uint16_t keycode )
1.27 +static void input_delete_key( uint16_t keycode, input_key_callback_t callback, void *data,
1.28 + uint32_t value )
1.29 {
1.30 struct keymap_entry *key = keymap[keycode];
1.31 - if( key != NULL ) {
1.32 + if( key != NULL && key->callback == callback && key->data == data && key->value == value ) {
1.33 free( key );
1.34 keymap[keycode] = NULL;
1.35 }
1.36 @@ -98,14 +99,15 @@
1.37 return TRUE;
1.38 }
1.39
1.40 -void input_unregister_key( const gchar *keysym )
1.41 +void input_unregister_key( const gchar *keysym, input_key_callback_t callback,
1.42 + void *data, uint32_t value )
1.43 {
1.44 if( display_driver == NULL || keysym == NULL )
1.45 return;
1.46 uint16_t keycode = display_driver->resolve_keysym(keysym);
1.47 if( keycode == 0 )
1.48 return;
1.49 - input_delete_key( keycode );
1.50 + input_delete_key( keycode, callback, data, value );
1.51 }
1.52
1.53
2.1 --- a/src/display.h Wed Oct 17 11:26:45 2007 +0000
2.2 +++ b/src/display.h Sun Oct 21 05:15:56 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: display.h,v 1.9 2007-10-08 11:49:35 nkeynes Exp $
2.6 + * $Id: display.h,v 1.10 2007-10-21 05:15:56 nkeynes Exp $
2.7 *
2.8 * The PC side of the video support (responsible for actually displaying /
2.9 * rendering frames)
2.10 @@ -165,7 +165,8 @@
2.11 gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,
2.12 void *data, uint32_t value );
2.13
2.14 -void input_unregister_key( const gchar *keysym );
2.15 +void input_unregister_key( const gchar *keysym, input_key_callback_t callback,
2.16 + void *data, uint32_t value );
2.17
2.18 gboolean input_is_key_valid( const gchar *keysym );
2.19
3.1 --- a/src/maple/controller.c Wed Oct 17 11:26:45 2007 +0000
3.2 +++ b/src/maple/controller.c Sun Oct 21 05:15:56 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: controller.c,v 1.7 2007-10-17 11:26:45 nkeynes Exp $
3.6 + * $Id: controller.c,v 1.8 2007-10-21 05:15:56 nkeynes Exp $
3.7 *
3.8 * Implements the standard dreamcast controller
3.9 *
3.10 @@ -154,8 +154,24 @@
3.11 input_register_key( dev->config[14].value, controller_key_callback, dev, BUTTON_START );
3.12 }
3.13
3.14 -void controller_detach( maple_device_t dev )
3.15 +void controller_detach( maple_device_t mdev )
3.16 {
3.17 + controller_device_t dev = (controller_device_t)mdev;
3.18 + input_unregister_key( dev->config[0].value, controller_key_callback, dev, BUTTON_DPAD_LEFT );
3.19 + input_unregister_key( dev->config[1].value, controller_key_callback, dev, BUTTON_DPAD_RIGHT );
3.20 + input_unregister_key( dev->config[2].value, controller_key_callback, dev, BUTTON_DPAD_UP );
3.21 + input_unregister_key( dev->config[3].value, controller_key_callback, dev, BUTTON_DPAD_DOWN );
3.22 + input_unregister_key( dev->config[4].value, controller_key_callback, dev, JOY_LEFT );
3.23 + input_unregister_key( dev->config[5].value, controller_key_callback, dev, JOY_RIGHT );
3.24 + input_unregister_key( dev->config[6].value, controller_key_callback, dev, JOY_UP );
3.25 + input_unregister_key( dev->config[7].value, controller_key_callback, dev, JOY_DOWN );
3.26 + input_unregister_key( dev->config[8].value, controller_key_callback, dev, BUTTON_X );
3.27 + input_unregister_key( dev->config[9].value, controller_key_callback, dev, BUTTON_Y );
3.28 + input_unregister_key( dev->config[10].value, controller_key_callback, dev, BUTTON_A );
3.29 + input_unregister_key( dev->config[11].value, controller_key_callback, dev, BUTTON_B );
3.30 + input_unregister_key( dev->config[12].value, controller_key_callback, dev, BUTTON_LEFT_TRIGGER );
3.31 + input_unregister_key( dev->config[13].value, controller_key_callback, dev, BUTTON_RIGHT_TRIGGER );
3.32 + input_unregister_key( dev->config[14].value, controller_key_callback, dev, BUTTON_START );
3.33
3.34 }
3.35
.