gtk: replaced Pause checkbox with Pause menu item that changes to Resume when pausing and vice versa when unpausing, and fixed the bug where FCEUX would stop responding after unpausing

This commit is contained in:
plombo 2011-03-19 01:16:09 +00:00
parent e9b4ab74ec
commit d8f4c3636c
3 changed files with 29 additions and 6 deletions

View File

@ -1322,12 +1322,25 @@ void toggleGameGenie(GtkToggleAction *action)
enableGameGenie(gtk_toggle_action_get_active(action));
}
void togglePause(GtkToggleAction *action)
void togglePause(GtkAction *action)
{
if(gtk_toggle_action_get_active(action))
FCEUI_SetEmulationPaused(1);
else
FCEUI_SetEmulationPaused(0);
SDL_Event sdlev;
int paused;
if(isloaded)
{
paused = FCEUI_EmulationPaused();
sdlev.type = SDL_FCEU_HOTKEY_EVENT;
sdlev.user.code = HK_PAUSE;
if(SDL_PushEvent(&sdlev) < 0)
{
FCEU_printf("Failed to push SDL event to %s game.\n", paused ? "resume" : "pause");
return;
}
gtk_action_set_label(action, paused ? "Pause" : "Resume");
gtk_action_set_stock_id(action, paused ? GTK_STOCK_MEDIA_PAUSE : GTK_STOCK_MEDIA_PLAY);
}
}
void loadGameGenie ()
@ -1889,6 +1902,7 @@ static GtkActionEntry normal_entries[] = {
{"EmulatorMenuAction", NULL, "_Emulator"},
{"PowerAction", NULL, "P_ower", NULL, NULL, G_CALLBACK(FCEUI_PowerNES)},
{"ResetAction", GTK_STOCK_REFRESH, "_Reset", NULL, NULL, G_CALLBACK(emuReset)},
{"PauseToggleAction", GTK_STOCK_MEDIA_PAUSE, "_Pause", NULL, NULL, G_CALLBACK(togglePause)},
{"FdsMenuAction", GTK_STOCK_FLOPPY, "_FDS"},
{"SwitchDiskAction", "go-jump", "_Switch Disk", NULL, NULL, G_CALLBACK(FCEU_FDSSelect)},
{"EjectDiskAction", "media-eject", "_Eject Disk", NULL, NULL, G_CALLBACK(FCEU_FDSInsert)},
@ -1909,7 +1923,6 @@ static GtkActionEntry normal_entries[] = {
// Menu items with a check box that can be toggled on or off
static GtkToggleActionEntry toggle_entries[] = {
{"GameGenieToggleAction", NULL, "Enable Game _Genie", NULL, NULL, G_CALLBACK(toggleGameGenie), FALSE},
{"PauseToggleAction", GTK_STOCK_MEDIA_PAUSE, "_Pause", NULL, NULL, G_CALLBACK(togglePause), FALSE}
};
static GtkWidget* CreateMenubar( GtkWidget* window)

View File

@ -735,6 +735,14 @@ UpdatePhysicalInput()
CloseGame();
puts("Quit");
break;
case SDL_FCEU_HOTKEY_EVENT:
switch(event.user.code) {
case HK_PAUSE:
FCEUI_ToggleEmulationPause();
break;
default:
FCEU_printf("Warning: unknown hotkey event %d\n", event.user.code);
}
default:
// do nothing
break;

View File

@ -30,6 +30,8 @@ int DWaitButton(const uint8 *text, ButtConfig *bc, int wb);
#define FCFGD_HYPERSHOT 3
#define FCFGD_QUIZKING 4
#define SDL_FCEU_HOTKEY_EVENT SDL_USEREVENT
void InitInputInterface(void);
void InputUserActiveFix(void);