Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 44446
Collapse All | Expand All

(-)fceu/configure.ac (+4 lines)
Lines 69-74 Link Here
69
if [[ "$use_gtk" = "yes" ]] ; then
69
if [[ "$use_gtk" = "yes" ]] ; then
70
	dnl Check for GTK
70
	dnl Check for GTK
71
	AM_PATH_GTK_2_0(2.2.0, AC_DEFINE([HAVE_GTK]), AC_MSG_ERROR("GTK2 requested but not found!"))
71
	AM_PATH_GTK_2_0(2.2.0, AC_DEFINE([HAVE_GTK]), AC_MSG_ERROR("GTK2 requested but not found!"))
72
	PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.3, 
73
		[	echo "Using experimental filechooser widget",
74
			AM_CONDITIONAL(HAVE_GTK24,true) ],
75
		[ AM_CONDITIONAL(HAVE_GTK24, false) ] )
72
	CFLAGS="$CFLAGS $GTK_CFLAGS "
76
	CFLAGS="$CFLAGS $GTK_CFLAGS "
73
	LIBS="$LIBS $GTK_LIBS "
77
	LIBS="$LIBS $GTK_LIBS "
74
	AC_DEFINE([EXTGUI])
78
	AC_DEFINE([EXTGUI])
(-)fceu/src/drivers/pc/Makefile.am.inc (+13 lines)
Lines 6-11 Link Here
6
6
7
fceu_SOURCES	+=	$(TMP_OGL)
7
fceu_SOURCES	+=	$(TMP_OGL)
8
8
9
if HAVE_GTK
10
TMP_GTK = drivers/pc/gtk/gtk-main.c drivers/pc/gtk/inputconfig.c drivers/pc/gtk/inputconfig_gp.c drivers/pc/gtk/drawingarea.c 
11
endif
12
13
if HAVE_GTK24
14
TMP_GTK_FC = drivers/pc/gtk/gtk-filechooser.c
15
else
16
TMP_GTK_FC = drivers/pc/gtk/gtk-fileopen.c
17
endif
18
19
fceu_SOURCES	+=	$(TMP_GTK)
20
fceu_SOURCES	+=	$(TMP_GTK_FC)
21
9
if HAVE_WX
22
if HAVE_WX
10
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
23
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
11
endif
24
endif
(-)fceu/src/drivers/pc/gtk/drawingarea.c (+185 lines)
Line 0 Link Here
1
#include "drawingarea.h"
2
3
4
#include <gtk/gtk.h>
5
#include <gdk/gdk.h>
6
#include <glib/gprintf.h>
7
8
9
	
10
gtkgui_drawingarea *gtkgui_drawingarea_new (gchar *filename_unlit, gchar *filename_lit) {
11
	gtkgui_drawingarea 	*ret 	=	NULL;
12
	GError      		*error  =	NULL;
13
	
14
	ret = g_new (gtkgui_drawingarea, 1);
15
	if (ret == NULL)
16
		return NULL;
17
	
18
	
19
	ret->da		= gtk_drawing_area_new  ();
20
	gtk_widget_add_events (	GTK_WIDGET(ret->da), 
21
								GDK_POINTER_MOTION_MASK
22
							|	GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK
23
							|	GDK_ENTER_NOTIFY_MASK
24
							|	GDK_LEAVE_NOTIFY_MASK
25
							|	GDK_FOCUS_CHANGE_MASK
26
							);
27
	
28
	ret->pixbuf_unlit	= gdk_pixbuf_new_from_file (filename_unlit, &error);
29
	if (ret->pixbuf_unlit == NULL) {
30
		g_printf ("Error #%i loading pixmap: \"%s\"\n\tERROR: %s\n", error->code, filename_unlit, error->message);
31
		}
32
	
33
	ret->pixbuf_lit	= gdk_pixbuf_new_from_file (filename_lit, &error);
34
	if (ret->pixbuf_lit == NULL) {
35
		g_printf ("Error #%i loading pixmap: \"%s\"\n\tERROR: %s\n", error->code, filename_lit, error->message);
36
		}
37
	
38
	
39
	
40
	ret->width	= gdk_pixbuf_get_width (ret->pixbuf_unlit);
41
	ret->height	= gdk_pixbuf_get_height(ret->pixbuf_unlit);
42
	
43
	gtk_widget_set_size_request (GTK_WIDGET(ret->da), ret->width, ret->height);
44
	
45
	g_signal_connect (G_OBJECT (ret->da), "expose_event", G_CALLBACK (gtkgui_drawingarea_expose_event_cb), ret);
46
	g_signal_connect (G_OBJECT (ret->da), "event",        G_CALLBACK (gtkgui_drawingarea_event_cb       ), ret);
47
48
	ret->buttons = NULL;
49
	ret->active_button = NULL;
50
	
51
	return (ret);
52
	}
53
54
	
55
void gtkgui_drawingarea_free (gtkgui_drawingarea *victim) {
56
	g_free (victim);
57
	}
58
59
gint gtkgui_findbutton (gconstpointer in_button, gconstpointer in_event) {
60
	gtkgui_button 		*button = (gtkgui_button  *)in_button;
61
	GdkEventMotion		*event  = (GdkEventMotion *)in_event;
62
	
63
	if (event->x >= button->x && event->x <= (button->x + button->width))
64
		if (event->y >= button->y && event->y <= (button->y + button->height)) {
65
			return 0;	// 0 indicates a match
66
			}
67
	
68
	return -1;
69
	}
70
71
gboolean gtkgui_drawingarea_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gtkgui_drawingarea *area) {
72
		
73
	gdk_pixbuf_render_to_drawable_alpha (	GDK_PIXBUF(area->pixbuf_unlit), 
74
											GDK_DRAWABLE(area->da->window),
75
											0, 0, 0, 0, -1, -1, 0, 0, GDK_RGB_DITHER_MAX, 0, 0);
76
	
77
//	g_list_foreach(area->buttons, (GFunc)gtkgui_button_draw, area->da->window);
78
	
79
	if (area->active_button != NULL) 
80
		gtkgui_button_draw (area, area->active_button);
81
	
82
	return TRUE;
83
	}
84
85
gboolean gtkgui_drawingarea_event_cb			(GtkWidget *widget, GdkEvent *event, gtkgui_drawingarea *area) {
86
	gboolean		 handled       = TRUE;
87
	GList			*active_button = NULL;
88
	
89
	switch (event->type) {
90
		case GDK_MOTION_NOTIFY :
91
			
92
			active_button = g_list_find_custom (area->buttons, event, &gtkgui_findbutton);
93
			
94
			if (active_button == NULL ) {
95
				if (area->active_button != NULL) {
96
					gtkgui_button	*oldbutton = area->active_button;
97
					area->active_button = NULL;
98
					gtkgui_button_draw (area, oldbutton);
99
					}
100
				}
101
			else {
102
				if (area->active_button != NULL) {
103
					if (active_button->data != area->active_button) {
104
						gtkgui_button	*oldbutton = area->active_button;
105
						area->active_button = NULL;
106
						gtkgui_button_draw (area, oldbutton);
107
						
108
						}
109
					}
110
				area->active_button = active_button->data;
111
				gtkgui_button_draw (area, active_button->data);
112
				}
113
			
114
			break;		
115
		case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS:
116
			break;
117
		case GDK_BUTTON_RELEASE :
118
			if (area->active_button != NULL) {
119
				g_printf ("Button press! button=%i\n", (int)area->active_button);
120
				
121
				}
122
			break;
123
		case GDK_EXPOSE :	// Ignore and let the other handler take this.
124
			handled = FALSE;
125
			break;
126
		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.
127
			break;
128
		case GDK_MAP:			//	
129
			break;
130
		case GDK_ENTER_NOTIFY:
131
			break;
132
		case GDK_LEAVE_NOTIFY:
133
			if (area->active_button != NULL) {
134
				gtkgui_button	*oldbutton = area->active_button;
135
				area->active_button = NULL;
136
				gtkgui_button_draw(area, oldbutton);
137
				}
138
			break;
139
		
140
		default:
141
			printf ("Unhandled event: %i\n", event->type);
142
			handled = FALSE;
143
			break;
144
		};	
145
	
146
	return (handled);
147
	}
