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

View File

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