diff --git a/desmume/src/ctrlssdl.cpp b/desmume/src/ctrlssdl.cpp index 191bdefc9..95edffaab 100644 --- a/desmume/src/ctrlssdl.cpp +++ b/desmume/src/ctrlssdl.cpp @@ -406,9 +406,6 @@ process_joystick_events( u16 *keypad) { if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) SDL_JoystickEventState(SDL_ENABLE); - /* Reset the keypad bits */ - *keypad = 0; - /* There's an event waiting to be processed? */ while (SDL_PollEvent(&event)) { diff --git a/desmume/src/gtk/desmume.cpp b/desmume/src/gtk/desmume.cpp index aa35b689a..0d1192bd9 100644 --- a/desmume/src/gtk/desmume.cpp +++ b/desmume/src/gtk/desmume.cpp @@ -75,16 +75,6 @@ bool desmume_running( void) void desmume_cycle( void) { - u16 keypad; - - /* Joystick events */ - /* Retrieve old value: can use joysticks w/ another device (from our side) */ - keypad = get_keypad(); - /* Look for queued events */ - process_joystick_events( &keypad); - /* Update keypad value */ - update_keypad(keypad); - FCEUMOV_AddInputState(); NDS_exec(); SPU_Emulate_user(); diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 5767574b0..2bfe547bc 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -493,7 +493,7 @@ struct modify_key_ctx { u8 key_id; }; -static u16 Cur_Keypad = 0; +static u16 keys_latch = 0; static u16 gdk_shift_pressed = 0; u16 Keypad_Temp[NB_KEYS]; @@ -1476,8 +1476,7 @@ static gint Key_Press(GtkWidget *w, GdkEventKey *e, gpointer data) if( (e->state & mask) == 0){ u16 Key = lookup_key(e->keyval); if(Key){ - ADD_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); + ADD_KEY( keys_latch, Key ); return 1; } } @@ -1502,8 +1501,7 @@ static gint Key_Release(GtkWidget *w, GdkEventKey *e, gpointer data) return 1; } u16 Key = lookup_key(e->keyval); - RM_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); + RM_KEY( keys_latch, Key ); return 1; } @@ -1974,6 +1972,11 @@ gboolean EmuLoop(gpointer data) skipped_frames = 0; } + /* Merge the joystick keys with the keyboard ones */ + process_joystick_events(&keys_latch); + /* Update! */ + update_keypad(keys_latch); + desmume_cycle(); /* Emule ! */ for (i = 0; i < Frameskip; i++) { NDS_SkipNextFrame();