148
149
150
151
152
gtkgui_button *gtkgui_button_register (gtkgui_drawingarea *da, gtkgui_button *inbutton) {
153
	if (da == NULL)
154
		return NULL;
155
	if (inbutton == NULL)
156
		return NULL;
157
	inbutton->parent	= da;
158
	da->buttons			= g_list_append (da->buttons, inbutton);		// Add self to the button list of the area
159
	return inbutton;
160
	}
161
162
163
void *gtkgui_button_draw						(gtkgui_drawingarea *area, gtkgui_button *button) {
164
	GdkPixbuf	*pixbuf = NULL;
165
	if (button->parent->active_button == button) {
166
		pixbuf = button->parent->pixbuf_lit;
167
		}
168
	else {
169
		pixbuf = button->parent->pixbuf_unlit;
170
		}
171
	
172
	gdk_draw_pixbuf (	GDK_DRAWABLE(area->da->window),
173
						NULL,
174
						GDK_PIXBUF(pixbuf),
175
						button->x, button->y,
176
						button->x, button->y, 
177
						button->width, button->height,
178
						GDK_RGB_DITHER_MAX,
179
						0, 0);
180
	return NULL;
181
	}
182
183
void *gtkgui_button_clicked_cb (gtkgui_button *button) {
184
	return NULL;
185
	}
(-)fceu/src/drivers/pc/gtk/drawingarea.h (+92 lines)
Line 0 Link Here
1
#ifndef __gtkdrawingarea_H__
2
#define __gtkdrawingarea_H__
3
4
5
#ifdef __GNUG__
6
    #pragma interface "drawingarea.c"
7
#endif
8
9
10
#ifndef GTK_PRECOMP
11
	#include <gtk/gtk.h>
12
	#include <glib.h>
13
	#include <glib/gprintf.h>
14
#endif
15
16
17
typedef struct {	
18
	GtkWidget		*da;			// The drawing area widget
19
	gint			 width,
20
					 height;
21
	GdkPixbuf		*pixbuf_unlit,	// The graphic with unlit buttons
22
					*pixbuf_lit;	// The graphic with lit buttons
23
	
24
	GList			*buttons;		// List of buttons
25
	void 			*active_button; // If a button should draw itself as lit this should point to it
26
	
27
	}	gtkgui_drawingarea;
28
29
30
typedef struct {
31
	gtkgui_drawingarea	*parent;
32
	gint				 type;		// This can be set to the type of button if there is an enumerated list of them
33
	gint				 x,			// Relative position of the button within the pixmap
34
						 y,
35
						 width,		// Dimensions of the button
36
						 height;
37
	}	gtkgui_button;
38
39
	
40
41
gtkgui_drawingarea 
42
	*gtkgui_drawingarea_new					(gchar *filename_unlit, gchar *filename_lit);
43
44
void 
45
	 gtkgui_drawingarea_free				(gtkgui_drawingarea *victim);
46
47
gboolean
48
	 gtkgui_drawingarea_expose_event_cb		(GtkWidget *widget, GdkEventExpose *event, gtkgui_drawingarea *area);
49
	
50
gboolean 
51
	 gtkgui_drawingarea_event_cb			(GtkWidget *widget, GdkEvent *event, gtkgui_drawingarea *area);
52
53
gint	// Tests a button to see if a GdkMotionEvent occured over it
54
	gtkgui_findbutton 						(gconstpointer in_button, gconstpointer in_event);
55
56
//gtkgui_button 
57
//	*gtkgui_button_new 						();
58
59
gtkgui_button 
60
	*gtkgui_button_register 				(gtkgui_drawingarea *da, gtkgui_button *inbutton);
61
62
void 
63
	*gtkgui_button_draw						(gtkgui_drawingarea *area, gtkgui_button *button);
64
65
void 
66
	*gtkgui_button_clicked_cb 				(gtkgui_button *button);
67
68
69
	
70
//gtkgui_tray 
71
//	*gtkgui_tray_new 						(gtkgui_drawingarea *area, gchar *filename, gint x, gint y);
72
73
//void 
74
//	*gtkgui_tray_draw 						(gtkgui_tray *tray, GdkDrawable *window);
75
	
76
//void
77
//	*gtkgui_tray_motion 					(gtkgui_tray *tray, GdkEventMotion *event);
78
79
//gtkgui_button 
80
//	*gtkgui_button_new 						(gtkgui_tray *tray, gchar *filename_unlit, gchar *filename_lit, gint x, gint y);
81
82
//void 
83
//	*gtkgui_button_draw						(gtkgui_button *button, GdkDrawable *window);
84
85
//void 
86
//	gtkgui_button_lit 						(gtkgui_button *button, gboolean lit);
87
88
//void
89
//	*gtkgui_button_motion 					(gtkgui_button *button, GdkEventMotion *event);
90
91
92
#endif		/*		__gtkdrawingarea_H__		*/
(-)fceu/src/drivers/pc/gtk/gtk-filechooser.c (+76 lines)
Line 0 Link Here
1
#include "gtk-fileopen.h"
2
#include "gtk-main.h"
3
4
#include <gtk/gtk.h>	// explicitly just for fun
5
#include <stdlib.h>		// free & malloc
6
#include <string.h>		// strlen
7
#include <stdio.h>
8
9
#include "../main.h"
10
#include "../dface.h"
11
12
#include <gtk/gtk.h>
13
14
static  GtkWidget 	*filew;
15
extern char 		*LastFile;
16
extern GString 		*bdir;
17
18
static void open_file( char *file ) {
19
	if(LoadGame(file)) {
20
		if(LastFile) {
21
			free(LastFile);
22
			}
23
		LastFile=malloc(strlen(file)+1);
24
		strcpy(LastFile, file);
25
		}
26
	}
27
28
void GTKGUI_fileopen( GtkWidget *w, gpointer   data ) {
29
	//cybercyst: use new gtk_file_chooser widget
30
    filew = gtk_file_chooser_dialog_new(	"File selection",
31
											GTK_WINDOW(w),
32
											GTK_FILE_CHOOSER_ACTION_OPEN,
33
											GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
34
											GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
35
											NULL);
36
	
37
	if (LastFile != NULL)
38
		gtk_file_chooser_select_filename (GTK_FILE_CHOOSER(filew), LastFile);
39
	
40
	if(gtk_dialog_run(GTK_DIALOG(filew)) == GTK_RESPONSE_ACCEPT) {
41
		char *filename;
42
		
43
		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filew) );
44
		
45
		open_file(filename);
46
		
47
		g_free (filename);
48
		}	
49
	
50
    gtk_widget_destroy(filew);
51
}
52
	
53
	
54
void GTKGUI_fileclose(GtkWidget *w, gpointer data) {
55
	CloseGame();
56
	return;
57
	}
58
59
uint8 *GetBaseDirectory(void) {
60
	uint8 *ret;
61
	ret=strdup(bdir->str);
62
	return(ret);
63
	}
64
65
FILE *FCEUD_UTF8fopen(const char *fn, const char *mode) {
66
	GString		*tmpfn   = g_string_new(fn);
67
	GString		*tmpmode = g_string_new(mode);
68
	
69
	FILE 		*tmpfile = fopen(tmpfn->str, tmpmode->str);
70
	
71
	FCEU_printf ("FCEUD_UTF8fopen : fn=\"%s\"  mode=\"%s\"  result=%i\n", tmpfn->str, tmpmode->str, (int)tmpfile);
72
	
73
	g_string_free(tmpfn,   TRUE);
74
	g_string_free(tmpmode, TRUE);
75
	return(tmpfile);
76
	}
