From 0f6338045ae848145347af60da67b5493b08c42c Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 12:43:16 -0500 Subject: [PATCH 1/8] Added Windows compiled files to .gitignore. Added "WIN32" preprocessor definition to the default VS2010 project. Replaced getHomePath() with the one mentioned in the pull request comments. --- .gitignore | 8 +++++- .../EmulationStation_vs2010/lib_paths.props | 6 ++-- src/platform.cpp | 28 +++++++++++++++---- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4d087d107..eda1679dc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,17 @@ *.la *.a +# And on Windows +*.dll +*.pdb +*.exe.manifest + # Dependency makefiles *.d #Compiled executable emulationstation +emulationstation.exe #build directory EmulationStation_vs2010 @@ -23,4 +29,4 @@ build Debug Release MinSizeRel -RelWithDebInfo \ No newline at end of file +RelWithDebInfo diff --git a/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props b/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props index 4b9b5bf1d..60ede5e74 100644 --- a/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props +++ b/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props @@ -3,12 +3,12 @@ - $(IncludePath) - $(LibraryPath) + $(IncludePath) + $(LibraryPath) - _DESKTOP_;%(PreprocessorDefinitions) + _DESKTOP_;WIN32;%(PreprocessorDefinitions) SDLmain.lib;SDL.lib;FreeImage.lib;freetype.lib;opengl32.lib;%(AdditionalDependencies) diff --git a/src/platform.cpp b/src/platform.cpp index bf88d70b2..bb4c5bb14 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -3,10 +3,26 @@ std::string getHomePath() { - //this gives you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows - const char* home = getenv("HOME"); - if(home == NULL) - return ""; - else - return home; + std::string homePath; + //this should give you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows + const char * envHome = getenv("HOME"); + if(envHome != nullptr) { + homePath = envHome; + } +#ifdef WIN32 + //but does not seem to work for Windwos XP or Vista, so try something else + if (homePath.empty()) { + const char * envDir = getenv("HOMEDRIVE"); + const char * envPath = getenv("HOMEPATH"); + if (envDir != nullptr && envPath != nullptr) { + homePath = envDir; + homePath += envPath; + } + } +#else + if (homePath.empty()) { + homePath = "~"; + } +#endif + return homePath; } From ec48c5d3a4beff8e74cc5dd155c04802906df9fd Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 13:27:19 -0500 Subject: [PATCH 2/8] Fixed a crash with empty path names in theme box definitions. --- src/components/GuiTheme.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/GuiTheme.cpp b/src/components/GuiTheme.cpp index 6bc27a07a..476780acf 100644 --- a/src/components/GuiTheme.cpp +++ b/src/components/GuiTheme.cpp @@ -332,6 +332,9 @@ Gui* GuiTheme::createElement(pugi::xml_node data, Gui* parent) //expands a file path (./ becomes the directory of this theme file, ~/ becomes $HOME/) std::string GuiTheme::expandPath(std::string path) { + if(path.length() == 0) + return ""; + if(path[0] == '~') path = getHomePath() + path.substr(1, path.length() - 1); else if(path[0] == '.') From cd76e2a6542526cf14db8612bcd853918bca2f99 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 14:39:40 -0500 Subject: [PATCH 3/8] Added ability to skip all inputs beyond menu by pressing Accept. --- src/components/GuiInputConfig.cpp | 29 +++++++++++++++++++++++------ src/components/GuiInputConfig.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/components/GuiInputConfig.cpp b/src/components/GuiInputConfig.cpp index d315c6489..bb683711f 100644 --- a/src/components/GuiInputConfig.cpp +++ b/src/components/GuiInputConfig.cpp @@ -9,7 +9,7 @@ static int inputCount = 10; static std::string inputName[10] = { "Up", "Down", "Left", "Right", "A", "B", "Menu", "Select", "PageUp", "PageDown" }; static std::string inputDispName[10] = { "Up", "Down", "Left", "Right", "Accept", "Back", "Menu", "Jump to Letter", "Page Up", "Page Down" }; -GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target) : Gui(window), mTargetConfig(target) +GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target) : Gui(window), mTargetConfig(target), mCanSkip(false) { mCurInputId = 0; LOG(LogInfo) << "Configuring device " << target->getDeviceId(); @@ -40,6 +40,12 @@ void GuiInputConfig::input(InputConfig* config, Input input) delete this; } }else{ + if(mCanSkip && config->isMappedTo("a", input)) + { + mCurInputId++; + return; + } + if(config->getMappedTo(input).size() > 0) { mErrorMsg = "Already mapped!"; @@ -53,10 +59,10 @@ void GuiInputConfig::input(InputConfig* config, Input input) mCurInputId++; mErrorMsg = ""; - //if the controller doesn't have enough buttons for Page Up/Page Down, skip to done - if(mWindow->getInputManager()->getButtonCountByDevice(config->getDeviceId()) <= 4 && mCurInputId >= 8) + //for buttons with not enough buttons, press A to skip + if(mCurInputId >= 7) { - mCurInputId = inputCount; + mCanSkip = true; } } } @@ -78,10 +84,21 @@ void GuiInputConfig::render() if(mCurInputId >= inputCount) { - Renderer::drawCenteredText("Basic config done!", 0, (int)(Renderer::getScreenHeight() * 0.6), 0x00CC00FF, font); - Renderer::drawCenteredText("Press any button to continue.", 0, (int)(Renderer::getScreenHeight() * 0.6) + font->getHeight() + 4, 0x000000FF, font); + Renderer::drawCenteredText("Basic config done!", 0, (int)(Renderer::getScreenHeight() * 0.4), 0x00CC00FF, font); + Renderer::drawCenteredText("Press any button to continue.", 0, (int)(Renderer::getScreenHeight() * 0.4) + font->getHeight() + 4, 0x000000FF, font); }else{ Renderer::drawText(inputDispName[mCurInputId], 10, y, 0x000000FF, font); + if(mCanSkip) + { + int textWidth = 0; + font->sizeText(inputDispName[mCurInputId], &textWidth, NULL); + textWidth += 14; + + if(Renderer::getScreenWidth() / 2.5f > textWidth) + textWidth = (int)(Renderer::getScreenWidth() / 2.5f); + + Renderer::drawText("press A to skip", textWidth, y, 0x0000AAFF, font); + } } if(!mErrorMsg.empty()) diff --git a/src/components/GuiInputConfig.h b/src/components/GuiInputConfig.h index 02e023dc0..1f4cadcaa 100644 --- a/src/components/GuiInputConfig.h +++ b/src/components/GuiInputConfig.h @@ -17,6 +17,7 @@ private: std::string mErrorMsg; InputConfig* mTargetConfig; int mCurInputId; + bool mCanSkip; }; #endif From 75d0226aa562e7461eef3890b4afaf7169f1018c Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 14:45:30 -0500 Subject: [PATCH 4/8] The old Makefiles contain the proper Renderer_init_X.cpp now. --- Makefile | 1 + Makefile.common | 2 ++ Makefile.x86 | 1 + 3 files changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f64e41ea6..ba8801a38 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ CPPFLAGS=-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/usr/include/freetype2 -I/usr/include/SDL -D_RPI_ LIBS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer +ADDITIONAL_SRC_SOURCES=Renderer_init_rpi.cpp include Makefile.common diff --git a/Makefile.common b/Makefile.common index 15ec7a98c..d5cac48d7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,6 +3,8 @@ CXXFLAGS=-Wall -g -O2 LDFLAGS= SRC_SOURCES=platform.cpp AudioManager.cpp Window.cpp InputConfig.cpp Log.cpp FolderData.cpp Font.cpp GameData.cpp Gui.cpp InputManager.cpp main.cpp MathExp.cpp Renderer_draw_gl.cpp Renderer_init.cpp Sound.cpp SystemData.cpp XMLReader.cpp components/GuiAnimation.cpp components/GuiBox.cpp components/GuiFastSelect.cpp components/GuiGameList.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiInputConfig.cpp components/GuiDetectDevice.cpp pugiXML/pugixml.cpp +SRC_SOURCES+=$(ADDITIONAL_SRC_SOURCES) + SOURCES=$(addprefix src/,$(SRC_SOURCES)) OBJECTS=$(SOURCES:.cpp=.o) DEPS=$(SOURCES:.cpp=.d) diff --git a/Makefile.x86 b/Makefile.x86 index 1217a1f00..183a4a18c 100644 --- a/Makefile.x86 +++ b/Makefile.x86 @@ -1,4 +1,5 @@ CPPFLAGS=-I/usr/include/freetype2 -I/usr/include/SDL -D_DESKTOP_ LIBS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer +ADDITIONAL_SRC_SOURCES=Renderer_init_sdlgl.cpp include Makefile.common From c5e91da6294297b0f32125e9e776aa54ef17dbe0 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 19:13:49 -0500 Subject: [PATCH 5/8] Fixed Raspberry Pi Makefile. Fixed a reorder warning in InputManager.cpp. --- Makefile | 5 ++++- src/InputManager.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ba8801a38..25ebc45b6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ -CPPFLAGS=-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/usr/include/freetype2 -I/usr/include/SDL -D_RPI_ +CPPFLAGS=-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/usr/include/freetype2 -I/usr/include/SDL -std=c++0x +CPPFLAGS+=-DUSE_OPENGL_ES -D_RPI_ LIBS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer + ADDITIONAL_SRC_SOURCES=Renderer_init_rpi.cpp +FT_FREETYPE_H_PATH=/usr/include/freetype include Makefile.common diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 20e8a17e1..25b0af40a 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -9,8 +9,8 @@ namespace fs = boost::filesystem; InputManager::InputManager(Window* window) : mWindow(window), - mJoysticks(NULL), mInputConfigs(NULL), mKeyboardInputConfig(NULL), mPrevAxisValues(NULL), - mNumJoysticks(0), mNumPlayers(0) + mNumJoysticks(0), mNumPlayers(0), mJoysticks(NULL), + mInputConfigs(NULL), mKeyboardInputConfig(NULL), mPrevAxisValues(NULL) { } From d89a1020a27d2a917ad39ba9f3737fc526bd6670 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 19:17:35 -0500 Subject: [PATCH 6/8] Probably fix the Makefile.x86 for Linux desktop. --- Makefile | 1 - Makefile.x86 | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 25ebc45b6..1d8b0bd88 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,5 @@ CPPFLAGS+=-DUSE_OPENGL_ES -D_RPI_ LIBS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer ADDITIONAL_SRC_SOURCES=Renderer_init_rpi.cpp -FT_FREETYPE_H_PATH=/usr/include/freetype include Makefile.common diff --git a/Makefile.x86 b/Makefile.x86 index 183a4a18c..6283d416d 100644 --- a/Makefile.x86 +++ b/Makefile.x86 @@ -1,4 +1,5 @@ -CPPFLAGS=-I/usr/include/freetype2 -I/usr/include/SDL -D_DESKTOP_ +CPPFLAGS=-I/usr/include/freetype2 -I/usr/include/SDL +CPPFLAGS+=-D_DESKTOP -DUSE_OPENGL_DESKTOP LIBS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer ADDITIONAL_SRC_SOURCES=Renderer_init_sdlgl.cpp From f3229f111c5786505c46746f4166594779967cae Mon Sep 17 00:00:00 2001 From: Aloshi Date: Mon, 20 May 2013 10:57:04 -0500 Subject: [PATCH 7/8] Fix for audio not reinitializing on restart. --- src/AudioManager.cpp | 13 +++++++++++-- src/AudioManager.h | 3 +++ src/Window.cpp | 2 ++ src/main.cpp | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/AudioManager.cpp b/src/AudioManager.cpp index d1cb02c17..05f0a93b9 100644 --- a/src/AudioManager.cpp +++ b/src/AudioManager.cpp @@ -50,6 +50,15 @@ void AudioManager::mixAudio(void *unused, Uint8 *stream, int len) } AudioManager::AudioManager() +{ +} + +AudioManager::~AudioManager() +{ + deinit(); +} + +void AudioManager::init() { //Set up format and callback. Play 16-bit stereo audio at 44.1Khz sAudioFormat.freq = 44100; @@ -65,7 +74,7 @@ AudioManager::AudioManager() } } -AudioManager::~AudioManager() +void AudioManager::deinit() { SDL_PauseAudio(1); SDL_CloseAudio(); @@ -97,4 +106,4 @@ void AudioManager::play() { //unpause audio, the mixer will figure out if samples need to be played... SDL_PauseAudio(0); -} \ No newline at end of file +} diff --git a/src/AudioManager.h b/src/AudioManager.h index b20a965b2..af3b0dbf1 100644 --- a/src/AudioManager.h +++ b/src/AudioManager.h @@ -26,6 +26,9 @@ public: static void play(); virtual ~AudioManager(); + + static void init(); + static void deinit(); }; #endif diff --git a/src/Window.cpp b/src/Window.cpp index 119ac9c5f..26e36a983 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -53,6 +53,7 @@ void Window::init() { mInputManager->init(); Renderer::init(0, 0); + AudioManager::init(); for(unsigned int i = 0; i < mGuiStack.size(); i++) { @@ -68,6 +69,7 @@ void Window::deinit() } mInputManager->deinit(); + AudioManager::deinit(); Renderer::deinit(); } diff --git a/src/main.cpp b/src/main.cpp index d0f347903..90d7617fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,6 @@ #include "SystemData.h" #include #include "components/GuiDetectDevice.h" -#include "AudioManager.h" #include "platform.h" #include "Log.h" #include "Window.h" @@ -121,6 +120,7 @@ int main(int argc, char* argv[]) Window window; //don't call Window.init() because we manually pass the resolution to Renderer::init window.getInputManager()->init(); + AudioManager::init(); //try loading the system config file if(!fs::exists(SystemData::getConfigPath())) //if it doesn't exist, create the example and quit From 12b4b121033d283ceffa1bf1b61f2fe1964e18e5 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 22 May 2013 11:30:14 -0500 Subject: [PATCH 8/8] Added comment to src/ImageIO.h --- src/ImageIO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageIO.h b/src/ImageIO.h index a965a5fba..a9805fa18 100644 --- a/src/ImageIO.h +++ b/src/ImageIO.h @@ -3,7 +3,7 @@ #include #include - +//This is used for loading files from Resource.h. Just the ES logo for now (for the icon). class ImageIO { public: