Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 27595 Details for
Bug 44446
FCE Ultra 0.98.2 released.
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to add GTK2 functionality to FCE Ultra 0.98.2
fceu-gtk2-0.98.2.patch (text/plain), 45.01 KB, created by
Jason Oliveira
on 2004-03-18 21:15:59 UTC
(
hide
)
Description:
patch to add GTK2 functionality to FCE Ultra 0.98.2
Filename:
MIME Type:
Creator:
Jason Oliveira
Created:
2004-03-18 21:15:59 UTC
Size:
45.01 KB
patch
obsolete
>--- fceu/configure.ac 2004-03-08 18:51:10.000000000 -0600 >+++ fceu-0.98.2/configure.ac 2004-03-15 00:29:02.338202423 -0600 >@@ -69,6 +69,10 @@ > if [[ "$use_gtk" = "yes" ]] ; then > dnl Check for GTK > AM_PATH_GTK_2_0(2.2.0, AC_DEFINE([HAVE_GTK]), AC_MSG_ERROR("GTK2 requested but not found!")) >+ PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.3, >+ [ echo "Using experimental filechooser widget", >+ AM_CONDITIONAL(HAVE_GTK24,true) ], >+ [ AM_CONDITIONAL(HAVE_GTK24, false) ] ) > CFLAGS="$CFLAGS $GTK_CFLAGS " > LIBS="$LIBS $GTK_LIBS " > AC_DEFINE([EXTGUI]) >diff -urNb fceu/src/drivers/pc/Makefile.am.inc fceu-0.98.2/src/drivers/pc/Makefile.am.inc >--- fceu/src/drivers/pc/Makefile.am.inc 2004-01-21 14:49:55.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/Makefile.am.inc 2004-03-15 00:04:59.604889517 -0600 >@@ -6,6 +6,19 @@ > > fceu_SOURCES += $(TMP_OGL) > >+if HAVE_GTK >+TMP_GTK = drivers/pc/gtk/gtk-main.c drivers/pc/gtk/inputconfig.c drivers/pc/gtk/inputconfig_gp.c drivers/pc/gtk/drawingarea.c >+endif >+ >+if HAVE_GTK24 >+TMP_GTK_FC = drivers/pc/gtk/gtk-filechooser.c >+else >+TMP_GTK_FC = drivers/pc/gtk/gtk-fileopen.c >+endif >+ >+fceu_SOURCES += $(TMP_GTK) >+fceu_SOURCES += $(TMP_GTK_FC) >+ > if HAVE_WX > TMP_WX = drivers/pc/wx/wx.cpp drivers/pc/wx/input.cpp drivers/pc/wx/inputconfig.cpp drivers/pc/wx/debugger.cpp drivers/pc/wx/virtuallistctrl.cpp drivers/pc/wx/fceultra_wdr.cpp drivers/pc/wx/sound.cpp drivers/pc/wx/cheat.cpp drivers/pc/wx/video.cpp drivers/pc/wx/extextctrl.cpp > endif >diff -urNb fceu/src/drivers/pc/gtk/drawingarea.c fceu-0.98.2/src/drivers/pc/gtk/drawingarea.c >--- fceu/src/drivers/pc/gtk/drawingarea.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/drawingarea.c 2004-03-15 00:04:59.748867284 -0600 >@@ -0,0 +1,185 @@ >+#include "drawingarea.h" >+ >+ >+#include <gtk/gtk.h> >+#include <gdk/gdk.h> >+#include <glib/gprintf.h> >+ >+ >+ >+gtkgui_drawingarea *gtkgui_drawingarea_new (gchar *filename_unlit, gchar *filename_lit) { >+ gtkgui_drawingarea *ret = NULL; >+ GError *error = NULL; >+ >+ ret = g_new (gtkgui_drawingarea, 1); >+ if (ret == NULL) >+ return NULL; >+ >+ >+ ret->da = gtk_drawing_area_new (); >+ gtk_widget_add_events ( GTK_WIDGET(ret->da), >+ GDK_POINTER_MOTION_MASK >+ | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK >+ | GDK_ENTER_NOTIFY_MASK >+ | GDK_LEAVE_NOTIFY_MASK >+ | GDK_FOCUS_CHANGE_MASK >+ ); >+ >+ ret->pixbuf_unlit = gdk_pixbuf_new_from_file (filename_unlit, &error); >+ if (ret->pixbuf_unlit == NULL) { >+ g_printf ("Error #%i loading pixmap: \"%s\"\n\tERROR: %s\n", error->code, filename_unlit, error->message); >+ } >+ >+ ret->pixbuf_lit = gdk_pixbuf_new_from_file (filename_lit, &error); >+ if (ret->pixbuf_lit == NULL) { >+ g_printf ("Error #%i loading pixmap: \"%s\"\n\tERROR: %s\n", error->code, filename_lit, error->message); >+ } >+ >+ >+ >+ ret->width = gdk_pixbuf_get_width (ret->pixbuf_unlit); >+ ret->height = gdk_pixbuf_get_height(ret->pixbuf_unlit); >+ >+ gtk_widget_set_size_request (GTK_WIDGET(ret->da), ret->width, ret->height); >+ >+ g_signal_connect (G_OBJECT (ret->da), "expose_event", G_CALLBACK (gtkgui_drawingarea_expose_event_cb), ret); >+ g_signal_connect (G_OBJECT (ret->da), "event", G_CALLBACK (gtkgui_drawingarea_event_cb ), ret); >+ >+ ret->buttons = NULL; >+ ret->active_button = NULL; >+ >+ return (ret); >+ } >+ >+ >+void gtkgui_drawingarea_free (gtkgui_drawingarea *victim) { >+ g_free (victim); >+ } >+ >+gint gtkgui_findbutton (gconstpointer in_button, gconstpointer in_event) { >+ gtkgui_button *button = (gtkgui_button *)in_button; >+ GdkEventMotion *event = (GdkEventMotion *)in_event; >+ >+ if (event->x >= button->x && event->x <= (button->x + button->width)) >+ if (event->y >= button->y && event->y <= (button->y + button->height)) { >+ return 0; // 0 indicates a match >+ } >+ >+ return -1; >+ } >+ >+gboolean gtkgui_drawingarea_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gtkgui_drawingarea *area) { >+ >+ gdk_pixbuf_render_to_drawable_alpha ( GDK_PIXBUF(area->pixbuf_unlit), >+ GDK_DRAWABLE(area->da->window), >+ 0, 0, 0, 0, -1, -1, 0, 0, GDK_RGB_DITHER_MAX, 0, 0); >+ >+// g_list_foreach(area->buttons, (GFunc)gtkgui_button_draw, area->da->window); >+ >+ if (area->active_button != NULL) >+ gtkgui_button_draw (area, area->active_button); >+ >+ return TRUE; >+ } >+ >+gboolean gtkgui_drawingarea_event_cb (GtkWidget *widget, GdkEvent *event, gtkgui_drawingarea *area) { >+ gboolean handled = TRUE; >+ GList *active_button = NULL; >+ >+ switch (event->type) { >+ case GDK_MOTION_NOTIFY : >+ >+ active_button = g_list_find_custom (area->buttons, event, >kgui_findbutton); >+ >+ if (active_button == NULL ) { >+ if (area->active_button != NULL) { >+ gtkgui_button *oldbutton = area->active_button; >+ area->active_button = NULL; >+ gtkgui_button_draw (area, oldbutton); >+ } >+ } >+ else { >+ if (area->active_button != NULL) { >+ if (active_button->data != area->active_button) { >+ gtkgui_button *oldbutton = area->active_button; >+ area->active_button = NULL; >+ gtkgui_button_draw (area, oldbutton); >+ >+ } >+ } >+ area->active_button = active_button->data; >+ gtkgui_button_draw (area, active_button->data); >+ } >+ >+ break; >+ case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: >+ break; >+ case GDK_BUTTON_RELEASE : >+ if (area->active_button != NULL) { >+ g_printf ("Button press! button=%i\n", (int)area->active_button); >+ >+ } >+ break; >+ case GDK_EXPOSE : // Ignore and let the other handler take this. >+ handled = FALSE; >+ break; >+ case GDK_CONFIGURE : // the size, position or stacking order of the window has changed. Note that GTK+ discards these events for GDK_WINDOW_CHILD windows. >+ break; >+ case GDK_MAP: // >+ break; >+ case GDK_ENTER_NOTIFY: >+ break; >+ case GDK_LEAVE_NOTIFY: >+ if (area->active_button != NULL) { >+ gtkgui_button *oldbutton = area->active_button; >+ area->active_button = NULL; >+ gtkgui_button_draw(area, oldbutton); >+ } >+ break; >+ >+ default: >+ printf ("Unhandled event: %i\n", event->type); >+ handled = FALSE; >+ break; >+ }; >+ >+ return (handled); >+ } >+ >+ >+ >+ >+gtkgui_button *gtkgui_button_register (gtkgui_drawingarea *da, gtkgui_button *inbutton) { >+ if (da == NULL) >+ return NULL; >+ if (inbutton == NULL) >+ return NULL; >+ inbutton->parent = da; >+ da->buttons = g_list_append (da->buttons, inbutton); // Add self to the button list of the area >+ return inbutton; >+ } >+ >+ >+void *gtkgui_button_draw (gtkgui_drawingarea *area, gtkgui_button *button) { >+ GdkPixbuf *pixbuf = NULL; >+ if (button->parent->active_button == button) { >+ pixbuf = button->parent->pixbuf_lit; >+ } >+ else { >+ pixbuf = button->parent->pixbuf_unlit; >+ } >+ >+ gdk_draw_pixbuf ( GDK_DRAWABLE(area->da->window), >+ NULL, >+ GDK_PIXBUF(pixbuf), >+ button->x, button->y, >+ button->x, button->y, >+ button->width, button->height, >+ GDK_RGB_DITHER_MAX, >+ 0, 0); >+ return NULL; >+ } >+ >+void *gtkgui_button_clicked_cb (gtkgui_button *button) { >+ return NULL; >+ } >diff -urNb fceu/src/drivers/pc/gtk/drawingarea.h fceu-0.98.2/src/drivers/pc/gtk/drawingarea.h >--- fceu/src/drivers/pc/gtk/drawingarea.h 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/drawingarea.h 2004-03-15 00:04:59.752866667 -0600 >@@ -0,0 +1,92 @@ >+#ifndef __gtkdrawingarea_H__ >+#define __gtkdrawingarea_H__ >+ >+ >+#ifdef __GNUG__ >+ #pragma interface "drawingarea.c" >+#endif >+ >+ >+#ifndef GTK_PRECOMP >+ #include <gtk/gtk.h> >+ #include <glib.h> >+ #include <glib/gprintf.h> >+#endif >+ >+ >+typedef struct { >+ GtkWidget *da; // The drawing area widget >+ gint width, >+ height; >+ GdkPixbuf *pixbuf_unlit, // The graphic with unlit buttons >+ *pixbuf_lit; // The graphic with lit buttons >+ >+ GList *buttons; // List of buttons >+ void *active_button; // If a button should draw itself as lit this should point to it >+ >+ } gtkgui_drawingarea; >+ >+ >+typedef struct { >+ gtkgui_drawingarea *parent; >+ gint type; // This can be set to the type of button if there is an enumerated list of them >+ gint x, // Relative position of the button within the pixmap >+ y, >+ width, // Dimensions of the button >+ height; >+ } gtkgui_button; >+ >+ >+ >+gtkgui_drawingarea >+ *gtkgui_drawingarea_new (gchar *filename_unlit, gchar *filename_lit); >+ >+void >+ gtkgui_drawingarea_free (gtkgui_drawingarea *victim); >+ >+gboolean >+ gtkgui_drawingarea_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gtkgui_drawingarea *area); >+ >+gboolean >+ gtkgui_drawingarea_event_cb (GtkWidget *widget, GdkEvent *event, gtkgui_drawingarea *area); >+ >+gint // Tests a button to see if a GdkMotionEvent occured over it >+ gtkgui_findbutton (gconstpointer in_button, gconstpointer in_event); >+ >+//gtkgui_button >+// *gtkgui_button_new (); >+ >+gtkgui_button >+ *gtkgui_button_register (gtkgui_drawingarea *da, gtkgui_button *inbutton); >+ >+void >+ *gtkgui_button_draw (gtkgui_drawingarea *area, gtkgui_button *button); >+ >+void >+ *gtkgui_button_clicked_cb (gtkgui_button *button); >+ >+ >+ >+//gtkgui_tray >+// *gtkgui_tray_new (gtkgui_drawingarea *area, gchar *filename, gint x, gint y); >+ >+//void >+// *gtkgui_tray_draw (gtkgui_tray *tray, GdkDrawable *window); >+ >+//void >+// *gtkgui_tray_motion (gtkgui_tray *tray, GdkEventMotion *event); >+ >+//gtkgui_button >+// *gtkgui_button_new (gtkgui_tray *tray, gchar *filename_unlit, gchar *filename_lit, gint x, gint y); >+ >+//void >+// *gtkgui_button_draw (gtkgui_button *button, GdkDrawable *window); >+ >+//void >+// gtkgui_button_lit (gtkgui_button *button, gboolean lit); >+ >+//void >+// *gtkgui_button_motion (gtkgui_button *button, GdkEventMotion *event); >+ >+ >+#endif /* __gtkdrawingarea_H__ */ >diff -urNb fceu/src/drivers/pc/gtk/gtk-filechooser.c fceu-0.98.2/src/drivers/pc/gtk/gtk-filechooser.c >--- fceu/src/drivers/pc/gtk/gtk-filechooser.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/gtk-filechooser.c 2004-03-15 00:04:59.882846596 -0600 >@@ -0,0 +1,76 @@ >+#include "gtk-fileopen.h" >+#include "gtk-main.h" >+ >+#include <gtk/gtk.h> // explicitly just for fun >+#include <stdlib.h> // free & malloc >+#include <string.h> // strlen >+#include <stdio.h> >+ >+#include "../main.h" >+#include "../dface.h" >+ >+#include <gtk/gtk.h> >+ >+static GtkWidget *filew; >+extern char *LastFile; >+extern GString *bdir; >+ >+static void open_file( char *file ) { >+ if(LoadGame(file)) { >+ if(LastFile) { >+ free(LastFile); >+ } >+ LastFile=malloc(strlen(file)+1); >+ strcpy(LastFile, file); >+ } >+ } >+ >+void GTKGUI_fileopen( GtkWidget *w, gpointer data ) { >+ //cybercyst: use new gtk_file_chooser widget >+ filew = gtk_file_chooser_dialog_new( "File selection", >+ GTK_WINDOW(w), >+ GTK_FILE_CHOOSER_ACTION_OPEN, >+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, >+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, >+ NULL); >+ >+ if (LastFile != NULL) >+ gtk_file_chooser_select_filename (GTK_FILE_CHOOSER(filew), LastFile); >+ >+ if(gtk_dialog_run(GTK_DIALOG(filew)) == GTK_RESPONSE_ACCEPT) { >+ char *filename; >+ >+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filew) ); >+ >+ open_file(filename); >+ >+ g_free (filename); >+ } >+ >+ gtk_widget_destroy(filew); >+} >+ >+ >+void GTKGUI_fileclose(GtkWidget *w, gpointer data) { >+ CloseGame(); >+ return; >+ } >+ >+uint8 *GetBaseDirectory(void) { >+ uint8 *ret; >+ ret=strdup(bdir->str); >+ return(ret); >+ } >+ >+FILE *FCEUD_UTF8fopen(const char *fn, const char *mode) { >+ GString *tmpfn = g_string_new(fn); >+ GString *tmpmode = g_string_new(mode); >+ >+ FILE *tmpfile = fopen(tmpfn->str, tmpmode->str); >+ >+ FCEU_printf ("FCEUD_UTF8fopen : fn=\"%s\" mode=\"%s\" result=%i\n", tmpfn->str, tmpmode->str, (int)tmpfile); >+ >+ g_string_free(tmpfn, TRUE); >+ g_string_free(tmpmode, TRUE); >+ return(tmpfile); >+ } >diff -urNb fceu/src/drivers/pc/gtk/gtk-fileopen.c fceu-0.98.2/src/drivers/pc/gtk/gtk-fileopen.c >--- fceu/src/drivers/pc/gtk/gtk-fileopen.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/gtk-fileopen.c 2004-03-15 00:05:00.027824209 -0600 >@@ -0,0 +1,74 @@ >+#include "gtk-fileopen.h" >+#include "gtk-main.h" >+ >+#include <gtk/gtk.h> // explicitly just for fun >+#include <stdlib.h> // free & malloc >+#include <string.h> // strlen >+#include <stdio.h> >+ >+#include "../main.h" >+#include "../dface.h" >+ >+#include <gtk/gtk.h> >+ >+static GtkWidget *filew; >+extern char *LastFile; >+extern GString *bdir; >+ >+static void file_ok_sel( GtkWidget *w, GtkFileSelection *fs ) { >+ gchar *path= (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)); >+ if(LoadGame(path)) { >+ if(LastFile) { >+ free(LastFile); >+ } >+ LastFile=malloc(strlen(path)+1); >+ strcpy(LastFile,path); >+ gtk_widget_destroy(filew); >+ } >+ } >+ >+void GTKGUI_fileopen( GtkWidget *w, gpointer data ) { >+ >+ /* Create a new file selection widget */ >+ filew = gtk_file_selection_new ("File selection"); >+ >+ /* Connect the ok_button to file_ok_sel function */ >+ g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION (filew)->ok_button), "clicked", (GtkSignalFunc) file_ok_sel, filew ); >+ >+ /* Connect the cancel_button to destroy the widget */ >+ g_signal_connect_object ( GTK_OBJECT (GTK_FILE_SELECTION(filew)->cancel_button), >+ "clicked", >+ (GtkSignalFunc) gtk_widget_destroy, >+ GTK_OBJECT (filew), 0 ); >+ >+ /* Lets set the filename, as if this were a save dialog, and we are giving >+ a default filename */ >+ gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew), LastFile); >+ >+ gtk_widget_show(filew); >+ } >+ >+ >+void GTKGUI_fileclose(GtkWidget *w, gpointer data) { >+ CloseGame(); >+ return; >+ } >+ >+uint8 *GetBaseDirectory(void) { >+ uint8 *ret; >+ ret=strdup(bdir->str); >+ return(ret); >+ } >+ >+FILE *FCEUD_UTF8fopen(const char *fn, const char *mode) { >+ GString *tmpfn = g_string_new(fn); >+ GString *tmpmode = g_string_new(mode); >+ >+ FILE *tmpfile = fopen(tmpfn->str, tmpmode->str); >+ >+ FCEU_printf ("FCEUD_UTF8fopen : fn=\"%s\" mode=\"%s\" result=%i\n", tmpfn->str, tmpmode->str, (int)tmpfile); >+ >+ g_string_free(tmpfn, TRUE); >+ g_string_free(tmpmode, TRUE); >+ return(tmpfile); >+ } >diff -urNb fceu/src/drivers/pc/gtk/gtk-fileopen.h fceu-0.98.2/src/drivers/pc/gtk/gtk-fileopen.h >--- fceu/src/drivers/pc/gtk/gtk-fileopen.h 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/gtk-fileopen.h 2004-03-15 00:05:00.174801514 -0600 >@@ -0,0 +1,16 @@ >+ >+#ifndef __gtkfileopen_H__ >+#define __gtkfileopen_H__ >+ >+#ifndef GTK_PRECOMP >+ #include <gtk/gtk.h> >+#endif >+ >+#ifdef __GNUG__ >+ #pragma interface "gtk-fileopen.c" >+#endif >+ >+void GTKGUI_fileopen( GtkWidget *w, gpointer data ); >+void GTKGUI_fileclose(GtkWidget *w, gpointer data); >+ >+#endif >diff -urNb fceu/src/drivers/pc/gtk/gtk-main.c fceu-0.98.2/src/drivers/pc/gtk/gtk-main.c >--- fceu/src/drivers/pc/gtk/gtk-main.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/gtk-main.c 2004-03-15 00:05:00.506750257 -0600 >@@ -0,0 +1,292 @@ >+ >+#include "gtk-main.h" >+#include "gtk-fileopen.h" >+#include "inputconfig.h" >+ >+#include "../main.h" >+#include "../dface.h" >+#include "../sdl.h" >+ >+#include <unistd.h> >+#include <glib/gprintf.h> >+#include <stdlib.h> >+ >+static int exiting = 0; >+GtkWidget *mainwin = NULL; >+GString *bdir = NULL; >+ >+static GtkTextBuffer *messagebuf = NULL; >+static GtkWidget *messageview= NULL; >+ >+static GtkTextTag *txtmsgtag = NULL; >+static GtkTextTag *txterrtag = NULL; >+static GtkTextIter txtiter; >+static GtkTextMark *txtendmark = NULL; >+static gboolean autoscroll = TRUE; >+ >+ // Config stuff >+uint8 *LastFile = NULL; >+gint GUIwidth = 600; >+gint GUIheight = 440; >+ >+extern int UsrInputType[3]; >+extern int InputType[3]; /* Current */ >+ >+ // Prototypes >+ >+int FCEUSDLmain(int argc, char **argv); >+ >+int GTKGUI_Init (void); >+int GTKGUI_Main (void); >+void GTKGUI_Quit(GtkWidget *w, gpointer data); >+void GTKGUI_nesreset(void); >+void GTKGUI_nespower(void); >+ >+void get_main_menu( GtkWidget **menubar ); >+ >+void on_config_palette (void); >+void on_config_input (void); >+void on_config_sound (void); >+void on_config_video (void); >+void on_config_directories (void); >+ >+static gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data ); >+gboolean expose_event_cb ( GtkWidget *widget, GdkEventExpose *event, gpointer user_data); >+ >+int main (int argc, char **argv) { >+ >+ gtk_init(&argc,&argv); >+ >+ mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); >+ >+ bdir=g_string_new(getenv("HOME")); >+ g_string_append (bdir,PSS); >+ g_string_append (bdir,".fceultra"); >+ >+ GTKGUI_Init(); >+ >+ FCEUSDLmain(argc,argv); >+ >+ gtk_window_resize(GTK_WINDOW(mainwin), GUIwidth, GUIheight); // Do this before it's shown >+ >+ if(argc>1) { >+ GUI_Update(); >+ LoadGame(argv[argc-1]); >+ } >+ >+ >+ GTKGUI_Main(); >+ >+ // I wonder how I can force a config save here... >+ CloseGame(); >+ >+ return 0; >+ } >+ >+static GtkItemFactoryEntry menu_items[] = { >+// PATH, ACCEL, CB CB_A TYPE EXTRA_DATA >+ { "/_Game", NULL, NULL, 0, "<Branch>" }, >+ { "/Game/_Open...", "<control>O", GTKGUI_fileopen, 0, NULL }, >+ { "/Game/_Close...", "<control>C", GTKGUI_fileclose, 0, NULL }, >+ { "/Game/sep1", NULL, NULL, 0, "<Separator>" }, >+ { "/Game/Quit", "<control>Q", GTKGUI_Quit, 0, NULL }, >+ { "/_System", NULL, NULL, 0, "<Branch>" }, >+ { "/System/_Reset", NULL, GTKGUI_nesreset, 0, NULL }, >+ { "/System/_Power", NULL, GTKGUI_nespower, 0, NULL }, >+ { "/System/sep1", NULL, NULL, 0, "<Separator>" }, >+ { "/System/_Cheats", NULL, NULL, 0, NULL }, >+ { "/System/_Debugger", NULL, NULL, 0, NULL }, >+ { "/_Configuration", NULL, NULL, 0, "<Branch>" }, >+ { "/Configuration/_PAL Emulation", NULL, NULL, 0, "<CheckItem>" }, >+ { "/Configuration/_Game Genie Emulation",NULL, NULL, 0, "<CheckItem>" }, >+ { "/Configuration/sep1", NULL, NULL, 0, "<Separator>" }, >+ { "/Configuration/_Palette...", NULL, on_config_palette, 0, NULL }, >+ { "/Configuration/_Input...", NULL, on_config_input, 0, NULL }, >+ { "/Configuration/_Sound...", NULL, on_config_sound, 0, NULL }, >+ { "/Configuration/_Video...", NULL, on_config_video, 0, NULL }, >+ { "/Configuration/_Directories...", NULL, on_config_directories,0,NULL }, >+ { "/_Help", NULL, NULL, 0, "<LastBranch>" }, >+ { "/_Help/_About...", NULL, NULL, 0, NULL }, >+ { "/_Help/_Message Log...", NULL, NULL, 0, NULL }, >+}; >+ >+void get_main_menu( GtkWidget **menubar ) >+{ >+ GtkItemFactory *item_factory; >+ GtkAccelGroup *accel_group = gtk_accel_group_new (); >+ gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); >+ >+ /* This function initializes the item factory. >+ Param 1: The type of menu - can be GTK_TYPE_MENU_BAR, GTK_TYPE_MENU, or GTK_TYPE_OPTION_MENU. >+ Param 2: The path of the menu. >+ Param 3: A pointer to a gtk_accel_group. The item factory sets up >+ the accelerator table while generating menus. >+ */ >+ >+ item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group); >+ >+ /* This function generates the menu items. Pass the item factory, >+ the number of items in the array, the array itself, and any >+ callback data for the the menu items. */ >+ gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL); >+ >+ /* Attach the new accelerator group to the window. */ >+ gtk_window_add_accel_group (GTK_WINDOW (mainwin), accel_group); >+ >+ if (menubar) >+ /* Finally, return the actual menu bar created by the item factory. */ >+ *menubar = gtk_item_factory_get_widget (item_factory, "<main>"); >+} >+ >+ >+int GTKGUI_Init (void) { >+ GtkWidget *menubar = NULL, >+ *mainvbox = NULL, >+ *textscroll = NULL; >+ >+ gtk_window_set_title(GTK_WINDOW(mainwin), "FCE Ultra"); >+ gtk_signal_connect(GTK_OBJECT(mainwin), "delete_event", GTK_SIGNAL_FUNC(delete_event),NULL); >+ gtk_signal_connect(GTK_OBJECT(mainwin), "expose-event", GTK_SIGNAL_FUNC(expose_event_cb),NULL); >+ >+ gtk_window_resize(GTK_WINDOW(mainwin), GUIwidth, GUIheight); >+ >+ mainvbox=gtk_vbox_new(FALSE,2); >+ gtk_container_border_width(GTK_CONTAINER(mainvbox), 1); >+ gtk_container_add(GTK_CONTAINER(mainwin), mainvbox); >+ >+ get_main_menu(&menubar); >+ gtk_box_pack_start(GTK_BOX(mainvbox),menubar,FALSE,TRUE,0); >+ >+ textscroll=gtk_scrolled_window_new(NULL,NULL); >+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(textscroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); >+ >+ messageview=gtk_text_view_new(); >+ messagebuf=gtk_text_view_get_buffer(GTK_TEXT_VIEW(messageview)); >+ gtk_text_view_set_editable (GTK_TEXT_VIEW(messageview), FALSE); >+ >+ txterrtag = gtk_text_buffer_create_tag (messagebuf, "errtxt", "foreground", "red", NULL); >+ txtmsgtag = gtk_text_buffer_create_tag (messagebuf, "msgtxt", "foreground", "blue", NULL); >+ >+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER(messagebuf), &txtiter); >+ txtendmark = gtk_text_buffer_create_mark (messagebuf, "endtxt", &txtiter, FALSE); // This should give us something to "autoscroll" to >+ >+ gtk_container_add(GTK_CONTAINER(textscroll), messageview); >+ >+ gtk_box_pack_start(GTK_BOX(mainvbox), textscroll,TRUE,TRUE,0); >+ >+ gtk_widget_show_all(mainwin); >+ >+ return 0; >+ } >+ >+ >+int GUI_Update(void) { >+ while (gtk_events_pending()) { >+ gtk_main_iteration(); >+ } >+ return 0; >+ } >+ >+ >+int GUI_Idle(void) { >+ GUI_Update(); >+ usleep(10000); >+ return(!exiting); >+ } >+ >+ >+int GTKGUI_Main () { >+ >+ while(!exiting) { >+ >+ if(CurGame) { >+ DoFun(); >+ } >+ >+ GUI_Idle(); >+ } // End of while !exiting >+ >+ return 1; >+ } >+ >+static gint delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { >+ exiting=1; >+ CloseGame(); >+ return(FALSE); >+ } >+ >+gboolean expose_event_cb ( GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { >+ int w=0, h=0; >+ gtk_window_get_size(GTK_WINDOW(mainwin), &w, &h); >+ if (w != GUIwidth || h != GUIheight) { >+ GUIwidth=w; >+ GUIheight=h; >+ } >+ return FALSE; // True "eats" the signal so nothing else gets it >+ } >+ >+void GTKGUI_Quit(GtkWidget *w, gpointer data) { >+ gtk_widget_destroy(mainwin); >+ delete_event(0,0,0); >+ } >+ >+ >+void GUI_RequestExit(void) { >+ } >+ >+ >+void GUI_Hide(int hide) { >+ } >+ >+ >+void Giggles(int k) { // Input init ?? >+ } >+ >+ >+void FCEUD_PrintError(char *str) { >+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER(messagebuf), &txtiter); >+ gtk_text_buffer_insert_with_tags(messagebuf, &txtiter, str, -1, txterrtag, NULL); >+ if (autoscroll) >+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW(messageview), GTK_TEXT_MARK(txtendmark), 0, TRUE, 1.0, 1.0); >+ } >+ >+void FCEUD_Message(char *str) { >+ gtk_text_buffer_get_end_iter (messagebuf, &txtiter); >+ gtk_text_buffer_insert_with_tags(GTK_TEXT_BUFFER(messagebuf), &txtiter, str, -1, txtmsgtag, NULL); >+ if (autoscroll) >+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW(messageview), GTK_TEXT_MARK(txtendmark), 0, TRUE, 1.0, 1.0); >+ } >+ >+ >+void GTKGUI_nesreset(void) { >+ FCEUI_ResetNES(); >+ } >+ >+void GTKGUI_nespower(void) { >+ FCEUI_PowerNES(); >+ } >+ >+void on_config_palette(void) { >+ } >+ >+void on_config_input(void) { >+ GTKGUI_InputConfig_Init(); >+ } >+ >+void on_config_sound(void) { >+ } >+ >+void on_config_video(void) { >+ } >+ >+void on_config_directories(void) { >+ } >+ >+ >+ >+CFGSTRUCT GUIConfig[]={ >+ ACS(LastFile), >+ AC(GUIwidth), >+ AC(GUIheight), >+ ENDCFGSTRUCT >+ }; >diff -urNb fceu/src/drivers/pc/gtk/gtk-main.h fceu-0.98.2/src/drivers/pc/gtk/gtk-main.h >--- fceu/src/drivers/pc/gtk/gtk-main.h 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/gtk-main.h 2004-03-15 00:05:00.680723393 -0600 >@@ -0,0 +1,21 @@ >+///////////////////////////////////////////////////////////////////////////// >+// Name: gtk-main.h >+// Author: Curtis Magyar >+// Created: 2004-01-30 >+// Copyright: 2004 >+///////////////////////////////////////////////////////////////////////////// >+ >+#ifndef __gtkmain_H__ >+#define __gtkmain_H__ >+ >+#ifdef __GNUG__ >+ #pragma interface "gtk-main.c" >+#endif >+ >+#ifndef GTK_PRECOMP >+ #include <gtk/gtk.h> >+#endif >+ >+ >+ >+#endif >diff -urNb fceu/src/drivers/pc/gtk/input.c fceu-0.98.2/src/drivers/pc/gtk/input.c >--- fceu/src/drivers/pc/gtk/input.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/input.c 2004-03-15 00:05:00.683722930 -0600 >@@ -0,0 +1,17 @@ >+#include "gtk-main.h" >+ >+#include "../main.h" >+#include "../dface.h" >+ >+#include "input.h" >+ /* >+ >+struct NSFControl { >+ void Down(void); >+ void Down10(void); >+ void Up(void); >+ void Up10(void); >+ gchar *Current; >+ }; >+ >+ */ >diff -urNb fceu/src/drivers/pc/gtk/input.h fceu-0.98.2/src/drivers/pc/gtk/input.h >--- fceu/src/drivers/pc/gtk/input.h 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/input.h 2004-03-15 00:05:01.552588765 -0600 >@@ -0,0 +1,9 @@ >+ >+#ifndef __gtkinput_H__ >+#define __gtkinput_H__ >+ >+void StartGameExInput(GtkWidget *window, int type); >+void StopGameExInput(void); >+ >+ >+#endif >diff -urNb fceu/src/drivers/pc/gtk/inputconfig.c fceu-0.98.2/src/drivers/pc/gtk/inputconfig.c >--- fceu/src/drivers/pc/gtk/inputconfig.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/inputconfig.c 2004-03-15 00:05:01.000000000 -0600 >@@ -0,0 +1,358 @@ >+ >+ >+#include "inputconfig.h" >+#include "gtk-main.h" >+#include "inputconfig_gp.h" >+ >+#include <glib/gprintf.h> >+ >+GtkWidget *inputcfgwin = NULL; >+extern GtkWidget *mainwin; >+ >+ extern int UsrInputType[3]; >+ extern int InputType[3]; /* Current */ >+ >+const gchar *GTK_INPUT_DEVICE_NAMES[] = { >+ "[NONE]", >+ "Port 1", >+ "Port 2", >+ "Famicom Expansion Port" >+ }; >+#define GTK_GET_DEVICE_NAME(x) GTK_INPUT_DEVICE_NAMES[x] >+ >+ >+const gchar *GTK_INPUT_DEVICE_MENUPATHS[] = { >+ "<main>/NONE", >+ "<main>/PORT1", >+ "<main>/PORT2", >+ "<main>/FC" >+ }; >+ >+#define GTK_MENU_GET_PATH(x) GTK_INPUT_DEVICE_MENUPATHS[x] >+ >+const gchar *GTK_INPUT_DEVICE_TYPE_NAMES[] = { >+ "[NONE]", >+ "Game Pad", >+ "Zapper", >+ "Power Pad A", >+ "Power Pad B", >+ "Arkanoid", >+ NULL >+ }; >+ >+const gchar *GTK_INPUT_FCDEVICE_TYPE_NAMES[] = { >+ "[NONE]", >+ "Arkanoid", >+ "Space Shadow Gun", >+ "Four-Player Adapter", >+ "Family BASIC Keyboard", >+ "HyperShot", >+ "Mahjong", >+ "Quiz King Buzzers", >+ "Family Trainer A", >+ "Family Trainer B", >+ "Oeka Kids Tablet", >+ "Barcode World", >+ "Top Rider", >+ NULL >+ }; >+ >+const gchar *GTK_INPUT_UNKNOWN_TYPE_NAMES[] = { >+ "[UNKNOWN]", >+ NULL >+ }; >+ >+ >+void GTKGUI_JoyConfigDeleteEvent (void); >+ >+void input_device_selected_cb (GTK_INPUT_DEVICE *in_device, guint callback_action, GtkWidget *widget); >+void GTKGUI_get_inputdev_config (GTK_INPUT_DEVICE *in_device); >+ >+ >+GTK_INPUT_DEVICE input_device[3]; >+ >+void input_device_new (GTK_INPUT_DEVICE *indevice, GTK_INPUT_DEVICES indev, GTK_INPUT_DEVICE_TYPE intype); >+void get_input_device_menu (GTK_INPUT_DEVICE *device); >+ >+ >+ /* From input.h (I have no short term memory) >+ >+#define MAXBUTTCONFIG 4 >+ >+typedef struct { >+ uint8 ButtType[MAXBUTTCONFIG]; >+ uint8 DeviceNum[MAXBUTTCONFIG]; >+ uint16 ButtonNum[MAXBUTTCONFIG]; >+ uint32 NumC; >+ } ButtConfig; >+ */ >+ >+extern ButtConfig GamePadConfig [4][10]; >+extern ButtConfig powerpadsc [2][12]; >+extern ButtConfig QuizKingButtons [6]; >+extern ButtConfig FTrainerButtons [12]; >+ >+ >+GtkItemFactoryEntry input_unknown_menu_items[] = { >+ { "/UNKNOWN", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_NONE, NULL } >+ }; >+ >+GtkItemFactoryEntry input_device_menu_items[] = { >+ { "/_NONE", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_NONE, NULL }, >+ { "/_Game Pad", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_GP, NULL }, >+ { "/_Zapper", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_ZAP, NULL }, >+ { "/Power Pad _A", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_PPA, NULL }, >+ { "/Power Pad _B", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_PPB, NULL }, >+ { "/A_rkanoid", NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_ARK, NULL } >+ }; >+ >+GtkItemFactoryEntry input_fcdevice_menu_items[] = { >+ { "/_NONE", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_NONE, NULL }, >+ { "/A_rkanoid", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_ARK, NULL }, >+ { "/_Space Shadow Gun", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_SHADOW, NULL }, >+ { "/_Four-Player Adapter", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_4PLAYER, NULL }, >+ { "/Family BASIC _Keyboard", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_FKB, NULL }, >+ { "/_HyperShot", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_HYPERSHOT, NULL }, >+ { "/_Mahjong", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_MAHJONG, NULL }, >+ { "/_Quiz King Buzzers", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_QUIZKING, NULL }, >+ { "/Family Trainer _A", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_FTRAINERA, NULL }, >+ { "/Family Trainer _B", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_FTRAINERB, NULL }, >+ { "/_Oeka Kids Tablet", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_OEKAKIDS, NULL }, >+ { "/_Barcode World", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_BWORLD, NULL }, >+ { "/_Top Rider", NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_TOPRIDER, NULL } >+ }; >+ >+ >+ >+ >+ >+void get_input_device_menu( GTK_INPUT_DEVICE *device ) { >+ gint nmenu_items = -1; >+ gchar *accelpath = (gchar *)GTK_MENU_GET_PATH(device->device); >+ GtkAccelGroup *accel_group = gtk_accel_group_new (); >+ GtkItemFactory *item_factory = NULL; >+ >+ item_factory = gtk_item_factory_new (GTK_TYPE_OPTION_MENU, accelpath, accel_group); >+ >+ switch (device->device) { >+ case GTK_INPUT_DEVICE_PORT1: >+ nmenu_items = sizeof (input_device_menu_items) / sizeof ((input_device_menu_items)[0]); >+ gtk_item_factory_create_items (item_factory, nmenu_items, input_device_menu_items, device); >+ break; >+ case GTK_INPUT_DEVICE_PORT2: >+ nmenu_items = sizeof (input_device_menu_items) / sizeof ((input_device_menu_items)[0]); >+ gtk_item_factory_create_items (item_factory, nmenu_items, input_device_menu_items, device); >+ break; >+ case GTK_INPUT_DEVICE_FC: >+ nmenu_items = sizeof (input_fcdevice_menu_items) / sizeof ((input_fcdevice_menu_items)[0]); >+ gtk_item_factory_create_items (item_factory, nmenu_items, input_fcdevice_menu_items, device); >+ break; >+ default: >+ nmenu_items = sizeof (input_unknown_menu_items) / sizeof ((input_unknown_menu_items)[0]); >+ gtk_item_factory_create_items (item_factory, nmenu_items, input_unknown_menu_items, device); >+ break; >+ }; >+ >+ gtk_window_add_accel_group (GTK_WINDOW (inputcfgwin), GTK_ACCEL_GROUP(accel_group)); >+ >+ if (device) { >+ device->option = gtk_item_factory_get_widget (item_factory, accelpath); >+ gtk_option_menu_set_history(GTK_OPTION_MENU(device->option), device->type); >+ } >+ } >+ >+ >+void DoInputConfig(GtkWidget *window){ >+ GTKGUI_InputConfig_Init(); >+ } >+ >+ >+int GTKGUI_InputConfig_Init (void) { >+ GtkWidget *vboxM = NULL, // main vbox for dialog >+ *hboxM = NULL, // hbox for Ports >+ *butM = NULL; // Close Button >+ >+ inputcfgwin=gtk_window_new(GTK_WINDOW_TOPLEVEL); >+ >+ g_signal_connect(GTK_OBJECT(inputcfgwin), "delete_event", GTK_SIGNAL_FUNC(GTKGUI_JoyConfigDeleteEvent),NULL); >+ gtk_window_set_transient_for(GTK_WINDOW(inputcfgwin), GTK_WINDOW(mainwin)); >+ gtk_window_set_title(GTK_WINDOW(inputcfgwin), "Input Configuration"); >+ gtk_window_set_modal(GTK_WINDOW(inputcfgwin), TRUE); >+ >+ vboxM = gtk_vbox_new(FALSE, 2); >+ gtk_container_add(GTK_CONTAINER(inputcfgwin), vboxM); >+ >+ hboxM=gtk_hbox_new(TRUE, 2); >+ gtk_box_pack_start(GTK_BOX(vboxM), hboxM, TRUE, TRUE, 2); >+ >+ butM=gtk_button_new_from_stock(GTK_STOCK_CLOSE); >+ >+ input_device_new(&input_device[0], GTK_INPUT_DEVICE_PORT1, UsrInputType[0]); >+ input_device_new(&input_device[1], GTK_INPUT_DEVICE_PORT2, UsrInputType[1]); >+ input_device_new(&input_device[2], GTK_INPUT_DEVICE_FC, UsrInputType[2]); >+ >+ gtk_box_pack_start(GTK_BOX(hboxM), input_device[0].frame, TRUE, TRUE, 2); >+ gtk_box_pack_start(GTK_BOX(hboxM), input_device[1].frame, TRUE, TRUE, 2); >+ gtk_box_pack_start(GTK_BOX(vboxM), input_device[2].frame, TRUE, TRUE, 2); >+ gtk_box_pack_start(GTK_BOX(vboxM), butM, FALSE, FALSE, 2); >+ >+ gtk_signal_connect(GTK_OBJECT(butM), "clicked", GTK_SIGNAL_FUNC(GTKGUI_JoyConfigDeleteEvent),NULL); >+ >+ KillVideo(); >+ >+ gtk_widget_show_all(inputcfgwin); >+ >+ if(CurGame) >+ InitVideo(CurGame); >+ >+ return 0; >+ } >+ >+ >+ // Creates, and assembles the subdevice frames of the input dialog >+void input_device_new(GTK_INPUT_DEVICE *indevice, GTK_INPUT_DEVICES indev, GTK_INPUT_DEVICE_TYPE intype) { >+ indevice->device=indev; >+ indevice->type=intype; >+ >+ indevice->portname = (gchar *)GTK_INPUT_DEVICE_NAMES[indev]; >+ indevice->frame=gtk_frame_new((gchar *)indevice->portname); >+ indevice->vbox=gtk_vbox_new(FALSE, 2); >+ indevice->hbox=gtk_hbox_new(FALSE, 2); >+ >+ >+ switch (intype) { >+ case GTK_INPUT_DEVICE_PORT1: case GTK_INPUT_DEVICE_PORT2: >+ indevice->devicename = (gchar *)GTK_INPUT_DEVICE_TYPE_NAMES[intype]; >+ break; >+ case GTK_INPUT_DEVICE_FC: >+ indevice->devicename = (gchar *)GTK_INPUT_FCDEVICE_TYPE_NAMES[intype]; >+ break; >+ default: >+ indevice->devicename = (gchar *)GTK_INPUT_UNKNOWN_TYPE_NAMES[0]; >+ break; >+ }; >+ >+ indevice->label=gtk_label_new(indevice->devicename); >+ indevice->but=gtk_button_new_from_stock(GTK_STOCK_PROPERTIES); >+ >+ get_input_device_menu(indevice); // Init the device struct and hook its button to the cb function >+ >+ gtk_box_pack_start(GTK_BOX(indevice->hbox), indevice->label, TRUE, TRUE, 2); >+ gtk_box_pack_start(GTK_BOX(indevice->hbox), indevice->but, FALSE, FALSE, 2); >+ gtk_box_pack_start(GTK_BOX(indevice->vbox), indevice->hbox, FALSE, TRUE, 2); >+ gtk_box_pack_start(GTK_BOX(indevice->vbox), indevice->option, FALSE, TRUE, 2); >+ >+ g_signal_connect(GTK_OBJECT(indevice->but), "clicked", GTK_SIGNAL_FUNC(GTKGUI_DoSubConfig), indevice); >+ >+ GTKGUI_get_inputdev_config(indevice); >+ >+ gtk_container_add(GTK_CONTAINER(indevice->frame), indevice->vbox); >+ } >+ >+void GTKGUI_get_inputdev_config (GTK_INPUT_DEVICE *in_device) { >+ switch (in_device->device) { >+ case GTK_INPUT_DEVICE_PORT1: case GTK_INPUT_DEVICE_PORT2: >+ switch (in_device->type) { >+ case GTK_INPUT_DEVICE_TYPE_GP: >+ in_device->config = (ButtConfig *)&GamePadConfig; >+ break; >+ case GTK_INPUT_DEVICE_TYPE_ZAP: >+ in_device->config = NULL; >+ break; >+ case GTK_INPUT_DEVICE_TYPE_PPA: case GTK_INPUT_DEVICE_TYPE_PPB: >+ in_device->config = (ButtConfig *)&powerpadsc; >+ break; >+ case GTK_INPUT_DEVICE_TYPE_ARK: >+ in_device->config = NULL; >+ break; >+ case GTK_INPUT_DEVICE_TYPE_NONE : >+ default: >+ in_device->config = NULL; >+ break; >+ }; >+ FCEU_printf ("Input Config: input_device selected: Device=[%s] Type=[%s]\n", (GTK_INPUT_DEVICE_NAMES[in_device->device]), GTK_INPUT_DEVICE_TYPE_NAMES[in_device->type]); >+ gtk_label_set_text (GTK_LABEL(in_device->label), GTK_INPUT_DEVICE_TYPE_NAMES[in_device->type]); >+ break; >+ case GTK_INPUT_DEVICE_FC: >+ switch (in_device->type) { >+ case GTK_INPUT_FCDEVICE_TYPE_ARK: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_SHADOW: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_4PLAYER: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_FKB: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_HYPERSHOT: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_MAHJONG: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_QUIZKING: >+ in_device->config = (ButtConfig *)&QuizKingButtons; >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_FTRAINERA: case GTK_INPUT_FCDEVICE_TYPE_FTRAINERB: >+ in_device->config = (ButtConfig *)&FTrainerButtons; >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_OEKAKIDS: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_BWORLD: >+ break; >+ case GTK_INPUT_FCDEVICE_TYPE_TOPRIDER: >+ break; >+ default: case GTK_INPUT_FCDEVICE_TYPE_NONE: >+ in_device->config = NULL; >+ break; >+ }; >+ FCEU_printf ("Input Config: input_device selected: Device=[%s] Type=[%s]\n", (GTK_INPUT_DEVICE_NAMES[in_device->device]), GTK_INPUT_FCDEVICE_TYPE_NAMES[in_device->type]); >+ gtk_label_set_text (GTK_LABEL(in_device->label), GTK_INPUT_FCDEVICE_TYPE_NAMES[in_device->type]); >+ break; >+ default: >+ in_device->config = NULL; >+ FCEU_printf ("Input Config: input_device selected: Device=[%s] Type=[%s]\n", (GTK_INPUT_DEVICE_NAMES[in_device->device]), GTK_INPUT_UNKNOWN_TYPE_NAMES[in_device->type]); >+ gtk_label_set_text (GTK_LABEL(in_device->label), GTK_INPUT_UNKNOWN_TYPE_NAMES[in_device->type]); >+ break; >+ }; >+ >+ } >+ >+ // This is called when the user selects a new device for an input port >+void input_device_selected_cb ( GTK_INPUT_DEVICE *in_device, >+ guint callback_action, >+ GtkWidget *widget) { >+ if (!in_device) >+ return; >+ >+ in_device->type = callback_action; >+ >+ InputType[in_device->device - 1] = callback_action; >+ InitOtherInput(); >+ >+ GTKGUI_get_inputdev_config (in_device); >+ >+ } >+ >+ >+void GTKGUI_DoSubConfig (GtkButton* button, GTK_INPUT_DEVICE *indevice) { >+ FCEU_printf ("GTKGUI_DoSubConfig requested for %s %s config=%i\n", indevice->portname, indevice->devicename, (int)indevice->config); >+ if (indevice->device == GTK_INPUT_DEVICE_PORT1 || indevice->device == GTK_INPUT_DEVICE_PORT2) { >+ switch (indevice->type) { >+ case GTK_INPUT_DEVICE_TYPE_GP: >+ GTKGUI_DoGPConfig (indevice); >+ break; >+ default: >+ break; >+ }; >+ } >+ else { >+ switch (indevice->type) { >+ >+ default: >+ break; >+ }; >+ } >+ } >+ >+ >+void GTKGUI_JoyConfigDeleteEvent (void) { >+ gtk_widget_destroy(inputcfgwin); >+ } >diff -urNb fceu/src/drivers/pc/gtk/inputconfig.h fceu-0.98.2/src/drivers/pc/gtk/inputconfig.h >--- fceu/src/drivers/pc/gtk/inputconfig.h 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/inputconfig.h 2004-03-15 00:05:01.408610997 -0600 >@@ -0,0 +1,76 @@ >+#ifndef __GTKGUI_INPUTCONFIG_H_ >+#define __GTKGUI_INPUTCONFIG_H_ >+ >+#ifdef __GNUG__ >+ #pragma interface "inputconfig.c" >+#endif >+ >+#ifndef GTK_PRECOMP >+ #include <gtk/gtk.h> >+#endif >+ >+#include "../main.h" >+#include "../dface.h" >+#include "../input.h" >+ >+ >+typedef enum { >+ GTK_INPUT_DEVICE_NONE = 0, >+ GTK_INPUT_DEVICE_PORT1 = 1, >+ GTK_INPUT_DEVICE_PORT2 = 2, >+ GTK_INPUT_DEVICE_FC = 3, >+ NUM_GTK_INPUT_DEVICES >+ } GTK_INPUT_DEVICES; >+ >+typedef enum { >+ GTK_INPUT_DEVICE_TYPE_NONE = SI_NONE, >+ GTK_INPUT_DEVICE_TYPE_GP = SI_GAMEPAD, >+ GTK_INPUT_DEVICE_TYPE_ZAP = SI_ZAPPER, >+ GTK_INPUT_DEVICE_TYPE_PPA = SI_POWERPADA, >+ GTK_INPUT_DEVICE_TYPE_PPB = SI_POWERPADB, >+ GTK_INPUT_DEVICE_TYPE_ARK = SI_ARKANOID, >+ NUM_GTK_INPUT_DEVICE_TYPES >+ } GTK_INPUT_DEVICE_TYPE; >+ >+typedef enum { >+ GTK_INPUT_FCDEVICE_TYPE_NONE = SIFC_NONE, >+ GTK_INPUT_FCDEVICE_TYPE_ARK = SIFC_ARKANOID, >+ GTK_INPUT_FCDEVICE_TYPE_SHADOW = SIFC_SHADOW, >+ GTK_INPUT_FCDEVICE_TYPE_4PLAYER = SIFC_4PLAYER, >+ GTK_INPUT_FCDEVICE_TYPE_FKB = SIFC_FKB, >+ GTK_INPUT_FCDEVICE_TYPE_HYPERSHOT = SIFC_HYPERSHOT, >+ GTK_INPUT_FCDEVICE_TYPE_MAHJONG = SIFC_MAHJONG, >+ GTK_INPUT_FCDEVICE_TYPE_QUIZKING = SIFC_QUIZKING, >+ GTK_INPUT_FCDEVICE_TYPE_FTRAINERA = SIFC_FTRAINERA, >+ GTK_INPUT_FCDEVICE_TYPE_FTRAINERB = SIFC_FTRAINERB, >+ GTK_INPUT_FCDEVICE_TYPE_OEKAKIDS = SIFC_OEKAKIDS, >+ GTK_INPUT_FCDEVICE_TYPE_BWORLD = SIFC_BWORLD, >+ GTK_INPUT_FCDEVICE_TYPE_TOPRIDER = SIFC_TOPRIDER >+ } GTK_INPUT_FCDEVICE_TYPE; >+ >+ >+typedef struct { >+ GTK_INPUT_DEVICES device; >+ uint8 type; >+ ButtConfig *config; >+ >+ GtkWidget *vbox, // vbox >+ *hbox, // main hbox for Port1 >+ *frame, // frame for Port1 >+ *label, // Label for Port1 >+ *but, // Button for Port1 >+ *option; // Device Option for Port1 >+ >+ gchar *menupath, >+ *portname, >+ *devicename; >+ >+ } GTK_INPUT_DEVICE; >+ >+ >+void DoInputConfig(GtkWidget *window); >+int GTKGUI_InputConfig_Init (void); >+void GTKGUI_DoSubConfig (GtkButton* button, GTK_INPUT_DEVICE *indevice); >+ >+ >+#endif >diff -urNb fceu/src/drivers/pc/gtk/inputconfig_gp.c fceu-0.98.2/src/drivers/pc/gtk/inputconfig_gp.c >--- fceu/src/drivers/pc/gtk/inputconfig_gp.c 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/inputconfig_gp.c 2004-03-15 00:05:00.983676613 -0600 >@@ -0,0 +1,161 @@ >+#include "inputconfig_gp.h" >+ >+#include "drawingarea.h" >+ >+#include "../main.h" >+#include "../dface.h" >+#include "../input.h" >+ >+#include <gtk/gtk.h> >+#include <gdk/gdk.h> >+ >+/* This should look nice if I use GtkImage with the gamepad graphic I spent >+ an hour or two on in Gimp. Inspired by the snes9x joypad config in Win32. >+ >+ GtkImage's on a GtkTable is a bad hack apparently. GtkDrawingArea with >+ Pixbuf's is the way to go. >+ >+ http://developer.gnome.org/doc/API/2.0/gtk/GtkImage.html#id3134873 >+ >+*/ >+ >+extern GtkWidget *mainwin; >+extern GtkWidget *inputcfgwin; >+GtkWidget *inputgpwin = NULL; >+ >+ // I'll just hard code this, and autoconf-itize it later >+#define GTKGUI_GP_UNLIT_GRAPHIC "/usr/share/fceu/pixmaps/GAMEPAD_UNLIT.png" >+#define GTKGUI_GP_LIT_GRAPHIC "/usr/share/fceu/pixmaps/GAMEPAD_LIT.png" >+ >+typedef enum { >+ GTK_INPUT_GP_A = 0, >+ GTK_INPUT_GP_B = 1, >+ GTK_INPUT_GP_SELECT = 2, >+ GTK_INPUT_GP_START = 3, >+ GTK_INPUT_GP_DUP = 4, >+ GTK_INPUT_GP_DDOWN = 5, >+ GTK_INPUT_GP_DLEFT = 6, >+ GTK_INPUT_GP_DRIGHT = 7, >+ GTK_INPUT_GP_TA = 8, >+ GTK_INPUT_GP_TB = 9, >+ NUM_GTK_INPUT_GP_BUTTONS >+ } GTK_INPUT_GPBUTTONS; >+ >+gchar *GPBUTTON_NAMES[] = { >+ "A", >+ "B", >+ "SELECT", >+ "START", >+ "Up", >+ "Down", >+ "Left", >+ "Right", >+ "Turbo A", >+ "Turbo B", >+ NULL >+ }; >+ >+ >+gtkgui_button buttonlist[] = { >+ { NULL, GTK_INPUT_GP_A, 454, 209, 64, 64 }, >+ { NULL, GTK_INPUT_GP_B, 379, 209, 64, 64 }, >+ { NULL, GTK_INPUT_GP_SELECT, 209, 208, 49, 56 }, >+ { NULL, GTK_INPUT_GP_START, 286, 208, 49, 56 }, >+ { NULL, GTK_INPUT_GP_DUP, 85, 147, 40, 40 }, >+ { NULL, GTK_INPUT_GP_DDOWN, 85, 227, 40, 40 }, >+ { NULL, GTK_INPUT_GP_DLEFT, 45, 187, 40, 40 }, >+ { NULL, GTK_INPUT_GP_DRIGHT, 125, 187, 40, 40 }, >+ { NULL, GTK_INPUT_GP_TA, 454, 141, 64, 64 }, >+ { NULL, GTK_INPUT_GP_TB, 379, 141, 64, 64 }, >+ }; >+ >+ >+typedef enum { >+ BUTTNAME_COLUMN, // Name of the button >+ NUMBUTTS_COLUMN, // Number of configured buttons >+ DEVTYPE_COLUMN, // Type of input chosen (keyboard, joy, etc) >+ BUTTSEL_COLUMN, // Selected button on the input device >+ N_GPCOLUMNS >+ } GPTREECOLS; >+ >+ >+void GTKGUI_GPConfig_Init () { >+ gtkgui_drawingarea *da = NULL; >+ GtkWidget *view = NULL; // Treeview widget for showing config >+ GtkTreeStore *store = NULL; >+ >+ view = NULL; // Delete this later, just to make gcc shut up >+ >+ inputgpwin = gtk_dialog_new_with_buttons ( "Gamepad Configuration", >+ GTK_WINDOW(inputcfgwin), >+ GTK_DIALOG_MODAL, >+ GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL); >+ >+ da = gtkgui_drawingarea_new ( GTKGUI_GP_UNLIT_GRAPHIC, GTKGUI_GP_LIT_GRAPHIC ); >+ >+ >+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG(inputgpwin)->vbox), da->da); >+ >+ g_signal_connect_swapped ( GTK_OBJECT (inputgpwin), >+ "response", >+ G_CALLBACK (gtk_widget_destroy), >+ GTK_OBJECT (inputgpwin)); >+ >+ store = gtk_tree_store_new ( N_GPCOLUMNS, // Total number of columns >+ G_TYPE_STRING, // Name of button >+ G_TYPE_STRING, // Number of corr. events >+ G_TYPE_STRING, // Type of input device >+ G_TYPE_STRING); // Button selected for event >+ >+ gtk_widget_show_all (inputgpwin); >+ >+ return; >+ } >+ >+ // This function will be called from the Properties button in >+ // inputconfig if GamePad is the selected device >+void GTKGUI_DoGPConfig (GTK_INPUT_DEVICE *in_device) { >+ // Lets start off by trying to list the button config in text: >+ int bl, dl, bcl; >+ ButtConfig *onebutton; >+ >+ for (bl = 0; bl < 10; bl++) { >+ FCEU_printf ("Gamepad config: Button Name = %s :\n", GPBUTTON_NAMES[bl]); >+ for (dl = 0; dl < 4; dl++) { >+ onebutton = &GamePadConfig[dl][bl]; >+ FCEU_printf ("\tButtType:\t[ "); // Duuhh, these are ButtConfig ptr's, not ints >+ for (bcl = 0; bcl < MAXBUTTCONFIG; bcl++) { >+ FCEU_printf ("%i\t",onebutton->ButtType[bcl]); >+ } >+ FCEU_printf (" ]\n"); >+ FCEU_printf ("\tDeviceNum:\t[ "); >+ for (bcl = 0; bcl < MAXBUTTCONFIG; bcl++) { >+ FCEU_printf ("%i\t",onebutton->DeviceNum[bcl]); >+ } >+ FCEU_printf (" ]\n"); >+ FCEU_printf ("\tButtonNum:\t[ "); >+ for (bcl = 0; bcl < MAXBUTTCONFIG; bcl++) { >+ FCEU_printf ("%i\t",onebutton->ButtonNum[bcl]); >+ } >+ FCEU_printf (" ]\n"); >+ FCEU_printf ("\tNumC: \t\t[ %i ]\n\n", onebutton->NumC); >+ } >+ FCEU_printf ("\n"); >+ } >+ GTKGUI_GPConfig_Init(); >+ return; >+ } >+ >+/* From input.h (I have no short term memory) >+ >+#define MAXBUTTCONFIG 4 >+ >+typedef struct { >+ uint8 ButtType[MAXBUTTCONFIG]; >+ uint8 DeviceNum[MAXBUTTCONFIG]; >+ uint16 ButtonNum[MAXBUTTCONFIG]; >+ uint32 NumC; >+ } ButtConfig; >+ >+ >+ */ >diff -urNb fceu/src/drivers/pc/gtk/inputconfig_gp.h fceu-0.98.2/src/drivers/pc/gtk/inputconfig_gp.h >--- fceu/src/drivers/pc/gtk/inputconfig_gp.h 1969-12-31 18:00:00.000000000 -0600 >+++ fceu-0.98.2/src/drivers/pc/gtk/inputconfig_gp.h 2004-03-15 00:05:01.397612695 -0600 >@@ -0,0 +1,13 @@ >+#ifndef __GTKGUI_INPUTCONFIG_GP_H_ >+#define __GTKGUI_INPUTCONFIG_GP_H_ >+ >+#include <gtk/gtk.h> >+ >+#include "inputconfig.h" >+ >+/* PROTOTYPES */ >+ >+void GTKGUI_DoGPConfig (GTK_INPUT_DEVICE *in_device); >+void GTKGUI_GPConfig_Init ( void ); >+ >+#endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44446
: 27595