(-)fceu/src/drivers/pc/gtk/gtk-fileopen.c (+74 lines)
Line 0 Link Here
1
#include "gtk-fileopen.h"
2
#include "gtk-main.h"
3
4
#include <gtk/gtk.h>	// explicitly just for fun
5
#include <stdlib.h>		// free & malloc
6
#include <string.h>		// strlen
7
#include <stdio.h>
8
9
#include "../main.h"
10
#include "../dface.h"
11
12
#include <gtk/gtk.h>
13
14
static  GtkWidget 	*filew;
15
extern char 		*LastFile;
16
extern GString 		*bdir;
17
18
static void file_ok_sel( GtkWidget *w, GtkFileSelection *fs ) {
19
	gchar *path= (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs));
20
	if(LoadGame(path)) {
21
		if(LastFile) {
22
			free(LastFile);
23
			}
24
		LastFile=malloc(strlen(path)+1);
25
		strcpy(LastFile,path);
26
		gtk_widget_destroy(filew);
27
		}
28
	}
29
30
void GTKGUI_fileopen( GtkWidget *w, gpointer   data ) {
31
32
    /* Create a new file selection widget */
33
    filew = gtk_file_selection_new ("File selection");
34
	
35
    /* Connect the ok_button to file_ok_sel function */
36
	g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION (filew)->ok_button), "clicked", (GtkSignalFunc) file_ok_sel, filew );
37
	
38
    /* Connect the cancel_button to destroy the widget */
39
    g_signal_connect_object ( 	GTK_OBJECT (GTK_FILE_SELECTION(filew)->cancel_button),
40
								"clicked",
41
								(GtkSignalFunc) gtk_widget_destroy,
42
								GTK_OBJECT (filew), 0	);
43
    
44
    /* Lets set the filename, as if this were a save dialog, and we are giving
45
     a default filename */
46
    gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew), LastFile);
47
    
48
    gtk_widget_show(filew);
49
	}
50
	
51
	
52
void GTKGUI_fileclose(GtkWidget *w, gpointer data) {
53
	CloseGame();
54
	return;
55
	}
56
57
uint8 *GetBaseDirectory(void) {
58
	uint8 *ret;
59
	ret=strdup(bdir->str);
60
	return(ret);
61
	}
62
63
FILE *FCEUD_UTF8fopen(const char *fn, const char *mode) {
64
	GString		*tmpfn   = g_string_new(fn);
65
	GString		*tmpmode = g_string_new(mode);
66
	
67
	FILE 		*tmpfile = fopen(tmpfn->str, tmpmode->str);
68
	
69
	FCEU_printf ("FCEUD_UTF8fopen : fn=\"%s\"  mode=\"%s\"  result=%i\n", tmpfn->str, tmpmode->str, (int)tmpfile);
70
	
71
	g_string_free(tmpfn,   TRUE);
72
	g_string_free(tmpmode, TRUE);
73
	return(tmpfile);
74
	}
(-)fceu/src/drivers/pc/gtk/gtk-fileopen.h (+16 lines)
Line 0 Link Here
1
2
#ifndef __gtkfileopen_H__
3
#define __gtkfileopen_H__
4
5
#ifndef GTK_PRECOMP
6
	#include <gtk/gtk.h>
7
#endif
8
9
#ifdef __GNUG__
10
    #pragma interface "gtk-fileopen.c"
11
#endif
12
13
void GTKGUI_fileopen( GtkWidget *w, gpointer   data );
14
void GTKGUI_fileclose(GtkWidget *w, gpointer data);
15
16
#endif
(-)fceu/src/drivers/pc/gtk/gtk-main.c (+292 lines)
Line 0 Link Here
1
2
#include "gtk-main.h"
3
#include "gtk-fileopen.h"
4
#include "inputconfig.h"
5
6
#include "../main.h"
7
#include "../dface.h"
8
#include "../sdl.h"
9
10
#include <unistd.h>
11
#include <glib/gprintf.h>
12
#include <stdlib.h>
13
14
static int				 exiting	= 0;
15
GtkWidget 				*mainwin	= NULL;
16
GString 				*bdir       = NULL;
17
18
static GtkTextBuffer 	*messagebuf = NULL;
19
static GtkWidget		*messageview= NULL;
20
21
static GtkTextTag		*txtmsgtag  = NULL;
22
static GtkTextTag		*txterrtag  = NULL;
23
static GtkTextIter		 txtiter;
24
static GtkTextMark      *txtendmark = NULL;
25
static gboolean			 autoscroll = TRUE;
26
27
	// Config stuff
28
uint8 			*LastFile	= NULL;
29
gint 			GUIwidth	= 600;	
30
gint			GUIheight	= 440;
31
32
extern int UsrInputType[3]; 
33
extern int InputType[3];   	/* Current */
34
  
35
	// Prototypes
36
37
int 	FCEUSDLmain(int argc, char **argv);
38
39
int 	GTKGUI_Init (void);
40
int 	GTKGUI_Main (void);
41
void 	GTKGUI_Quit(GtkWidget *w, gpointer data);
42
void 	GTKGUI_nesreset(void);
43
void 	GTKGUI_nespower(void);
44
45
void get_main_menu( GtkWidget **menubar );
46
47
void on_config_palette		(void);
48
void on_config_input		(void);
49
void on_config_sound		(void);
50
void on_config_video		(void);
51
void on_config_directories	(void);
52
53
static gint 		delete_event					( GtkWidget *widget, GdkEvent *event,		gpointer data );
54
gboolean    expose_event_cb					( GtkWidget *widget, GdkEventExpose *event,	gpointer user_data);
55
56
int main (int argc, char **argv) {
57
	
58
	gtk_init(&argc,&argv);
59
	
60
	mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
61
	
62
	bdir=g_string_new(getenv("HOME"));
63
	g_string_append (bdir,PSS);
64
	g_string_append (bdir,".fceultra");
65
	
66
	GTKGUI_Init();
67
	
68
	FCEUSDLmain(argc,argv);
69
	
70
	gtk_window_resize(GTK_WINDOW(mainwin), GUIwidth, GUIheight);	// Do this before it's shown
71
72
	if(argc>1) {
73
		GUI_Update();
74
		LoadGame(argv[argc-1]);
75
		}
76
	
77
	
78
	GTKGUI_Main();
79
	
80
		// I wonder how I can force a config save here...
81
	 CloseGame();
82
83
	return 0;
84
	}
