sdl: fixed formatting issues; overall code cleanup

This commit is contained in:
punkrockguy318 2012-03-06 08:43:42 +00:00
parent 750b7f75e0
commit 646847ddc8
4 changed files with 276 additions and 330 deletions

View File

@ -321,9 +321,9 @@ InitConfig()
prefix = "SDL.Input.FamicomPad2."; prefix = "SDL.Input.FamicomPad2.";
config->addOption("rp2mic", prefix + "EnableMic", 0); config->addOption("rp2mic", prefix + "EnableMic", 0);
// TODO: use a better data structure to store the hotkeys or something
// this is really hacky // improve this code overall in the future to make it
// TODO clean this up; clean config.h as well // easier to maintain
const int Hotkeys[HK_MAX] = { const int Hotkeys[HK_MAX] = {
SDLK_F1, // cheat menu SDLK_F1, // cheat menu
SDLK_F2, // bind state SDLK_F2, // bind state
@ -358,37 +358,6 @@ InitConfig()
prefix = "SDL.Hotkeys."; prefix = "SDL.Hotkeys.";
for(int i=0; i < HK_MAX; i++) for(int i=0; i < HK_MAX; i++)
config->addOption(prefix + HotkeyStrings[i], Hotkeys[i]); config->addOption(prefix + HotkeyStrings[i], Hotkeys[i]);
/*
config->addOption(prefix + "Pause", SDLK_PAUSE);
config->addOption(prefix + "DecreaseSpeed", SDLK_MINUS);
config->addOption(prefix + "IncreaseSpeed", SDLK_EQUALS);
config->addOption(prefix + "FrameAdvance", SDLK_BACKSLASH);
config->addOption(prefix + "FastForward", SDLK_TAB);
config->addOption(prefix + "InputDisplay", SDLK_i);
config->addOption(prefix + "MovieToggleReadWrite", SDLK_q);
#ifdef CREATE_AVI
config->addOption(prefix + "MuteCapture", SDLK_DELETE);
#endif
config->addOption(prefix + "Quit", SDLK_ESCAPE);
//config->addOption(prefix + "Power", 0);
config->addOption(prefix + "SelectState0", SDLK_0);
config->addOption(prefix + "SelectState1", SDLK_1);
config->addOption(prefix + "SelectState2", SDLK_2);
config->addOption(prefix + "SelectState3", SDLK_3);
config->addOption(prefix + "SelectState4", SDLK_4);
config->addOption(prefix + "SelectState5", SDLK_5);
config->addOption(prefix + "SelectState6", SDLK_6);
config->addOption(prefix + "SelectState7", SDLK_7);
config->addOption(prefix + "SelectState8", SDLK_8);
config->addOption(prefix + "SelectState9", SDLK_9);
*/
// All mouse devices // All mouse devices
config->addOption("SDL.OekaKids.0.DeviceType", "Mouse"); config->addOption("SDL.OekaKids.0.DeviceType", "Mouse");
config->addOption("SDL.OekaKids.0.DeviceNum", 0); config->addOption("SDL.OekaKids.0.DeviceNum", 0);
@ -433,10 +402,6 @@ UpdateEMUCore(Config *config)
config->getOption("SDL.DisableSpriteLimit", &flag); config->getOption("SDL.DisableSpriteLimit", &flag);
FCEUI_DisableSpriteLimitation(flag ? 1 : 0); FCEUI_DisableSpriteLimitation(flag ? 1 : 0);
//Not used anymore.
//config->getOption("SDL.SnapName", &flag);
//FCEUI_SetSnapName(flag ? true : false);
config->getOption("SDL.ScanLineStart", &start); config->getOption("SDL.ScanLineStart", &start);
config->getOption("SDL.ScanLineEnd", &end); config->getOption("SDL.ScanLineEnd", &end);
@ -449,3 +414,4 @@ UpdateEMUCore(Config *config)
FCEUI_SetRenderedLines(start + 8, end - 8, start, end); FCEUI_SetRenderedLines(start + 8, end - 8, start, end);
} }

View File

