gtk: fix some minor issues

Only allow the emulator to handle key events when the main window has the input focus

Don't write anything to stdout when configuring a button using the GTK+ control config dialog.
This commit is contained in:
plombo 2011-03-22 23:36:16 +00:00
parent f3eb06bde3
commit c76d4bf20d
2 changed files with 20 additions and 12 deletions

View File

@ -58,7 +58,7 @@ int configGamepadButton(GtkButton* button, gpointer p)
snprintf(buf, sizeof(buf), "SDL.Input.GamePad.%d", padNo);
prefix = buf;
DWaitButton((const uint8*)"Press a button", &GamePadConfig[padNo][x], configNo);
DWaitButton(NULL, &GamePadConfig[padNo][x], configNo);
g_config->setOption(prefix + GamePadNames[x], GamePadConfig[padNo][x].ButtonNum[configNo]);
@ -1091,7 +1091,6 @@ const char* Authors[]= {
void openAbout ()
{
GtkWidget* aboutDialog;
GdkPixbuf* logo = gdk_pixbuf_new_from_xpm_data(icon_xpm);
gtk_show_about_dialog(GTK_WINDOW(MainWindow),
@ -1102,7 +1101,7 @@ void openAbout ()
//"license-type", GTK_LICENSE_GPL_2_0,
"website", "http://fceux.com",
"authors", Authors,
"logo", logo);
"logo", logo, NULL);
}
void toggleSound(GtkWidget* check, gpointer data)
@ -1837,12 +1836,17 @@ gint convertKeypress(GtkWidget *grab, GdkEventKey *event, gpointer user_data)
if (sdlkey != 0)
{
SDL_PushEvent(&sdlev);
// Only let the emulator handle the key event if this window has the input focus.
if(keystate == 0 || gtk_window_is_active(GTK_WINDOW(MainWindow)))
{
#if SDL_VERSION_ATLEAST(1, 3, 0)
SDL_GetKeyboardState(NULL)[SDL_GetScancodeFromKey(sdlkey)] = keystate;
#else
SDL_GetKeyState(NULL)[sdlkey] = keystate;
#endif
}
}
// Allow GTK+ to process this key.
return FALSE;

View File

@ -1346,10 +1346,14 @@ DWaitButton(const uint8 *text,
SDL_Event event;
static int32 LastAx[64][64];
int x,y;
if(text) {
std::string title = "Press a key for ";
title += (const char*)text;
SDL_WM_SetCaption(title.c_str(),0);
puts((const char *)text);
}
for(x = 0; x < 64; x++) {
for(y = 0; y < 64; y++) {
LastAx[x][y]=0x100000;