85
86
static GtkItemFactoryEntry menu_items[] = {
87
//	PATH,								ACCEL,			CB					CB_A	TYPE		EXTRA_DATA
88
  { "/_Game",         					NULL,         	NULL, 				0,	"<Branch>" 		},
89
  { "/Game/_Open...",    				"<control>O", 	GTKGUI_fileopen, 	0,	NULL 			},
90
  { "/Game/_Close...",   				"<control>C", 	GTKGUI_fileclose, 	0,	NULL 			},
91
  { "/Game/sep1",     					NULL,         	NULL, 				0,	"<Separator>" 	},
92
  { "/Game/Quit",     					"<control>Q", 	GTKGUI_Quit, 		0,	NULL 			},
93
  { "/_System",							NULL,			NULL, 				0,	"<Branch>" 		},
94
  { "/System/_Reset",					NULL,			GTKGUI_nesreset,	0,	NULL			},
95
  { "/System/_Power",					NULL,			GTKGUI_nespower,	0,	NULL			},
96
  { "/System/sep1",						NULL,			NULL,				0,	"<Separator>"	},
97
  { "/System/_Cheats",					NULL,			NULL,				0,	NULL			},
98
  { "/System/_Debugger",				NULL,			NULL,				0,	NULL			},
99
  { "/_Configuration",      			NULL,         	NULL, 				0,	"<Branch>" 		},
100
  { "/Configuration/_PAL Emulation", 	NULL, 			NULL, 				0,	"<CheckItem>"	},
101
  { "/Configuration/_Game Genie Emulation",NULL,		NULL, 				0,	"<CheckItem>"	},
102
  { "/Configuration/sep1",				NULL,			NULL,				0,	"<Separator>"	},
103
  { "/Configuration/_Palette...",  		NULL,			on_config_palette,	0,	NULL			},
104
  { "/Configuration/_Input...",  		NULL,         	on_config_input,	0,	NULL 			},
105
  { "/Configuration/_Sound...",			NULL,			on_config_sound,	0,	NULL 			},
106
  { "/Configuration/_Video...",			NULL,			on_config_video,	0,	NULL 			},
107
  { "/Configuration/_Directories...",	NULL,			on_config_directories,0,NULL 			},
108
  { "/_Help",         					NULL,			NULL, 				0,	"<LastBranch>" 	},
109
  { "/_Help/_About...",   				NULL,         	NULL, 				0,	NULL 			},
110
  { "/_Help/_Message Log...",   		NULL,         	NULL, 				0,	NULL 			},
111
};
112
113
void get_main_menu( GtkWidget **menubar )
114
{
115
  GtkItemFactory 	*item_factory;
116
  GtkAccelGroup 	*accel_group 	= gtk_accel_group_new ();
117
  gint 				 nmenu_items	= sizeof (menu_items) / sizeof (menu_items[0]);
118
119
  /* This function initializes the item factory.
120
     Param 1: The type of menu - can be GTK_TYPE_MENU_BAR, GTK_TYPE_MENU, or GTK_TYPE_OPTION_MENU.
121
     Param 2: The path of the menu.
122
     Param 3: A pointer to a gtk_accel_group.  The item factory sets up
123
              the accelerator table while generating menus.
124
  */
125
126
  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
127
128
  /* This function generates the menu items. Pass the item factory,
129
     the number of items in the array, the array itself, and any
130
     callback data for the the menu items. */
131
  gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
132
133
  /* Attach the new accelerator group to the window. */
134
  gtk_window_add_accel_group (GTK_WINDOW (mainwin), accel_group);
135
136
  if (menubar)
137
    /* Finally, return the actual menu bar created by the item factory. */ 
138
    *menubar = gtk_item_factory_get_widget (item_factory, "<main>");
139
}
140
141
142
int GTKGUI_Init (void) {
143
	GtkWidget		*menubar		= NULL,
144
					*mainvbox		= NULL,
145
					*textscroll		= NULL;
146
	
147
	gtk_window_set_title(GTK_WINDOW(mainwin), "FCE Ultra");
148
	gtk_signal_connect(GTK_OBJECT(mainwin), "delete_event", GTK_SIGNAL_FUNC(delete_event),NULL);
149
	gtk_signal_connect(GTK_OBJECT(mainwin), "expose-event", GTK_SIGNAL_FUNC(expose_event_cb),NULL);
150
	
151
	gtk_window_resize(GTK_WINDOW(mainwin), GUIwidth, GUIheight);
152
	
153
	mainvbox=gtk_vbox_new(FALSE,2);
154
	gtk_container_border_width(GTK_CONTAINER(mainvbox), 1);
155
	gtk_container_add(GTK_CONTAINER(mainwin), mainvbox);
156
157
	get_main_menu(&menubar);
158
	gtk_box_pack_start(GTK_BOX(mainvbox),menubar,FALSE,TRUE,0);
159
160
	textscroll=gtk_scrolled_window_new(NULL,NULL);
161
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(textscroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
162
	
163
	messageview=gtk_text_view_new();
164
	messagebuf=gtk_text_view_get_buffer(GTK_TEXT_VIEW(messageview));
165
	gtk_text_view_set_editable (GTK_TEXT_VIEW(messageview), FALSE);
166
	
167
	txterrtag = gtk_text_buffer_create_tag (messagebuf, "errtxt", 	"foreground", "red", 	NULL);
168
	txtmsgtag = gtk_text_buffer_create_tag (messagebuf, "msgtxt",	"foreground", "blue",	NULL);
169
	
170
	gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER(messagebuf), &txtiter);
171
	txtendmark = gtk_text_buffer_create_mark (messagebuf, "endtxt", &txtiter, FALSE);		// This should give us something to "autoscroll" to
172
	
173
	gtk_container_add(GTK_CONTAINER(textscroll), messageview);
174
	
175
	gtk_box_pack_start(GTK_BOX(mainvbox), textscroll,TRUE,TRUE,0);
176
	
177
	gtk_widget_show_all(mainwin);
178
	
179
	return 0;
180
	}	
181
182
183
int GUI_Update(void) {
184
	while (gtk_events_pending()) {
185
		gtk_main_iteration();
186
		}
187
	return 0;
188
	}
189
190
191
int GUI_Idle(void) {
192
	GUI_Update();
193
	usleep(10000);
194
	return(!exiting);
195
	}
196
197
198
int GTKGUI_Main () {
199
	
200
	while(!exiting) {
201
					
202
		if(CurGame) {
203
			DoFun();
204
			}
205
		
206
		GUI_Idle();
207
		}	// End of while !exiting
208
	
209
	return 1;
210
	}
211
	
212
static gint delete_event( GtkWidget *widget, GdkEvent  *event, gpointer   data ) {
213
    exiting=1;
214
    CloseGame();
215
    return(FALSE);
216
	}
217
218
gboolean expose_event_cb ( GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
219
	int w=0, h=0;
220
	gtk_window_get_size(GTK_WINDOW(mainwin), &w, &h);
221
	if (w != GUIwidth || h != GUIheight) {
222
		GUIwidth=w;
223
		GUIheight=h;
224
		}
225
	return FALSE;	 	// True "eats" the signal so nothing else gets it
226
	}
227
228
void GTKGUI_Quit(GtkWidget *w, gpointer data) {
229
	gtk_widget_destroy(mainwin);
230
	delete_event(0,0,0);
231
	}
232
233
234
void GUI_RequestExit(void) {
235
	}
236
237
238
void GUI_Hide(int hide) {
239
	}
240
241
242
void Giggles(int k) {	//	Input init ??
243
	}
244
245
246
void FCEUD_PrintError(char *str) {
247
	gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER(messagebuf), &txtiter);
248
	gtk_text_buffer_insert_with_tags(messagebuf, &txtiter, str, -1, txterrtag, NULL);
249
	if (autoscroll)
250
		gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW(messageview), GTK_TEXT_MARK(txtendmark), 0, TRUE, 1.0, 1.0);
251
	}
252
	
253
void FCEUD_Message(char *str) {
254
	gtk_text_buffer_get_end_iter (messagebuf, &txtiter);
255
	gtk_text_buffer_insert_with_tags(GTK_TEXT_BUFFER(messagebuf), &txtiter, str, -1, txtmsgtag, NULL);
256
	if (autoscroll)
257
		gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW(messageview), GTK_TEXT_MARK(txtendmark), 0, TRUE, 1.0, 1.0);
258
	}
259
260
	
261
void GTKGUI_nesreset(void) {
262
	FCEUI_ResetNES();
263
	}
264
265
void GTKGUI_nespower(void) {
266
	FCEUI_PowerNES();
267
	}
268
	
269
void on_config_palette(void) {
270
	}
271
	
272
void on_config_input(void) {
273
	GTKGUI_InputConfig_Init();
274
	}
275
	
276
void on_config_sound(void) {
277
	}
278
	
279
void on_config_video(void) {
280
	}	
281
	
282
void on_config_directories(void) {
283
	}
284
285
	
286
287
CFGSTRUCT GUIConfig[]={
288
	ACS(LastFile),
289
	AC(GUIwidth),
290
	AC(GUIheight),
291
	ENDCFGSTRUCT
292
	};