@ -7,10 +7,8 @@ Config *InitConfig(void);
void UpdateEMUCore(Config *); void UpdateEMUCore(Config *);
int LoadCPalette(const std::string &file); int LoadCPalette(const std::string &file);
// hotkey definitions // hotkey definitions
// TODO: encapsulate this in an improved data structure
enum HOTKEY { HK_CHEAT_MENU, HK_BIND_STATE, HK_LOAD_LUA, HK_TOGGLE_BG, enum HOTKEY { HK_CHEAT_MENU, HK_BIND_STATE, HK_LOAD_LUA, HK_TOGGLE_BG,
HK_SAVE_STATE, HK_FDS_SELECT, HK_LOAD_STATE, HK_FDS_EJECT , HK_SAVE_STATE, HK_FDS_SELECT, HK_LOAD_STATE, HK_FDS_EJECT ,
HK_VS_INSERT_COIN, HK_VS_TOGGLE_DIPSWITCH, HK_VS_INSERT_COIN, HK_VS_TOGGLE_DIPSWITCH,
@ -53,5 +51,5 @@ static const char* HotkeyStrings[HK_MAX] = {
"SelectState0", "SelectState1", "SelectState2", "SelectState3", "SelectState0", "SelectState1", "SelectState2", "SelectState3",
"SelectState4", "SelectState5", "SelectState6", "SelectState7", "SelectState4", "SelectState5", "SelectState6", "SelectState7",
"SelectState8", "SelectState9", "SelectStateNext", "SelectStatePrev" }; "SelectState8", "SelectState9", "SelectStateNext", "SelectStatePrev" };
#endif #endif

View File

@ -17,7 +17,6 @@ uint32 GetWriteSound(void);
void SilenceSound(int s); /* DOS and SDL */ void SilenceSound(int s); /* DOS and SDL */
int InitJoysticks(void); int InitJoysticks(void);
int KillJoysticks(void); int KillJoysticks(void);
uint32 *GetJSOr(void); uint32 *GetJSOr(void);
@ -37,4 +36,3 @@ void DoFun(void);
int FCEUD_NetworkConnect(void); int FCEUD_NetworkConnect(void);

View File

@ -1,16 +1,17 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#ifdef _GTK3 #ifdef _GTK3
#include <gdk/gdkkeysyms-compat.h> #include <gdk/gdkkeysyms-compat.h>
#endif #endif
#include <gdk/gdkx.h>
#include <SDL/SDL.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <SDL/SDL.h>
#include "../../types.h" #include "../../types.h"
#include "../../fceu.h" #include "../../fceu.h"
#include "../../driver.h" #include "../../driver.h"
@ -18,9 +19,8 @@
#include "../../movie.h" #include "../../movie.h"
#include "../../palette.h" #include "../../palette.h"
#include "../../fds.h" #include "../../fds.h"
#include "../common/configSys.h" #include "../common/configSys.h"
#include "sdl.h" #include "sdl.h"
#include "gui.h" #include "gui.h"
#include "dface.h" #include "dface.h"
@ -113,7 +113,6 @@ void toggleLowPass(GtkWidget* w, gpointer p)
FCEUI_SetLowPass(0); FCEUI_SetLowPass(0);
} }
g_config->save(); g_config->save();
} }
// Wrapper for pushing GTK options into the config file // Wrapper for pushing GTK options into the config file
@ -235,15 +234,12 @@ void openPaletteConfig()
g_signal_connect(paletteButton, "clicked", G_CALLBACK(loadPalette), paletteEntry); g_signal_connect(paletteButton, "clicked", G_CALLBACK(loadPalette), paletteEntry);
g_signal_connect(clearButton, "clicked", G_CALLBACK(clearPalette), paletteEntry); g_signal_connect(clearButton, "clicked", G_CALLBACK(clearPalette), paletteEntry);
// sync with config // sync with config
std::string fn; std::string fn;
g_config->getOption("SDL.Palette", &fn); g_config->getOption("SDL.Palette", &fn);
gtk_entry_set_text(GTK_ENTRY(paletteEntry), fn.c_str()); gtk_entry_set_text(GTK_ENTRY(paletteEntry), fn.c_str());
// ntsc color check // ntsc color check
ntscColorChk = gtk_check_button_new_with_label("Use NTSC palette"); ntscColorChk = gtk_check_button_new_with_label("Use NTSC palette");
g_signal_connect(ntscColorChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.NTSCpalette"); g_signal_connect(ntscColorChk, "clicked", G_CALLBACK(toggleOption), (gpointer)"SDL.NTSCpalette");
@ -256,7 +252,6 @@ void openPaletteConfig()
else else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ntscColorChk), 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ntscColorChk), 0);
// color / tint / hue sliders // color / tint / hue sliders
slidersFrame = gtk_frame_new("NTSC palette controls"); slidersFrame = gtk_frame_new("NTSC palette controls");
slidersVbox = gtk_vbox_new(FALSE, 2); slidersVbox = gtk_vbox_new(FALSE, 2);
@ -360,7 +355,6 @@ void openNetworkConfig()
g_signal_connect(userEntry, "changed", G_CALLBACK(setUsername), NULL); g_signal_connect(userEntry, "changed", G_CALLBACK(setUsername), NULL);
frame = gtk_frame_new("Network options"); frame = gtk_frame_new("Network options");
vbox = gtk_vbox_new(FALSE, 5); vbox = gtk_vbox_new(FALSE, 5);
ipBox = gtk_hbox_new(FALSE, 5); ipBox = gtk_hbox_new(FALSE, 5);
@ -971,7 +965,6 @@ int mixerChanged(GtkWidget* w, gpointer p)
return 0; return 0;
} }
void openSoundConfig() void openSoundConfig()
{ {
GtkWidget* win; GtkWidget* win;
@ -993,7 +986,6 @@ void openSoundConfig()
GtkWidget* mixers[6]; GtkWidget* mixers[6];
GtkWidget* mixerFrames[6]; GtkWidget* mixerFrames[6];
win = gtk_dialog_new_with_buttons("Sound Preferences", win = gtk_dialog_new_with_buttons("Sound Preferences",
GTK_WINDOW(MainWindow), GTK_WINDOW(MainWindow),
(GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT), (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),
@ -1003,8 +995,6 @@ void openSoundConfig()
gtk_window_set_icon_name(GTK_WINDOW(win), "audio-x-generic"); gtk_window_set_icon_name(GTK_WINDOW(win), "audio-x-generic");
main_hbox = gtk_hbox_new(FALSE, 15); main_hbox = gtk_hbox_new(FALSE, 15);
vbox = gtk_vbox_new(False, 5); vbox = gtk_vbox_new(False, 5);
//gtk_widget_set_size_request(win, 300, 200);
// sound enable check // sound enable check
soundChk = gtk_check_button_new_with_label("Enable sound"); soundChk = gtk_check_button_new_with_label("Enable sound");
@ -1017,9 +1007,7 @@ void openSoundConfig()
else else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(soundChk), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(soundChk), FALSE);
g_signal_connect(soundChk, "clicked", g_signal_connect(soundChk, "clicked", G_CALLBACK(toggleSound), NULL);
G_CALLBACK(toggleSound), NULL);
// low pass filter check // low pass filter check
lowpassChk = gtk_check_button_new_with_label("Enable low pass filter"); lowpassChk = gtk_check_button_new_with_label("Enable low pass filter");
@ -1077,7 +1065,6 @@ void openSoundConfig()
g_signal_connect(rateCombo, "changed", G_CALLBACK(setRate), NULL); g_signal_connect(rateCombo, "changed", G_CALLBACK(setRate), NULL);
// sound rate widgets // sound rate widgets
rateLbl = gtk_label_new("Rate (Hz): "); rateLbl = gtk_label_new("Rate (Hz): ");
@ -1088,14 +1075,12 @@ void openSoundConfig()
bufferHscale = gtk_hscale_new_with_range(15, 200, 2); bufferHscale = gtk_hscale_new_with_range(15, 200, 2);
bufferLbl = gtk_label_new("Buffer size (in ms)"); bufferLbl = gtk_label_new("Buffer size (in ms)");
// sync widget with cfg // sync widget with cfg
g_config->getOption("SDL.Sound.BufSize", &cfgBuf); g_config->getOption("SDL.Sound.BufSize", &cfgBuf);
gtk_range_set_value(GTK_RANGE(bufferHscale), cfgBuf); gtk_range_set_value(GTK_RANGE(bufferHscale), cfgBuf);
g_signal_connect(bufferHscale, "button-release-event", G_CALLBACK(setBufSize), NULL); g_signal_connect(bufferHscale, "button-release-event", G_CALLBACK(setBufSize), NULL);
// mixer // mixer
mixerFrame = gtk_frame_new("Mixer:"); mixerFrame = gtk_frame_new("Mixer:");
mixerHbox = gtk_hbox_new(TRUE, 5); mixerHbox = gtk_hbox_new(TRUE, 5);
@ -1230,7 +1215,6 @@ void hardReset ()
} }
} }
void enableFullscreen () void enableFullscreen ()
{ {
if(isloaded) if(isloaded)