GTK: added GUI for --inputcfg; only works with gamepad 1 currently

This commit is contained in:
punkrockguy318 2010-02-19 00:40:16 +00:00
parent 160faa8837
commit 82c55b16e4
3 changed files with 65 additions and 25 deletions

View File

@ -10,6 +10,7 @@
#include "sdl.h"
#include "gui.h"
#include "dface.h"
#include "input.h"
#ifdef _S9XLUA_H
#include "../../fceulua.h"
@ -17,28 +18,62 @@
extern Config *g_config;
// test rendering
//SDL_Surface* screen = NULL;
//SDL_Surface* hello = NULL;
GtkWidget* MainWindow = NULL;
// we're not using this loop right now since integrated sdl is broken
gint mainLoop(gpointer data)
int configGamepadButton(GtkButton* button, gpointer p)
{
// test render
/*
SDL_UpdateRect(screen, 0, 0, xres, yres);
int x = GPOINTER_TO_INT(p);
int padNo = 0;
char buf[256];
std::string prefix;
ButtonConfigBegin();
SDL_BlitSurface (hello, NULL, screen, NULL);
snprintf(buf, 256, "SDL.Input.GamePad.%d", padNo);
prefix = buf;
ConfigButton("Press key twice to bind...", &GamePadConfig[padNo][x]);
SDL_Flip( screen );
*/
DoFun(0);
g_config->setOption(prefix + GamePadNames[x], GamePadConfig[padNo][x].ButtonNum[0]);
return TRUE;
if(GamePadConfig[padNo][x].ButtType[0] == BUTTC_KEYBOARD)
{
g_config->setOption(prefix + "DeviceType", "Keyboard");
} else if(GamePadConfig[padNo][x].ButtType[0] == BUTTC_JOYSTICK) {
g_config->setOption(prefix + "DeviceType", "Joystick");
} else {
g_config->setOption(prefix + "DeviceType", "Unknown");
}
g_config->setOption(prefix + "DeviceNum", GamePadConfig[padNo][0].DeviceNum[0]);
ButtonConfigEnd();
return 0;
}
// TODO: Implement something for gamepads 1 - 4
// shouldnt be hard but im lazy right now
void openGamepadConfig()
{
GtkWidget* win;
GtkWidget* vbox;
GtkWidget* buttons[10];
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win), "Gamepad 1 Config");
gtk_widget_set_size_request(win, 250, 600);
vbox = gtk_vbox_new(TRUE, 2);
for(int i=0; i<10; i++)
{
buttons[i] = gtk_button_new_with_label(GamePadNames[i]);
gtk_box_pack_start(GTK_BOX(vbox), buttons[i], TRUE, TRUE, 5);
gtk_signal_connect(GTK_OBJECT(buttons[i]), "clicked", G_CALLBACK(configGamepadButton), GINT_TO_POINTER(i));
}
gtk_container_add(GTK_CONTAINER(win), vbox);
gtk_widget_show_all(win);
return;
}
void quit ()
@ -263,6 +298,7 @@ static GtkItemFactoryEntry menu_items[] = {
{ "/Emulator/_Pause", NULL, emuPause, 0, "<Item>"},
{ "/Emulator/R_esume", NULL, emuResume, 0, "<Item>"},
{ "/Options/_Preferences", "<CTRL>P" , openPrefs, 0, "<StockItem>", GTK_STOCK_PREFERENCES },
{ "/Options/_Gamepad Config", NULL , openGamepadConfig, 0, "<StockItem>", GTK_STOCK_PREFERENCES },
{ "/Options/tear", NULL, NULL, 0, "<Tearoff>" },
{ "/Options/_Fullscreen", NULL, enableFullscreen, 0, "<Item>" },
// { "/Options/sep", NULL, NULL, 0, "<Separator>" },
@ -395,3 +431,4 @@ int InitGTKSubsystem(int argc, char** argv)
return 0;
}

View File

@ -745,7 +745,7 @@ static int bcpv,bcpj;
* subsystems into a well-known state. Button configuration really
* needs to be cleaned up after the new config system is in place.
*/
static int
int
ButtonConfigBegin()
{
SDL_Surface *screen;
@ -781,7 +781,7 @@ ButtonConfigBegin()
* subsystems to their previous state. Button configuration really
* needs to be cleaned up after the new config system is in place.
*/
static void
void
ButtonConfigEnd()
{
extern FCEUGI *GameInfo;
@ -829,7 +829,7 @@ DTestButton(ButtConfig *bc)
#define MKZ() {{0},{0},{0},0}
#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()}
static ButtConfig GamePadConfig[4][10]={
ButtConfig GamePadConfig[4][10]={
/* Gamepad 1 */
{ MK(KP3), MK(KP2), MK(TAB), MK(ENTER),
MK(W), MK(Z), MK(A), MK(S), MKZ(), MKZ() },
@ -1321,7 +1321,7 @@ DWaitButton(const uint8 *text,
* used as input for the specified button, thus allowing up to four
* possible settings for each input button.
*/
static void
void
ConfigButton(char *text,
ButtConfig *bc)
{
@ -1713,7 +1713,6 @@ UpdateInput(Config *config)
fkbmap[j].NumC = 1;
}
}
// Definitions from main.h:
// GamePad defaults
const char *GamePadNames[GAMEPAD_NUM_BUTTONS] =
@ -1807,3 +1806,4 @@ const int DefaultFamilyKeyBoard[FAMILYKEYBOARD_NUM_BUTTONS] =
SDLK_n, SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_RALT,
SDLK_RSHIFT, SDLK_LALT, SDLK_SPACE, SDLK_DELETE, SDLK_END, SDLK_PAGEDOWN,
SDLK_UP, SDLK_LEFT, SDLK_RIGHT, SDLK_DOWN };

View File

@ -16,6 +16,9 @@ extern CFGSTRUCT InputConfig[];
extern ARGPSTRUCT InputArgs[];
void ParseGIInput(FCEUGI *GI);
void setHotKeys();
int ButtonConfigBegin();
void ButtonConfigEnd();
void ConfigButton(char *text, ButtConfig *bc);
#define BUTTC_KEYBOARD 0x00
#define BUTTC_JOYSTICK 0x01
@ -28,12 +31,10 @@ void setHotKeys();
void InitInputInterface(void);
void InputUserActiveFix(void);
#ifdef EXTGUI
extern ButtConfig GamePadConfig[4][10];
extern ButtConfig powerpadsc[2][12];
extern ButtConfig QuizKingButtons[6];
extern ButtConfig FTrainerButtons[12];
#endif
//extern ButtConfig powerpadsc[2][12];
//extern ButtConfig QuizKingButtons[6];
//extern ButtConfig FTrainerButtons[12];
void IncreaseEmulationSpeed(void);
void DecreaseEmulationSpeed(void);
@ -45,4 +46,6 @@ void FCEUD_UpdateInput(void);
void UpdateInput(Config *config);
void InputCfg(const std::string &);
#endif