(-)fceu/src/drivers/pc/gtk/gtk-main.h (+21 lines)
Line 0 Link Here
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        gtk-main.h
3
// Author:      Curtis Magyar
4
// Created:     2004-01-30
5
// Copyright:   2004
6
/////////////////////////////////////////////////////////////////////////////
7
8
#ifndef __gtkmain_H__
9
#define __gtkmain_H__
10
11
#ifdef __GNUG__
12
    #pragma interface "gtk-main.c"
13
#endif
14
15
#ifndef GTK_PRECOMP
16
	#include <gtk/gtk.h>
17
#endif
18
19
20
21
#endif
(-)fceu/src/drivers/pc/gtk/input.c (+17 lines)
Line 0 Link Here
1
#include "gtk-main.h"
2
3
#include "../main.h"
4
#include "../dface.h"
5
6
#include "input.h"
7
	/*
8
	
9
struct NSFControl {
10
	void	 Down(void);
11
	void	 Down10(void);
12
	void	 Up(void);
13
	void	 Up10(void);
14
	gchar	*Current;
15
	};
16
	
17
	*/
(-)fceu/src/drivers/pc/gtk/input.h (+9 lines)
Line 0 Link Here
1
2
#ifndef __gtkinput_H__
3
#define __gtkinput_H__
4
5
void StartGameExInput(GtkWidget *window, int type);
6
void StopGameExInput(void);
7
8
9
#endif
(-)fceu/src/drivers/pc/gtk/inputconfig.c (+358 lines)
Line 0 Link Here
1
2
3
#include "inputconfig.h"
4
#include "gtk-main.h"
5
#include "inputconfig_gp.h"
6
7
#include <glib/gprintf.h>
8
9
GtkWidget				*inputcfgwin 		= NULL;
10
extern GtkWidget 		*mainwin;
11
12
 extern int UsrInputType[3]; 
13
 extern int    InputType[3];   /* Current */
14
15
const gchar *GTK_INPUT_DEVICE_NAMES[] =		{
16
	 "[NONE]",
17
	 "Port 1",
18
	 "Port 2",
19
	 "Famicom Expansion Port"
20
	};
21
#define GTK_GET_DEVICE_NAME(x)  GTK_INPUT_DEVICE_NAMES[x] 
22
23
24
const gchar *GTK_INPUT_DEVICE_MENUPATHS[] =		{
25
	"<main>/NONE",
26
	"<main>/PORT1",
27
	"<main>/PORT2",
28
	"<main>/FC"
29
	};
30
	
31
#define GTK_MENU_GET_PATH(x)  GTK_INPUT_DEVICE_MENUPATHS[x] 
32
	
33
const gchar *GTK_INPUT_DEVICE_TYPE_NAMES[] = 	{
34
	"[NONE]",
35
	"Game Pad",
36
	"Zapper",
37
	"Power Pad A",
38
	"Power Pad B",
39
	"Arkanoid", 
40
	NULL
41
	};
42
43
const gchar *GTK_INPUT_FCDEVICE_TYPE_NAMES[] = 	{
44
	"[NONE]",
45
	"Arkanoid",
46
	"Space Shadow Gun",
47
    "Four-Player Adapter",
48
    "Family BASIC Keyboard",
49
    "HyperShot",
50
    "Mahjong",
51
    "Quiz King Buzzers",
52
    "Family Trainer A",
53
    "Family Trainer B",
54
    "Oeka Kids Tablet",
55
	"Barcode World",
56
	"Top Rider",
57
	NULL
58
	};
59
60
const gchar *GTK_INPUT_UNKNOWN_TYPE_NAMES[] = 	{
61
	"[UNKNOWN]",
62
	NULL
63
	};
64
65
66
void	GTKGUI_JoyConfigDeleteEvent		(void);
67
68
void input_device_selected_cb (GTK_INPUT_DEVICE *in_device, guint callback_action, GtkWidget *widget);
69
void GTKGUI_get_inputdev_config (GTK_INPUT_DEVICE *in_device);
70
	
71
72
GTK_INPUT_DEVICE	input_device[3];
73
74
void 				input_device_new		(GTK_INPUT_DEVICE *indevice, GTK_INPUT_DEVICES indev, GTK_INPUT_DEVICE_TYPE intype);
75
void 				get_input_device_menu	(GTK_INPUT_DEVICE *device);
76
77
	
78
 /*		From input.h (I have no short term memory)
79
80
#define MAXBUTTCONFIG   4
81
82
typedef struct {
83
        uint8  ButtType[MAXBUTTCONFIG];
84
        uint8  DeviceNum[MAXBUTTCONFIG];
85
        uint16 ButtonNum[MAXBUTTCONFIG];
86
        uint32 NumC;
87
		} ButtConfig;
88
  */
89
 
90
extern ButtConfig GamePadConfig		[4][10];
91
extern ButtConfig powerpadsc		[2][12];
92
extern ButtConfig QuizKingButtons	[6];
93
extern ButtConfig FTrainerButtons	[12];
94
	
95
	
96
GtkItemFactoryEntry input_unknown_menu_items[] = {
97
	{	"/UNKNOWN",			NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_NONE,	NULL	}
98
	};
99
100
GtkItemFactoryEntry input_device_menu_items[] = {
101
	{	"/_NONE",			NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_NONE,	NULL	},
102
	{	"/_Game Pad", 		NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_GP,  	NULL	},
103
	{	"/_Zapper",			NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_ZAP, 	NULL	},
104
	{	"/Power Pad _A",	NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_PPA,	NULL	},
105
	{	"/Power Pad _B",	NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_PPB,	NULL	},
106
	{	"/A_rkanoid",		NULL, input_device_selected_cb, GTK_INPUT_DEVICE_TYPE_ARK,	NULL	}
107
	};
108
109
GtkItemFactoryEntry input_fcdevice_menu_items[] = {
110
	{	"/_NONE",                   NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_NONE,		NULL	},
111
	{	"/A_rkanoid",               NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_ARK,		NULL	},
112
	{	"/_Space Shadow Gun",       NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_SHADOW,		NULL	},
113
	{	"/_Four-Player Adapter",    NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_4PLAYER,	NULL	},
114
	{	"/Family BASIC _Keyboard",  NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_FKB,		NULL	},
115
	{	"/_HyperShot",              NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_HYPERSHOT,	NULL	},
116
	{	"/_Mahjong",                NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_MAHJONG,	NULL	},
117
	{	"/_Quiz King Buzzers",      NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_QUIZKING,	NULL	},
118
	{	"/Family Trainer _A",       NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_FTRAINERA,	NULL	},
119
	{	"/Family Trainer _B",       NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_FTRAINERB,	NULL	},
120
	{	"/_Oeka Kids Tablet",       NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_OEKAKIDS,	NULL	},
121
	{	"/_Barcode World",          NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_BWORLD,		NULL	},
122
	{	"/_Top Rider",              NULL, input_device_selected_cb, GTK_INPUT_FCDEVICE_TYPE_TOPRIDER,	NULL	}
123
	};
124
125
	
126
	
127
	
128
	
129
void get_input_device_menu( GTK_INPUT_DEVICE *device ) {
130
	gint				 nmenu_items	= -1;
131
	gchar				*accelpath 		= (gchar *)GTK_MENU_GET_PATH(device->device);
132
	GtkAccelGroup 		*accel_group 	= gtk_accel_group_new ();
133
	GtkItemFactory 		*item_factory	= NULL;
134
		
135
	item_factory	= gtk_item_factory_new (GTK_TYPE_OPTION_MENU, accelpath, accel_group);
136
	
137
	switch (device->device) {
138
		case GTK_INPUT_DEVICE_PORT1:  
139
			nmenu_items = sizeof (input_device_menu_items) / sizeof ((input_device_menu_items)[0]);
140
			gtk_item_factory_create_items (item_factory, nmenu_items, input_device_menu_items, device);
141
			break;
142
		case GTK_INPUT_DEVICE_PORT2:
143
			nmenu_items = sizeof (input_device_menu_items) / sizeof ((input_device_menu_items)[0]);
144
			gtk_item_factory_create_items (item_factory, nmenu_items, input_device_menu_items, device);
145
			break;
146
		case GTK_INPUT_DEVICE_FC:
147
			nmenu_items = sizeof (input_fcdevice_menu_items) / sizeof ((input_fcdevice_menu_items)[0]);
148
			gtk_item_factory_create_items (item_factory, nmenu_items, input_fcdevice_menu_items, device);
149
			break;
150
		default:
151
			nmenu_items = sizeof (input_unknown_menu_items) / sizeof ((input_unknown_menu_items)[0]);
152
			gtk_item_factory_create_items (item_factory, nmenu_items, input_unknown_menu_items, device);
153
			break;
154
		};
155
	
156
  	gtk_window_add_accel_group (GTK_WINDOW (inputcfgwin), GTK_ACCEL_GROUP(accel_group));
157
158
	if (device) {
159
		device->option = gtk_item_factory_get_widget (item_factory, accelpath);
160
		gtk_option_menu_set_history(GTK_OPTION_MENU(device->option), device->type);
161
		}
162
	}
163
164
165
void DoInputConfig(GtkWidget *window){
166
	GTKGUI_InputConfig_Init();
167
	}
168
169
170
int GTKGUI_InputConfig_Init (void) {
171
	GtkWidget		*vboxM 		= NULL,		//	main vbox for dialog
172
					*hboxM		= NULL,		//	hbox for Ports
173
					*butM		= NULL;		//	Close Button
174
175
	inputcfgwin=gtk_window_new(GTK_WINDOW_TOPLEVEL);
176
	
177
	g_signal_connect(GTK_OBJECT(inputcfgwin), "delete_event", GTK_SIGNAL_FUNC(GTKGUI_JoyConfigDeleteEvent),NULL);
178
	gtk_window_set_transient_for(GTK_WINDOW(inputcfgwin), GTK_WINDOW(mainwin));
179
	gtk_window_set_title(GTK_WINDOW(inputcfgwin), "Input Configuration");
180
	gtk_window_set_modal(GTK_WINDOW(inputcfgwin), TRUE);
181
	
182
	vboxM = gtk_vbox_new(FALSE, 2);
183
	gtk_container_add(GTK_CONTAINER(inputcfgwin), vboxM);
184
	
185
	hboxM=gtk_hbox_new(TRUE, 2);
186
	gtk_box_pack_start(GTK_BOX(vboxM), hboxM, TRUE, TRUE, 2);
187
	
188
	butM=gtk_button_new_from_stock(GTK_STOCK_CLOSE);
189
190
	input_device_new(&input_device[0], GTK_INPUT_DEVICE_PORT1, 	UsrInputType[0]);
191
	input_device_new(&input_device[1], GTK_INPUT_DEVICE_PORT2, 	UsrInputType[1]);
192
	input_device_new(&input_device[2], GTK_INPUT_DEVICE_FC, 	UsrInputType[2]);
193
194
	gtk_box_pack_start(GTK_BOX(hboxM), input_device[0].frame, TRUE, TRUE, 2);
195
	gtk_box_pack_start(GTK_BOX(hboxM), input_device[1].frame, TRUE, TRUE, 2);
196
	gtk_box_pack_start(GTK_BOX(vboxM), input_device[2].frame, TRUE, TRUE, 2);
197
	gtk_box_pack_start(GTK_BOX(vboxM), butM, FALSE, FALSE, 2);
198
	
199
	gtk_signal_connect(GTK_OBJECT(butM), "clicked", GTK_SIGNAL_FUNC(GTKGUI_JoyConfigDeleteEvent),NULL);
200
	
201
	KillVideo();
202
	
203
	gtk_widget_show_all(inputcfgwin);
204
	
205
	if(CurGame) 
206
		InitVideo(CurGame);
207
	
208
	return 0;
209
	}
210
211
212
	//	Creates, and assembles the subdevice frames of the input dialog
213
void input_device_new(GTK_INPUT_DEVICE *indevice, GTK_INPUT_DEVICES indev, GTK_INPUT_DEVICE_TYPE intype) {
214
	indevice->device=indev;
215
	indevice->type=intype;
216
	
217
	indevice->portname   = (gchar *)GTK_INPUT_DEVICE_NAMES[indev];
218
	indevice->frame=gtk_frame_new((gchar *)indevice->portname);
219
	indevice->vbox=gtk_vbox_new(FALSE, 2);
220
	indevice->hbox=gtk_hbox_new(FALSE, 2);
221
	
222
	
223
	switch (intype) {
224
		case GTK_INPUT_DEVICE_PORT1: case GTK_INPUT_DEVICE_PORT2: 
225
			indevice->devicename = (gchar *)GTK_INPUT_DEVICE_TYPE_NAMES[intype];
226
			break;
227
		case GTK_INPUT_DEVICE_FC:
228
			indevice->devicename = (gchar *)GTK_INPUT_FCDEVICE_TYPE_NAMES[intype];
229
			break;
230
		default:
231
			indevice->devicename = (gchar *)GTK_INPUT_UNKNOWN_TYPE_NAMES[0];
232
			break;
233
		};
234
		
235
	indevice->label=gtk_label_new(indevice->devicename);
236
	indevice->but=gtk_button_new_from_stock(GTK_STOCK_PROPERTIES);
237
		
238
	get_input_device_menu(indevice);				//  Init the device struct and hook its button to the cb function
239
	
240
	gtk_box_pack_start(GTK_BOX(indevice->hbox), indevice->label,	 TRUE,  TRUE, 2);
241
	gtk_box_pack_start(GTK_BOX(indevice->hbox), indevice->but,		FALSE, FALSE, 2);
242
	gtk_box_pack_start(GTK_BOX(indevice->vbox), indevice->hbox,		FALSE,  TRUE, 2);
243
	gtk_box_pack_start(GTK_BOX(indevice->vbox), indevice->option,	FALSE,  TRUE, 2);
244
	
245
	g_signal_connect(GTK_OBJECT(indevice->but), "clicked", GTK_SIGNAL_FUNC(GTKGUI_DoSubConfig), indevice);
246
	
247
	GTKGUI_get_inputdev_config(indevice);
248
		
249
	gtk_container_add(GTK_CONTAINER(indevice->frame), indevice->vbox);
250
	}
251
252
void GTKGUI_get_inputdev_config (GTK_INPUT_DEVICE *in_device) {
253
	switch (in_device->device) {
254
		case GTK_INPUT_DEVICE_PORT1:	case GTK_INPUT_DEVICE_PORT2:
255
			switch (in_device->type) {
256
				case GTK_INPUT_DEVICE_TYPE_GP:
257
					in_device->config = (ButtConfig *)&GamePadConfig;
258
					break;
259
				case GTK_INPUT_DEVICE_TYPE_ZAP:
260
					in_device->config = NULL;
261
					break;
262
				case GTK_INPUT_DEVICE_TYPE_PPA: case GTK_INPUT_DEVICE_TYPE_PPB:
263
					in_device->config = (ButtConfig *)&powerpadsc;
264
					break;
265
				case GTK_INPUT_DEVICE_TYPE_ARK:
266
					in_device->config = NULL;
267
					break;
268
				case GTK_INPUT_DEVICE_TYPE_NONE :	
269
				default:
270
					in_device->config = NULL;
271
					break;
272
				};
273
			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]);
274
			gtk_label_set_text (GTK_LABEL(in_device->label), GTK_INPUT_DEVICE_TYPE_NAMES[in_device->type]);
275
			break;
276
		case GTK_INPUT_DEVICE_FC:
