mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Added a logging system to ES.
You should no longer see non-error output with ES except for "cleanly shutting down". The new log file is located in ~/.emulationstation/es_log.txt. If you notice any performance degredation, please tell me!
This commit is contained in:
parent
cadc9a9ec6
commit
2efca58869
|
@ -2,7 +2,7 @@ CXX=g++
|
|||
CXXFLAGS=-Wall -g -O2
|
||||
LDFLAGS=
|
||||
|
||||
SRC_SOURCES=AudioManager.cpp FolderData.cpp Font.cpp GameData.cpp GuiComponent.cpp InputManager.cpp main.cpp MathExp.cpp Renderer.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/GuiInputConfig.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
|
||||
SRC_SOURCES=AudioManager.cpp Log.cpp FolderData.cpp Font.cpp GameData.cpp GuiComponent.cpp InputManager.cpp main.cpp MathExp.cpp Renderer.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/GuiInputConfig.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
|
||||
SOURCES=$(addprefix src/,$(SRC_SOURCES))
|
||||
OBJECTS=$(SOURCES:.cpp=.o)
|
||||
DEPS=$(SOURCES:.cpp=.d)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "AudioManager.h"
|
||||
|
||||
#include "Log.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_mixer.h"
|
||||
#include <iostream>
|
||||
|
@ -18,8 +19,7 @@ namespace AudioManager
|
|||
|
||||
if(result == -1)
|
||||
{
|
||||
std::cerr << "Error initializing AudioManager!\n";
|
||||
std::cerr << " " << Mix_GetError() << "\n";
|
||||
LOG(LogError) << "Error initializing AudioManager!\n " << Mix_GetError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,36 +47,7 @@ namespace AudioManager
|
|||
}
|
||||
}
|
||||
|
||||
std::cerr << "AudioManager Error - tried to unregister a sound that wasn't registered!\n";
|
||||
}
|
||||
|
||||
void test()
|
||||
{
|
||||
Mix_Chunk* sound = NULL;
|
||||
sound = Mix_LoadWAV("test.wav");
|
||||
|
||||
if(sound == NULL)
|
||||
{
|
||||
std::cerr << "Error loading test sound!\n";
|
||||
std::cerr << " " << Mix_GetError() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
int channel = -1;
|
||||
|
||||
//third argument is play count, -1 = infinite loop, 0 = once
|
||||
channel = Mix_PlayChannel(-1, sound, 0);
|
||||
|
||||
if(channel == -1)
|
||||
{
|
||||
std::cerr << "Error playing sound!\n";
|
||||
std::cerr << " " << Mix_GetError() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
while(Mix_Playing(channel) != 0);
|
||||
Mix_FreeChunk(sound);
|
||||
|
||||
LOG(LogError) << "AudioManager Error - tried to unregister a sound that wasn't registered!";
|
||||
}
|
||||
|
||||
void deinit()
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace AudioManager
|
|||
bool isInitialized();
|
||||
|
||||
void init();
|
||||
void test();
|
||||
void deinit();
|
||||
}
|
||||
|
||||
|
|
11
src/Font.cpp
11
src/Font.cpp
|
@ -4,6 +4,7 @@
|
|||
#include <vector>
|
||||
#include "Renderer.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "Log.h"
|
||||
|
||||
FT_Library Font::sLibrary;
|
||||
bool Font::libraryInitialized = false;
|
||||
|
@ -26,7 +27,7 @@ std::string Font::getDefaultPath()
|
|||
return fonts[i];
|
||||
}
|
||||
|
||||
std::cerr << "Error - could not find a font!\n";
|
||||
LOG(LogError) << "Error - could not find a font!";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ void Font::initLibrary()
|
|||
{
|
||||
if(FT_Init_FreeType(&sLibrary))
|
||||
{
|
||||
std::cerr << "Error initializing FreeType!\n";
|
||||
LOG(LogError) << "Error initializing FreeType!";
|
||||
}else{
|
||||
libraryInitialized = true;
|
||||
}
|
||||
|
@ -61,7 +62,7 @@ void Font::onInit()
|
|||
|
||||
if(FT_New_Face(sLibrary, mPath.c_str(), 0, &face))
|
||||
{
|
||||
std::cerr << "Error creating font face! (path: " << mPath.c_str() << "\n";
|
||||
LOG(LogError) << "Error creating font face! (path: " << mPath.c_str();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,7 +173,7 @@ void Font::buildAtlas()
|
|||
|
||||
if(y >= textureHeight)
|
||||
{
|
||||
std::cerr << "Error - font size exceeded texture size! If you were doing something reasonable, tell Aloshi to fix it!\n";
|
||||
LOG(LogError) << "Error - font size exceeded texture size! If you were doing something reasonable, tell Aloshi to fix it!";
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -222,7 +223,7 @@ void Font::drawText(std::string text, int startx, int starty, int color)
|
|||
{
|
||||
if(!textureID)
|
||||
{
|
||||
std::cerr << "Error - tried to draw with Font that has no texture loaded!\n";
|
||||
LOG(LogError) << "Error - tried to draw with Font that has no texture loaded!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "GuiComponent.h"
|
||||
#include "Renderer.h"
|
||||
#include <iostream>
|
||||
#include "Log.h"
|
||||
|
||||
std::vector<GuiComponent*> GuiComponent::sComponentVector;
|
||||
|
||||
|
@ -40,7 +41,7 @@ void GuiComponent::removeChild(GuiComponent* comp)
|
|||
}
|
||||
}
|
||||
|
||||
std::cerr << "Error - tried to remove GuiComponent child, but couldn't find it!\n";
|
||||
LOG(LogError) << "Error - tried to remove GuiComponent child, but couldn't find it!";
|
||||
}
|
||||
|
||||
void GuiComponent::clearChildren()
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
extern bool DEBUG; //defined in main.cpp
|
||||
#include "Log.h"
|
||||
|
||||
std::vector<GuiComponent*> InputManager::inputVector;
|
||||
SDL_Event* InputManager::lastEvent = NULL;
|
||||
|
@ -97,7 +96,7 @@ void InputManager::processEvent(SDL_Event* event)
|
|||
SDL_Event* quit = new SDL_Event();
|
||||
quit->type = SDL_QUIT;
|
||||
SDL_PushEvent(quit);
|
||||
std::cout << "Pushing quit event\n";
|
||||
LOG(LogInfo) << "Pushing quit event.";
|
||||
}
|
||||
}else{
|
||||
if(event->type == SDL_JOYBUTTONDOWN || event->type == SDL_JOYBUTTONUP) //joystick button events
|
||||
|
@ -150,10 +149,6 @@ void InputManager::processEvent(SDL_Event* event)
|
|||
}
|
||||
}
|
||||
|
||||
//for debugging hats
|
||||
//if(button != UNKNOWN)
|
||||
// std::cout << "hat event, button: " << button << ", keyDown: " << keyDown << "\n";
|
||||
|
||||
}else{
|
||||
if(event->type == SDL_JOYAXISMOTION)
|
||||
{
|
||||
|
@ -198,8 +193,7 @@ void InputManager::processEvent(SDL_Event* event)
|
|||
|
||||
void InputManager::loadConfig()
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << "Loading input config...\n";
|
||||
LOG(LogDebug) << "Loading input config...";
|
||||
|
||||
//clear any old config
|
||||
joystickButtonMap.clear();
|
||||
|
@ -257,7 +251,7 @@ void InputManager::loadConfig()
|
|||
{
|
||||
joystickName = token[1];
|
||||
}else{
|
||||
std::cerr << "Invalid input type - " << token[0] << "\n";
|
||||
LOG(LogWarning) << "Invalid input type - " << token[0];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -268,16 +262,14 @@ void InputManager::loadConfig()
|
|||
{
|
||||
if(!joystickName.empty())
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " attempting to open joystick of name \"" << joystickName << "\"\n";
|
||||
LOG(LogDebug) << " attempting to open joystick of name \"" << joystickName << "\"";
|
||||
|
||||
bool found = false;
|
||||
for(int i = 0; i < SDL_NumJoysticks(); i++)
|
||||
{
|
||||
if(strcmp(SDL_JoystickName(i), joystickName.c_str()) == 0)
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " found, opening joystick " << joystickName << "\n";
|
||||
LOG(LogDebug) << " found, opening joystick " << joystickName << " at " << i;
|
||||
|
||||
SDL_JoystickOpen(i);
|
||||
found = true;
|
||||
|
@ -285,18 +277,17 @@ void InputManager::loadConfig()
|
|||
}
|
||||
}
|
||||
|
||||
if(DEBUG && !found)
|
||||
std::cout << " could not find named joystick! You could try manually removing the joystick name entry in the input config file.\n";
|
||||
|
||||
if(!found)
|
||||
{
|
||||
LOG(LogWarning) << " could not find named joystick! You could try manually removing the joystick name entry in the input config file.";
|
||||
}
|
||||
}else{
|
||||
if(DEBUG)
|
||||
std::cout << " opening first joystick\n";
|
||||
LOG(LogDebug) << " opening first joystick";
|
||||
|
||||
SDL_JoystickOpen(0); //if we don't have a specific joystick in mind, take the first
|
||||
}
|
||||
}else{
|
||||
if(DEBUG)
|
||||
std::cout << " no joysticks detected by SDL_NumJoysticks(), input loaded but no joystick opened\n";
|
||||
LOG(LogDebug) << " no joysticks detected by SDL_NumJoysticks(), input loaded but no joystick opened";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
57
src/Log.cpp
Normal file
57
src/Log.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "Log.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
LogLevel Log::reportingLevel = LogInfo;
|
||||
FILE* Log::file = fopen(getLogPath().c_str(), "w");
|
||||
|
||||
LogLevel Log::getReportingLevel()
|
||||
{
|
||||
return reportingLevel;
|
||||
}
|
||||
|
||||
std::string Log::getLogPath()
|
||||
{
|
||||
std::string home = getenv("HOME");
|
||||
return home + "/.emulationstation/es_log.txt";
|
||||
}
|
||||
|
||||
void Log::setReportingLevel(LogLevel level)
|
||||
{
|
||||
reportingLevel = level;
|
||||
}
|
||||
|
||||
std::ostringstream& Log::get(LogLevel level)
|
||||
{
|
||||
os << "lvl" << level << ": \t";
|
||||
messageLevel = level;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
void Log::flush()
|
||||
{
|
||||
fflush(getOutput());
|
||||
}
|
||||
|
||||
void Log::close()
|
||||
{
|
||||
fclose(file);
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
FILE* Log::getOutput()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
os << std::endl;
|
||||
fprintf(getOutput(), "%s", os.str().c_str());
|
||||
|
||||
//if it's an error, also print to console
|
||||
if(messageLevel == LogError)
|
||||
fprintf(stderr, "%s", os.str().c_str());
|
||||
}
|
36
src/Log.h
Normal file
36
src/Log.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef _LOG_H_
|
||||
#define _LOG_H_
|
||||
|
||||
#define LOG(level) \
|
||||
if(level > Log::getReportingLevel()) ; \
|
||||
else Log().get(level)
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
enum LogLevel { LogError, LogWarning, LogInfo, LogDebug };
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
//Log();
|
||||
~Log();
|
||||
std::ostringstream& get(LogLevel level = LogInfo);
|
||||
|
||||
static LogLevel getReportingLevel();
|
||||
static void setReportingLevel(LogLevel level);
|
||||
|
||||
static std::string getLogPath();
|
||||
|
||||
static void flush();
|
||||
static void close();
|
||||
protected:
|
||||
std::ostringstream os;
|
||||
static FILE* file;
|
||||
private:
|
||||
static LogLevel reportingLevel;
|
||||
static FILE* getOutput();
|
||||
LogLevel messageLevel;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -4,6 +4,7 @@
|
|||
#include <iostream>
|
||||
#include "Font.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "Log.h"
|
||||
|
||||
namespace Renderer {
|
||||
bool loadedFonts = false;
|
||||
|
@ -80,14 +81,12 @@ namespace Renderer {
|
|||
if(loadedFonts)
|
||||
return;
|
||||
|
||||
std::cout << "loading fonts...";
|
||||
|
||||
std::string fontPath = Font::getDefaultPath();
|
||||
|
||||
//make sure our font exists
|
||||
if(!boost::filesystem::exists(fontPath))
|
||||
{
|
||||
std::cerr << "System font \"" << fontPath << "\" wasn't found! Well, you're kind of screwed. Sorry. Report this to Aloshi, please.\n";
|
||||
LOG(LogError) << "System font \"" << fontPath << "\" wasn't found! Well, you're kind of screwed. Sorry. Report this to Aloshi, please.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -99,7 +98,7 @@ namespace Renderer {
|
|||
|
||||
loadedFonts = true;
|
||||
|
||||
std::cout << "done\n";
|
||||
LOG(LogInfo) << "Loaded fonts successfully.";
|
||||
}
|
||||
|
||||
Font* getDefaultFont(FontSize size)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "Font.h"
|
||||
#include <SDL/SDL.h>
|
||||
#include "InputManager.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace Renderer
|
||||
{
|
||||
|
@ -28,18 +29,18 @@ namespace Renderer
|
|||
|
||||
bool createSurface() //unsigned int display_width, unsigned int display_height)
|
||||
{
|
||||
LOG(LogInfo) << "Starting SDL...";
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) != 0)
|
||||
{
|
||||
std::cerr << "Error initializing SDL!\n";
|
||||
std::cerr << SDL_GetError() << "\n";
|
||||
std::cerr << "Are you in the 'video', 'audio', and 'input' groups? Is X closed? Is your firmware up to date? Are you using at least the 192/64 memory split?\n";
|
||||
LOG(LogError) << "Error initializing SDL!\n " << SDL_GetError() << "\n" << "Are you in the 'video', 'audio', and 'input' groups? Is X closed? Is your firmware up to date? Are you using at least the 192/64 memory split?";
|
||||
return false;
|
||||
}
|
||||
|
||||
sdlScreen = SDL_SetVideoMode(1, 1, 0, SDL_SWSURFACE);
|
||||
if(sdlScreen == NULL)
|
||||
{
|
||||
std::cerr << "Error creating SDL window for input!\n";
|
||||
LOG(LogError) << "Error creating SDL window for input!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ namespace Renderer
|
|||
|
||||
|
||||
|
||||
std::cout << "Creating surface...";
|
||||
LOG(LogInfo) << "Creating surface...";
|
||||
|
||||
DISPMANX_ELEMENT_HANDLE_T dispman_element;
|
||||
DISPMANX_DISPLAY_HANDLE_T dispman_display;
|
||||
|
@ -61,21 +62,21 @@ namespace Renderer
|
|||
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if(display == EGL_NO_DISPLAY)
|
||||
{
|
||||
std::cerr << "Error getting display!\n";
|
||||
LOG(LogError) << "Error getting display!";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = eglInitialize(display, NULL, NULL);
|
||||
if(result == EGL_FALSE)
|
||||
{
|
||||
std::cerr << "Error initializing display!\n";
|
||||
LOG(LogError) << "Error initializing display!";
|
||||
return false;
|
||||
}
|
||||
|
||||
result = eglBindAPI(EGL_OPENGL_ES_API);
|
||||
if(result == EGL_FALSE)
|
||||
{
|
||||
std::cerr << "Error binding API!\n";
|
||||
LOG(LogError) << "Error binding API!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -95,7 +96,7 @@ namespace Renderer
|
|||
|
||||
if(result == EGL_FALSE)
|
||||
{
|
||||
std::cerr << "Error choosing config!\n";
|
||||
LOG(LogError) << "Error choosing config!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -103,9 +104,7 @@ namespace Renderer
|
|||
context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);
|
||||
if(context == EGL_NO_CONTEXT)
|
||||
{
|
||||
std::cout << "Error: " << eglGetError() << "\n";
|
||||
|
||||
std::cerr << "Error getting context!\n";
|
||||
LOG(LogError) << "Error getting context!\n " << eglGetError();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -118,12 +117,12 @@ namespace Renderer
|
|||
|
||||
if(success < 0)
|
||||
{
|
||||
std::cerr << "Error getting display size!\n";
|
||||
LOG(LogError) << "Error getting display size!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << display_width << "x" << display_height << "...";
|
||||
LOG(LogInfo) << "Resolution: " << display_width << "x" << display_height << "...";
|
||||
|
||||
|
||||
dst_rect.x = 0; dst_rect.y = 0;
|
||||
|
@ -147,19 +146,19 @@ namespace Renderer
|
|||
surface = eglCreateWindowSurface(display, config, &nativewindow, NULL);
|
||||
if(surface == EGL_NO_SURFACE)
|
||||
{
|
||||
std::cerr << "Error creating window surface!\n";
|
||||
LOG(LogError) << "Error creating window surface!";
|
||||
return false;
|
||||
}
|
||||
|
||||
result = eglMakeCurrent(display, surface, surface, context);
|
||||
if(result == EGL_FALSE)
|
||||
{
|
||||
std::cerr << "Error with eglMakeCurrent!\n";
|
||||
LOG(LogError) << "Error with eglMakeCurrent!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "success!\n";
|
||||
LOG(LogInfo) << "Created surface successfully!";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Font.h"
|
||||
#include <SDL/SDL.h>
|
||||
#include "InputManager.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace Renderer
|
||||
{
|
||||
|
@ -18,12 +19,11 @@ namespace Renderer
|
|||
|
||||
bool createSurface() //unsigned int display_width, unsigned int display_height)
|
||||
{
|
||||
std::cout << "Creating surface...";
|
||||
LOG(LogInfo) << "Creating surface...";
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) != 0)
|
||||
{
|
||||
std::cerr << "Error initializing SDL!\n";
|
||||
std::cerr << " " << SDL_GetError() << "\n";
|
||||
LOG(LogError) << "Error initializing SDL!\n " << SDL_GetError();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace Renderer
|
|||
|
||||
if(sdlScreen == NULL)
|
||||
{
|
||||
std::cout << "Error creating SDL video surface!\n";
|
||||
LOG(LogError) << "Error creating SDL video surface!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace Renderer
|
|||
display_width = sdlScreen->w;
|
||||
display_height = sdlScreen->h;
|
||||
|
||||
std::cout << "success!\n";
|
||||
LOG(LogInfo) << "Created surface successfully.";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Sound.h"
|
||||
#include <iostream>
|
||||
#include "AudioManager.h"
|
||||
#include "Log.h"
|
||||
|
||||
Sound::Sound(std::string path)
|
||||
{
|
||||
|
@ -40,8 +41,7 @@ void Sound::init()
|
|||
|
||||
if(mSound == NULL)
|
||||
{
|
||||
std::cerr << "Error loading sound \"" << mPath << "\"!\n";
|
||||
std::cerr << " " << Mix_GetError() << "\n";
|
||||
LOG(LogError) << "Error loading sound \"" << mPath << "\"!\n" << " " << Mix_GetError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,7 @@ void Sound::play()
|
|||
mChannel = Mix_PlayChannel(-1, mSound, 0);
|
||||
if(mChannel == -1)
|
||||
{
|
||||
std::cerr << "Error playing sound!\n";
|
||||
std::cerr << " " << Mix_GetError() << "\n";
|
||||
LOG(LogError) << "Error playing sound!\n " << Mix_GetError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <SDL/SDL_joystick.h>
|
||||
#include "Renderer.h"
|
||||
#include "AudioManager.h"
|
||||
#include "Log.h"
|
||||
|
||||
std::vector<SystemData*> SystemData::sSystemVector;
|
||||
|
||||
|
@ -23,19 +24,12 @@ SystemData::SystemData(std::string name, std::string descName, std::string start
|
|||
mName = name;
|
||||
mDescName = descName;
|
||||
|
||||
//expand home symbol if the startpath contains it
|
||||
//expand home symbol if the startpath contains ~
|
||||
if(startPath[0] == '~')
|
||||
{
|
||||
startPath.erase(0, 1);
|
||||
|
||||
std::string home = getenv("HOME");
|
||||
if(home.empty())
|
||||
{
|
||||
std::cerr << "ERROR - System start path contains ~ but $HOME is not set!\n";
|
||||
return;
|
||||
}else{
|
||||
startPath.insert(0, home);
|
||||
}
|
||||
{
|
||||
startPath.erase(0, 1);
|
||||
std::string home = getenv("HOME");
|
||||
startPath.insert(0, home);
|
||||
}
|
||||
|
||||
mStartPath = startPath;
|
||||
|
@ -70,7 +64,7 @@ std::string strreplace(std::string& str, std::string replace, std::string with)
|
|||
|
||||
void SystemData::launchGame(GameData* game)
|
||||
{
|
||||
std::cout << "Attempting to launch game...\n";
|
||||
LOG(LogInfo) << "Attempting to launch game...";
|
||||
|
||||
//suspend SDL joystick events (these'll pile up even while something else is running)
|
||||
SDL_JoystickEventState(0);
|
||||
|
@ -83,13 +77,15 @@ void SystemData::launchGame(GameData* game)
|
|||
command = strreplace(command, "%ROM%", game->getBashPath());
|
||||
command = strreplace(command, "%BASENAME%", game->getBaseName());
|
||||
|
||||
std::cout << " " << command << "\n";
|
||||
std::cout << "=====================================================\n";
|
||||
LOG(LogInfo) << " " << command;
|
||||
LOG(LogInfo) << "==============================================";
|
||||
int exitCode = system(command.c_str());
|
||||
std::cout << "=====================================================\n";
|
||||
LOG(LogInfo) << "==============================================";
|
||||
|
||||
if(exitCode != 0)
|
||||
std::cout << "...launch terminated with nonzero exit code!\n";
|
||||
{
|
||||
LOG(LogWarning) << "...launch terminated with nonzero exit code " << exitCode << "!";
|
||||
}
|
||||
|
||||
Renderer::init(0, 0);
|
||||
AudioManager::init();
|
||||
|
@ -103,7 +99,7 @@ void SystemData::populateFolder(FolderData* folder)
|
|||
std::string folderPath = folder->getPath();
|
||||
if(!fs::is_directory(folderPath))
|
||||
{
|
||||
std::cerr << "Error - folder with path \"" << folderPath << "\" is not a directory!\n";
|
||||
LOG(LogError) << "Error - folder with path \"" << folderPath << "\" is not a directory!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -170,7 +166,7 @@ void SystemData::loadConfig()
|
|||
|
||||
std::string path = getConfigPath();
|
||||
|
||||
std::cout << "Loading system config file \"" << path << "\"...\n";
|
||||
LOG(LogInfo) << "Loading system config file...";
|
||||
|
||||
std::ifstream file(path.c_str());
|
||||
if(file.is_open())
|
||||
|
@ -226,7 +222,7 @@ void SystemData::loadConfig()
|
|||
SystemData* newSystem = new SystemData(sysName, sysDescName, sysPath, sysExtension, sysCommand);
|
||||
if(newSystem->getRootFolder()->getFileCount() == 0)
|
||||
{
|
||||
std::cout << "System \"" << sysName << "\" has no games! Deleting.\n";
|
||||
LOG(LogWarning) << "System \"" << sysName << "\" has no games! Ignoring it.";
|
||||
delete newSystem;
|
||||
}else{
|
||||
sSystemVector.push_back(newSystem);
|
||||
|
@ -236,16 +232,16 @@ void SystemData::loadConfig()
|
|||
sysName = ""; sysDescName = ""; sysPath = ""; sysExtension = ""; sysCommand = "" ;
|
||||
}
|
||||
}else{
|
||||
std::cerr << "Error reading config file \"" << path << "\" - no equals sign found on line \"" << line << "\"!\n";
|
||||
LOG(LogError) << "Error reading config file \"" << path << "\" - no equals sign found on line \"" << line << "\"!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
std::cerr << "Error - could not load config file \"" << path << "\"!\n";
|
||||
LOG(LogError) << "Error - could not load config file \"" << path << "\"!";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "Finished loading config file - created " << sSystemVector.size() << " systems.\n";
|
||||
LOG(LogInfo) << "Finished loading config file - created " << sSystemVector.size() << " systems.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -294,7 +290,7 @@ std::string SystemData::getConfigPath()
|
|||
std::string home = getenv("HOME");
|
||||
if(home.empty())
|
||||
{
|
||||
std::cerr << "FATAL ERROR - $HOME environment variable empty or nonexistant!\n";
|
||||
LOG(LogError) << "$HOME environment variable empty or nonexistant!";
|
||||
exit(1);
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "GameData.h"
|
||||
#include "pugiXML/pugixml.hpp"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "Log.h"
|
||||
|
||||
//this is obviously an incredibly inefficient way to go about searching
|
||||
//but I don't think it'll matter too much with the size of most collections
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
#include "GuiMenu.h"
|
||||
#include "GuiFastSelect.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "../Log.h"
|
||||
|
||||
GuiGameList::GuiGameList(bool useDetail)
|
||||
{
|
||||
//std::cout << "Creating GuiGameList\n";
|
||||
mDetailed = useDetail;
|
||||
|
||||
mTheme = new GuiTheme(); //not a child because it's rendered manually by GuiGameList::onRender (to make sure it's rendered first)
|
||||
|
@ -61,7 +60,7 @@ void GuiGameList::setSystemId(int id)
|
|||
{
|
||||
if(SystemData::sSystemVector.size() == 0)
|
||||
{
|
||||
std::cerr << "Error - no systems found!\n";
|
||||
LOG(LogError) << "Error - no systems found!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <math.h>
|
||||
#include "../Log.h"
|
||||
|
||||
unsigned int GuiImage::getWidth() { return mDrawWidth; }
|
||||
unsigned int GuiImage::getHeight() { return mDrawHeight; }
|
||||
|
@ -44,7 +45,7 @@ void GuiImage::loadImage(std::string path)
|
|||
//make sure the file *exists*
|
||||
if(!boost::filesystem::exists(path))
|
||||
{
|
||||
std::cerr << "File \"" << path << "\" not found!\n";
|
||||
LOG(LogError) << "File \"" << path << "\" not found!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,7 @@ void GuiImage::loadImage(std::string path)
|
|||
format = FreeImage_GetFIFFromFilename(path.c_str());
|
||||
if(format == FIF_UNKNOWN)
|
||||
{
|
||||
std::cerr << "Error - could not detect filetype for image \"" << path << "\"!\n";
|
||||
LOG(LogError) << "Error - could not detect filetype for image \"" << path << "\"!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -73,14 +74,14 @@ void GuiImage::loadImage(std::string path)
|
|||
{
|
||||
image = FreeImage_Load(format, path.c_str());
|
||||
}else{
|
||||
std::cerr << "Error - file format reading not supported for image \"" << path << "\"!\n";
|
||||
LOG(LogError) << "Error - file format reading not supported for image \"" << path << "\"!";
|
||||
return;
|
||||
}
|
||||
|
||||
//make sure it loaded properly
|
||||
if(!image)
|
||||
{
|
||||
std::cerr << "Error loading image \"" << path << "\"!\n";
|
||||
LOG(LogError) << "Error loading image \"" << path << "\"!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -93,7 +94,7 @@ void GuiImage::loadImage(std::string path)
|
|||
imageData = FreeImage_GetBits(image);
|
||||
if(!imageData)
|
||||
{
|
||||
std::cerr << "Error retriving bits from image \"" << path << "\"!\n";
|
||||
LOG(LogError) << "Error retriving bits from image \"" << path << "\"!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ void GuiImage::loadImage(std::string path)
|
|||
//if width or height are zero then something is clearly wrong
|
||||
if(!width || !height)
|
||||
{
|
||||
std::cerr << "Width or height are zero for image \"" << path << "\"!\n";
|
||||
LOG(LogError) << "Width or height are zero for image \"" << path << "\"!";
|
||||
FreeImage_Unload(image);
|
||||
return;
|
||||
}
|
||||
|
@ -127,7 +128,7 @@ void GuiImage::loadImage(std::string path)
|
|||
|
||||
if(!widthPwrOf2 || !heightPwrOf2)
|
||||
{
|
||||
std::cerr << "Error assigning power of two for width or height of image!\n";
|
||||
LOG(LogError) << "Error assigning power of two for width or height of image!";
|
||||
FreeImage_Unload(image);
|
||||
return;
|
||||
}*/
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "GuiGameList.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "../Log.h"
|
||||
|
||||
extern bool DEBUG; //defined in main.cpp
|
||||
|
||||
|
@ -24,7 +25,7 @@ GuiInputConfig::GuiInputConfig()
|
|||
mDone = true;
|
||||
return;
|
||||
}else{
|
||||
std::cout << "Opening joystick \"" << SDL_JoystickName(0) << "\" for configuration...\n";
|
||||
LOG(LogInfo) << "Opening joystick \"" << SDL_JoystickName(0) << "\" for configuration...";
|
||||
mJoystick = SDL_JoystickOpen(0);
|
||||
}
|
||||
}
|
||||
|
@ -63,16 +64,14 @@ void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown)
|
|||
{
|
||||
if(InputManager::lastEvent->type == SDL_KEYUP || InputManager::lastEvent->type == SDL_JOYBUTTONDOWN)
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " finishing configuration...\n";
|
||||
LOG(LogDebug) << " finishing configuration...";
|
||||
|
||||
writeConfig();
|
||||
|
||||
if(mJoystick)
|
||||
SDL_JoystickClose(mJoystick);
|
||||
|
||||
if(DEBUG)
|
||||
std::cout << "Config complete. Closed joystick, loading input then opening GuiGameList.\n";
|
||||
LOG(LogDebug) << "Config complete. Closed joystick, loading input then opening GuiGameList.";
|
||||
|
||||
InputManager::loadConfig();
|
||||
delete this;
|
||||
|
@ -84,8 +83,7 @@ void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown)
|
|||
SDL_Event* event = InputManager::lastEvent;
|
||||
if(event->type == SDL_KEYUP)
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " [KEYUP] (skipping)\n";
|
||||
LOG(LogDebug) << " [KEYUP] (skipping)";
|
||||
|
||||
//keyboard key pressed; skip and continue
|
||||
mInputNum++;
|
||||
|
@ -93,21 +91,16 @@ void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown)
|
|||
|
||||
if(event->type == SDL_JOYBUTTONDOWN)
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " [JOYBUTTONDOWN] button " << event->jbutton.button << "\n";
|
||||
|
||||
LOG(LogDebug) << " [JOYBUTTONDOWN] button " << event->jbutton.button;
|
||||
|
||||
mButtonMap[event->jbutton.button] = (InputManager::InputButton)mInputNum;
|
||||
std::cout << " Mapping " << sInputs[mInputNum] << " to button " << (int)event->jbutton.button << "\n";
|
||||
LOG(LogInfo) << " Mapping " << sInputs[mInputNum] << " to button " << (int)event->jbutton.button;
|
||||
mInputNum++;
|
||||
}
|
||||
|
||||
if(event->type == SDL_JOYAXISMOTION)
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " [JOYAXISMOTION] axis " << event->jaxis.axis << ", value " << event->jaxis.value << "\n";
|
||||
|
||||
//std::cout << "motion on axis " << event->jaxis.axis << " to value " << event->jaxis.value << "\n";
|
||||
LOG(LogDebug) << " [JOYAXISMOTION] axis " << event->jaxis.axis << ", value " << event->jaxis.value;
|
||||
|
||||
if(event->jaxis.axis == mLastAxis)
|
||||
{
|
||||
|
@ -120,13 +113,13 @@ void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown)
|
|||
mAxisPosMap[event->jaxis.axis] = (InputManager::InputButton)mInputNum;
|
||||
mInputNum++;
|
||||
mLastAxis = event->jaxis.axis;
|
||||
std::cout << " Mapping " << sInputs[mInputNum - 1] << " to axis+ " << mLastAxis << "\n";
|
||||
LOG(LogInfo) << " Mapping " << sInputs[mInputNum - 1] << " to axis+ " << mLastAxis;
|
||||
}else if(event->jaxis.value < -InputManager::deadzone)
|
||||
{
|
||||
mAxisNegMap[event->jaxis.axis] = (InputManager::InputButton)mInputNum;
|
||||
mInputNum++;
|
||||
mLastAxis = event->jaxis.axis;
|
||||
std::cout << " Mapping " << sInputs[mInputNum - 1] << " to axis- " << mLastAxis << "\n";
|
||||
LOG(LogInfo) << " Mapping " << sInputs[mInputNum - 1] << " to axis- " << mLastAxis;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,8 +132,7 @@ void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown)
|
|||
|
||||
void GuiInputConfig::writeConfig()
|
||||
{
|
||||
if(DEBUG)
|
||||
std::cout << " writing config...";
|
||||
LOG(LogDebug) << " Writing config...";
|
||||
|
||||
std::string path = InputManager::getConfigPath();
|
||||
|
||||
|
@ -167,6 +159,5 @@ void GuiInputConfig::writeConfig()
|
|||
|
||||
file.close();
|
||||
|
||||
if(DEBUG)
|
||||
std::cout << "done.\n";
|
||||
LOG(LogDebug) << " Write complete.\n";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "GuiMenu.h"
|
||||
#include <iostream>
|
||||
#include <SDL/SDL.h>
|
||||
#include "../Log.h"
|
||||
|
||||
//defined in main.cpp
|
||||
extern bool DONTSHOWEXIT;
|
||||
|
@ -59,7 +60,9 @@ void GuiMenu::executeCommand(std::string command)
|
|||
SDL_PushEvent(event);
|
||||
}else{
|
||||
if(system(command.c_str()) != 0)
|
||||
std::cout << "(warning: command terminated with nonzero result!)\n";
|
||||
{
|
||||
LOG(LogWarning) << "(warning: command terminated with nonzero result!)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#include <boost/filesystem.hpp>
|
||||
#include <sstream>
|
||||
#include "../Renderer.h"
|
||||
|
||||
//really, this should all be refactored into "getColor("attribName")" and such,
|
||||
//but it's a little late now.
|
||||
#include "../Log.h"
|
||||
|
||||
unsigned int GuiTheme::getColor(std::string name)
|
||||
{
|
||||
|
@ -151,15 +149,14 @@ void GuiTheme::readXML(std::string path)
|
|||
if(path.empty())
|
||||
return;
|
||||
|
||||
std::cout << "Loading theme \"" << path << "\"...\n";
|
||||
LOG(LogInfo) << "Loading theme \"" << path << "\"...";
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_file(path.c_str());
|
||||
|
||||
if(!result)
|
||||
{
|
||||
std::cerr << "Error parsing theme \"" << path << "\"!\n";
|
||||
std::cerr << " " << result.description() << "\n";
|
||||
LOG(LogError) << "Error parsing theme \"" << path << "\"!\n" << " " << result.description();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -221,6 +218,8 @@ void GuiTheme::readXML(std::string path)
|
|||
|
||||
//actually read the components
|
||||
createComponentChildren(root, this);
|
||||
|
||||
LOG(LogInfo) << "Loading complete.";
|
||||
}
|
||||
|
||||
//recursively creates components (with proper parenting)
|
||||
|
@ -246,7 +245,7 @@ GuiComponent* GuiTheme::createElement(pugi::xml_node data, GuiComponent* parent)
|
|||
|
||||
if(!boost::filesystem::exists(path))
|
||||
{
|
||||
std::cerr << "Error - theme image \"" << path << "\" does not exist.\n";
|
||||
LOG(LogError) << "Error - theme image \"" << path << "\" does not exist.";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -286,7 +285,7 @@ GuiComponent* GuiTheme::createElement(pugi::xml_node data, GuiComponent* parent)
|
|||
}
|
||||
|
||||
|
||||
std::cerr << "Theme component type \"" << type << "\" unknown!\n";
|
||||
LOG(LogError) << "Theme component type \"" << type << "\" unknown!";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -325,7 +324,7 @@ unsigned int GuiTheme::resolveColor(std::string str, unsigned int defaultColor)
|
|||
|
||||
if(str.length() != 6 && str.length() != 8)
|
||||
{
|
||||
std::cerr << "Error - color \"" << str << "\" is not a valid hex color! Must be 6 or 8 characters.\n";
|
||||
LOG(LogError) << "Color \"" << str << "\" is not a valid hex color! Must be 6 or 8 characters.";
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
|
@ -353,7 +352,7 @@ void GuiTheme::splitString(std::string str, char delim, std::string* before, std
|
|||
*before = str.substr(0, split);
|
||||
*after = str.substr(split + 1, str.length() - split - 1);
|
||||
}else{
|
||||
std::cerr << " Error: tried to splt string \"" << str << "\" with delimiter '" << delim << "', but delimiter was not found!\n";
|
||||
LOG(LogError) << "Tried to splt string \"" << str << "\" with delimiter '" << delim << "', but delimiter was not found!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <SDL.h>
|
||||
#include "AudioManager.h"
|
||||
#include "platform.h"
|
||||
#include "Log.h"
|
||||
|
||||
#ifdef _RPI_
|
||||
#include <bcm_host.h>
|
||||
|
@ -66,7 +67,7 @@ int main(int argc, char* argv[])
|
|||
std::cout << "--ignore-gamelist ignore the gamelist (useful for troubleshooting)\n";
|
||||
std::cout << "--draw-framerate display the framerate\n";
|
||||
std::cout << "--no-exit don't show the exit option in the menu\n";
|
||||
std::cout << "--debug print additional output to console\n";
|
||||
std::cout << "--debug even more logging\n";
|
||||
std::cout << "--help summon a sentient, angry tuba\n\n";
|
||||
std::cout << "More information available in README.md.\n";
|
||||
return 0;
|
||||
|
@ -74,7 +75,6 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _RPI_
|
||||
bcm_host_init();
|
||||
#endif
|
||||
|
@ -86,6 +86,7 @@ int main(int argc, char* argv[])
|
|||
if(!renderInit)
|
||||
{
|
||||
std::cerr << "Error initializing renderer!\n";
|
||||
Log::close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -195,9 +196,9 @@ int main(int argc, char* argv[])
|
|||
|
||||
|
||||
Renderer::swapBuffers();
|
||||
Log::flush();
|
||||
}
|
||||
|
||||
|
||||
AudioManager::deinit();
|
||||
Renderer::deleteAll();
|
||||
Renderer::deinit();
|
||||
|
@ -205,7 +206,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
std::cout << "EmulationStation cleanly shutting down...\n";
|
||||
|
||||
SDL_Quit();
|
||||
Log::close();
|
||||
|
||||
#ifdef _RPI_
|
||||
bcm_host_deinit();
|
||||
|
|
Loading…
Reference in a new issue