277
			switch (in_device->type) {
278
				case GTK_INPUT_FCDEVICE_TYPE_ARK:
279
					break;
280
				case GTK_INPUT_FCDEVICE_TYPE_SHADOW:
281
					break;
282
				case GTK_INPUT_FCDEVICE_TYPE_4PLAYER:
283
					break;
284
				case GTK_INPUT_FCDEVICE_TYPE_FKB:
285
					break;
286
				case GTK_INPUT_FCDEVICE_TYPE_HYPERSHOT:
287
					break;
288
				case GTK_INPUT_FCDEVICE_TYPE_MAHJONG:
289
					break;
290
				case GTK_INPUT_FCDEVICE_TYPE_QUIZKING:
291
					in_device->config = (ButtConfig *)&QuizKingButtons;
292
					break;
293
				case GTK_INPUT_FCDEVICE_TYPE_FTRAINERA: case GTK_INPUT_FCDEVICE_TYPE_FTRAINERB:
294
					in_device->config = (ButtConfig *)&FTrainerButtons;
295
					break;
296
				case GTK_INPUT_FCDEVICE_TYPE_OEKAKIDS:
297
					break;
298
				case GTK_INPUT_FCDEVICE_TYPE_BWORLD:
299
					break;
300
				case GTK_INPUT_FCDEVICE_TYPE_TOPRIDER:
301
					break;
302
				default: case GTK_INPUT_FCDEVICE_TYPE_NONE:
303
					in_device->config = NULL;
304
					break;
305
				};
306
			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]);
307
			gtk_label_set_text (GTK_LABEL(in_device->label), GTK_INPUT_FCDEVICE_TYPE_NAMES[in_device->type]);
308
			break;
309
		default:
310
			in_device->config = NULL;
311
			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]);
312
			gtk_label_set_text (GTK_LABEL(in_device->label), GTK_INPUT_UNKNOWN_TYPE_NAMES[in_device->type]);
313
			break;
314
		};
315
	
316
	}	
317
	
318
	// This is called when the user selects a new device for an input port
319
void input_device_selected_cb (	GTK_INPUT_DEVICE	*in_device,
320
								guint callback_action,
321
								GtkWidget *widget) {
322
	if (!in_device)
323
		return;
324
	
325
	in_device->type 					= callback_action;
326
	
327
	InputType[in_device->device    - 1]  = callback_action;
328
	InitOtherInput();
329
	
330
	GTKGUI_get_inputdev_config (in_device);
331
	
332
	}
333
334
335
void	GTKGUI_DoSubConfig (GtkButton* button, GTK_INPUT_DEVICE *indevice) {
336
	FCEU_printf ("GTKGUI_DoSubConfig requested for %s %s  config=%i\n", indevice->portname, indevice->devicename, (int)indevice->config);
337
	if (indevice->device == GTK_INPUT_DEVICE_PORT1 || indevice->device == GTK_INPUT_DEVICE_PORT2) {
338
		switch (indevice->type) {
339
			case GTK_INPUT_DEVICE_TYPE_GP:
340
				GTKGUI_DoGPConfig (indevice);
341
				break;
342
			default:
343
				break;
344
			};
345
		}
346
	else {
347
		switch (indevice->type) {
348
			
349
			default:
350
				break;
351
			};
352
		}
353
	}
354
355
356
void	GTKGUI_JoyConfigDeleteEvent (void) {
357
	gtk_widget_destroy(inputcfgwin);
358
	}
(-)fceu/src/drivers/pc/gtk/inputconfig.h (+76 lines)
Line 0 Link Here
1
#ifndef __GTKGUI_INPUTCONFIG_H_
2
#define __GTKGUI_INPUTCONFIG_H_
3
4
#ifdef __GNUG__
5
    #pragma interface "inputconfig.c"
6
#endif
7
8
#ifndef GTK_PRECOMP
9
	#include <gtk/gtk.h>
10
#endif
11
12
#include "../main.h"
13
#include "../dface.h"
14
#include "../input.h"
15
16
17
typedef enum {
18
	GTK_INPUT_DEVICE_NONE  = 0,
19
	GTK_INPUT_DEVICE_PORT1 = 1,
20
	GTK_INPUT_DEVICE_PORT2 = 2,
21
	GTK_INPUT_DEVICE_FC    = 3,
22
	NUM_GTK_INPUT_DEVICES
23
	} GTK_INPUT_DEVICES;
24
	
25
typedef enum {
26
	GTK_INPUT_DEVICE_TYPE_NONE	=	SI_NONE,
27
	GTK_INPUT_DEVICE_TYPE_GP	=	SI_GAMEPAD,
28
	GTK_INPUT_DEVICE_TYPE_ZAP	=	SI_ZAPPER,
29
	GTK_INPUT_DEVICE_TYPE_PPA	=	SI_POWERPADA,
30
	GTK_INPUT_DEVICE_TYPE_PPB	=	SI_POWERPADB, 
31
	GTK_INPUT_DEVICE_TYPE_ARK	=	SI_ARKANOID,
32
	NUM_GTK_INPUT_DEVICE_TYPES
33
	} GTK_INPUT_DEVICE_TYPE;
34
35
typedef enum {
36
	GTK_INPUT_FCDEVICE_TYPE_NONE		= SIFC_NONE,
37
	GTK_INPUT_FCDEVICE_TYPE_ARK			= SIFC_ARKANOID,
38
	GTK_INPUT_FCDEVICE_TYPE_SHADOW		= SIFC_SHADOW,
39
	GTK_INPUT_FCDEVICE_TYPE_4PLAYER		= SIFC_4PLAYER,
40
	GTK_INPUT_FCDEVICE_TYPE_FKB			= SIFC_FKB,
41
	GTK_INPUT_FCDEVICE_TYPE_HYPERSHOT	= SIFC_HYPERSHOT,
42
	GTK_INPUT_FCDEVICE_TYPE_MAHJONG		= SIFC_MAHJONG,
43
	GTK_INPUT_FCDEVICE_TYPE_QUIZKING	= SIFC_QUIZKING,
44
	GTK_INPUT_FCDEVICE_TYPE_FTRAINERA	= SIFC_FTRAINERA,
45
	GTK_INPUT_FCDEVICE_TYPE_FTRAINERB	= SIFC_FTRAINERB,
46
	GTK_INPUT_FCDEVICE_TYPE_OEKAKIDS	= SIFC_OEKAKIDS,
47
	GTK_INPUT_FCDEVICE_TYPE_BWORLD		= SIFC_BWORLD,
48
	GTK_INPUT_FCDEVICE_TYPE_TOPRIDER	= SIFC_TOPRIDER
49
	} GTK_INPUT_FCDEVICE_TYPE;
50
	
51
52
typedef struct {
53
	GTK_INPUT_DEVICES		device;
54
	uint8	 				type;
55
	ButtConfig			   *config;
56
	
57
	GtkWidget		*vbox,		//	vbox
58
					*hbox,		//	main hbox for Port1
59
					*frame,		//	frame for Port1
60
					*label,		//	Label for Port1
61
					*but,		//	Button for Port1
62
					*option;	//	Device Option for Port1
63
	
64
	gchar			*menupath,
65
					*portname,
66
					*devicename;
67
	
68
	} GTK_INPUT_DEVICE;	
69
70
	
71
void 	DoInputConfig(GtkWidget *window);
72
int 	GTKGUI_InputConfig_Init (void);
73
void	GTKGUI_DoSubConfig (GtkButton* button, GTK_INPUT_DEVICE *indevice);
74
75
76
#endif
(-)fceu/src/drivers/pc/gtk/inputconfig_gp.c (+161 lines)
Line 0 Link Here
1
#include "inputconfig_gp.h"
2
3
#include "drawingarea.h"
4
5
#include "../main.h"
6
#include "../dface.h"
7
#include "../input.h"
8
9
#include <gtk/gtk.h>
10
#include <gdk/gdk.h>
11
12
/*	This should look nice if I use GtkImage with the gamepad graphic I spent
13
	an hour or two on in Gimp.  Inspired by the snes9x joypad config in Win32.
14
	
15
	GtkImage's on a GtkTable is a bad hack apparently.  GtkDrawingArea with
16
	Pixbuf's is the way to go.
17
	
18
	http://developer.gnome.org/doc/API/2.0/gtk/GtkImage.html#id3134873
19
20
*/
21
22
extern GtkWidget 		*mainwin;
23
extern GtkWidget		*inputcfgwin;
24
GtkWidget				*inputgpwin 		= NULL;
25
26
	// I'll just hard code this, and autoconf-itize it later
27
#define GTKGUI_GP_UNLIT_GRAPHIC "/usr/share/fceu/pixmaps/GAMEPAD_UNLIT.png"
28
#define GTKGUI_GP_LIT_GRAPHIC   "/usr/share/fceu/pixmaps/GAMEPAD_LIT.png"
29
30
typedef enum {
31
	GTK_INPUT_GP_A		= 0,
32
	GTK_INPUT_GP_B		= 1,
33
	GTK_INPUT_GP_SELECT	= 2,
34
	GTK_INPUT_GP_START	= 3,
35
	GTK_INPUT_GP_DUP	= 4,
36
	GTK_INPUT_GP_DDOWN	= 5,
37
	GTK_INPUT_GP_DLEFT	= 6,
38
	GTK_INPUT_GP_DRIGHT	= 7,
39
	GTK_INPUT_GP_TA		= 8,
40
	GTK_INPUT_GP_TB		= 9,
41
	NUM_GTK_INPUT_GP_BUTTONS
42
	} GTK_INPUT_GPBUTTONS;
43
44
gchar			*GPBUTTON_NAMES[] = {
45
	"A",
46
	"B",
47
	"SELECT",
48
	"START",
49
	"Up",
50
	"Down",
51
	"Left",
52
	"Right",
53
	"Turbo A",
54
	"Turbo B",
55
	NULL
56
	};
57
58
59
gtkgui_button		buttonlist[] = {
60
	{ NULL, GTK_INPUT_GP_A,      454, 209, 64, 64 },
61
	{ NULL, GTK_INPUT_GP_B,      379, 209, 64, 64 },
62
	{ NULL, GTK_INPUT_GP_SELECT, 209, 208, 49, 56 },
63
	{ NULL, GTK_INPUT_GP_START,  286, 208, 49, 56 },
64
	{ NULL, GTK_INPUT_GP_DUP,     85, 147, 40, 40 },
65
	{ NULL, GTK_INPUT_GP_DDOWN,   85, 227, 40, 40 },
66
	{ NULL, GTK_INPUT_GP_DLEFT,   45, 187, 40, 40 },
67
	{ NULL, GTK_INPUT_GP_DRIGHT, 125, 187, 40, 40 },
68
	{ NULL, GTK_INPUT_GP_TA,     454, 141, 64, 64 },
69
	{ NULL, GTK_INPUT_GP_TB,     379, 141, 64, 64 },
70
	};
71
72
73
typedef enum {
74
	BUTTNAME_COLUMN,	// Name of the button
75
	NUMBUTTS_COLUMN,	// Number of configured buttons
76
	DEVTYPE_COLUMN,		// Type of input chosen (keyboard, joy, etc)
77
	BUTTSEL_COLUMN,		// Selected button on the input device
78
	N_GPCOLUMNS
79
	} GPTREECOLS;
80
	
81
	
82
void GTKGUI_GPConfig_Init () {
83
	gtkgui_drawingarea	*da 	= NULL;
84
	GtkWidget			*view	= NULL;		// Treeview widget for showing config
85
	GtkTreeStore		*store	= NULL;
86
	
87
	view = NULL;	// Delete this later, just to make gcc shut up
88
	
89
	inputgpwin 	= gtk_dialog_new_with_buttons (	"Gamepad Configuration",
90
												GTK_WINDOW(inputcfgwin),
91
												GTK_DIALOG_MODAL,
92
												GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
93
	
94
	da 			= gtkgui_drawingarea_new ( GTKGUI_GP_UNLIT_GRAPHIC, GTKGUI_GP_LIT_GRAPHIC );
95
	
96
	
97
	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(inputgpwin)->vbox), da->da);
98
99
	g_signal_connect_swapped (	GTK_OBJECT (inputgpwin), 
100
                             	"response", 
101
                             	G_CALLBACK (gtk_widget_destroy),
102
                             	GTK_OBJECT (inputgpwin));
103
104
	store = gtk_tree_store_new (	N_GPCOLUMNS,		// Total number of columns
105
									G_TYPE_STRING,		// Name of button
106
									G_TYPE_STRING,		// Number of corr. events
107
									G_TYPE_STRING,		// Type of input device
108
									G_TYPE_STRING);		// Button selected for event
109
	
110
	gtk_widget_show_all (inputgpwin);
111
	
112
	return;
113
	}
114
	
115
	// This function will be called from the Properties button in 
116
	// inputconfig if GamePad is the selected device
117
void GTKGUI_DoGPConfig (GTK_INPUT_DEVICE *in_device) {
118
	// Lets start off by trying to list the button config in text:
119
	int bl, dl, bcl;
120
	ButtConfig	*onebutton;
121
		
122
	for (bl = 0; bl < 10; bl++) {
123
		FCEU_printf ("Gamepad config: Button Name = %s :\n", GPBUTTON_NAMES[bl]);
124
		for (dl = 0; dl < 4; dl++) {
125
			onebutton = &GamePadConfig[dl][bl];
126
			FCEU_printf ("\tButtType:\t[ ");		// Duuhh, these are ButtConfig ptr's, not ints
127
			for (bcl = 0; bcl < MAXBUTTCONFIG; bcl++) {
128
				FCEU_printf ("%i\t",onebutton->ButtType[bcl]);
129
				}
130
			FCEU_printf (" ]\n");
131
			FCEU_printf ("\tDeviceNum:\t[ ");
132
			for (bcl = 0; bcl < MAXBUTTCONFIG; bcl++) {
133
				FCEU_printf ("%i\t",onebutton->DeviceNum[bcl]);
134
				}
135
			FCEU_printf (" ]\n");
136
			FCEU_printf ("\tButtonNum:\t[ ");
137
			for (bcl = 0; bcl < MAXBUTTCONFIG; bcl++) {
138
				FCEU_printf ("%i\t",onebutton->ButtonNum[bcl]);
139
				}
140
			FCEU_printf (" ]\n");
141
			FCEU_printf ("\tNumC:   \t\t[ %i ]\n\n", onebutton->NumC);
142
			}
143
		FCEU_printf ("\n");
144
		}
145
	GTKGUI_GPConfig_Init();
146
	return;
147
	}
148
149
/*		From input.h (I have no short term memory)
150
151
#define MAXBUTTCONFIG   4
152
153
typedef struct {
154
        uint8  ButtType[MAXBUTTCONFIG];
155
        uint8  DeviceNum[MAXBUTTCONFIG];
156
        uint16 ButtonNum[MAXBUTTCONFIG];
157
        uint32 NumC;
158
		} ButtConfig;
159
160
	
161
	*/
(-)fceu/src/drivers/pc/gtk/inputconfig_gp.h (+13 lines)
Line 0 Link Here
1
#ifndef __GTKGUI_INPUTCONFIG_GP_H_
2
#define __GTKGUI_INPUTCONFIG_GP_H_
3
4
#include <gtk/gtk.h>
5
6
#include "inputconfig.h"
7
8
/*  PROTOTYPES	*/
9
10
void GTKGUI_DoGPConfig (GTK_INPUT_DEVICE *in_device);
11
void GTKGUI_GPConfig_Init ( void );
12
13
#endif

Return to bug 44446