2012-07-19 01:14:17 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <SDL/SDL.h>
|
2012-07-20 01:08:29 +00:00
|
|
|
#include <SDL/SDL_ttf.h>
|
2012-07-19 01:14:17 +00:00
|
|
|
#include "Renderer.h"
|
2012-07-20 16:14:09 +00:00
|
|
|
#include "components/GuiGameList.h"
|
|
|
|
#include "SystemData.h"
|
2012-07-23 23:53:33 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
2012-07-22 21:15:55 +00:00
|
|
|
#include "components/GuiInputConfig.h"
|
|
|
|
|
2012-07-19 01:14:17 +00:00
|
|
|
int main()
|
|
|
|
{
|
2012-07-23 23:53:33 +00:00
|
|
|
bool running = true;
|
|
|
|
|
2012-07-23 21:47:30 +00:00
|
|
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
|
2012-07-19 01:14:17 +00:00
|
|
|
{
|
|
|
|
std::cerr << "Error - could not initialize SDL!\n";
|
2012-07-21 19:06:24 +00:00
|
|
|
std::cerr << " " << SDL_GetError() << "\n";
|
2012-07-23 21:47:30 +00:00
|
|
|
std::cerr << "\nAre you in the 'video' and 'input' groups?\n";
|
2012-07-19 01:14:17 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-07-20 01:08:29 +00:00
|
|
|
if(TTF_Init() != 0)
|
|
|
|
{
|
|
|
|
std::cerr << "Error - could not initialize SDL_ttf!\n";
|
2012-07-21 19:06:24 +00:00
|
|
|
std::cerr << " " << TTF_GetError() << "\n";
|
2012-07-20 01:08:29 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-07-19 01:14:17 +00:00
|
|
|
|
2012-07-21 20:16:07 +00:00
|
|
|
Renderer::screen = SDL_SetVideoMode(Renderer::getScreenWidth(), Renderer::getScreenHeight(), 16, SDL_SWSURFACE);
|
2012-07-19 16:13:27 +00:00
|
|
|
if(Renderer::screen == NULL)
|
|
|
|
{
|
|
|
|
std::cerr << "Error - could not set video mode!\n";
|
2012-07-21 19:06:24 +00:00
|
|
|
std::cerr << " " << SDL_GetError() << "\n";
|
2012-07-19 16:13:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-07-20 01:08:29 +00:00
|
|
|
SDL_ShowCursor(false);
|
2012-07-21 19:06:24 +00:00
|
|
|
SDL_EnableKeyRepeat(500, 100);
|
2012-07-22 21:15:55 +00:00
|
|
|
SDL_JoystickEventState(SDL_ENABLE);
|
2012-07-19 16:13:27 +00:00
|
|
|
|
2012-07-23 23:53:33 +00:00
|
|
|
if(!boost::filesystem::exists(SystemData::getConfigPath()))
|
|
|
|
{
|
|
|
|
std::cerr << "A system config file in $HOME/.es_systems.cfg was not found. An example will be created.\n";
|
|
|
|
SystemData::writeExampleConfig();
|
|
|
|
std::cerr << "Set it up, then re-run EmulationStation.\n";
|
|
|
|
running = false;
|
|
|
|
}else{
|
|
|
|
SystemData::loadConfig();
|
2012-07-19 16:13:27 +00:00
|
|
|
|
2012-07-23 23:53:33 +00:00
|
|
|
if(boost::filesystem::exists(InputManager::getConfigPath()))
|
|
|
|
{
|
|
|
|
InputManager::loadConfig();
|
|
|
|
new GuiGameList();
|
|
|
|
}else{
|
|
|
|
if(SDL_NumJoysticks() > 0)
|
|
|
|
{
|
|
|
|
new GuiInputConfig();
|
|
|
|
}else{
|
|
|
|
std::cout << "Note - it looks like you have no joysticks connected.\n";
|
|
|
|
new GuiGameList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-22 21:15:55 +00:00
|
|
|
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-07-19 16:13:27 +00:00
|
|
|
while(running)
|
|
|
|
{
|
|
|
|
SDL_Event event;
|
|
|
|
while(SDL_PollEvent(&event))
|
|
|
|
{
|
|
|
|
switch(event.type)
|
|
|
|
{
|
2012-07-23 17:27:38 +00:00
|
|
|
case SDL_JOYAXISMOTION:
|
2012-07-22 21:15:55 +00:00
|
|
|
case SDL_JOYBUTTONDOWN:
|
|
|
|
case SDL_JOYBUTTONUP:
|
2012-07-19 16:13:27 +00:00
|
|
|
case SDL_KEYDOWN:
|
2012-07-20 01:08:29 +00:00
|
|
|
InputManager::processEvent(&event);
|
|
|
|
break;
|
|
|
|
case SDL_KEYUP:
|
|
|
|
InputManager::processEvent(&event);
|
2012-07-19 16:13:27 +00:00
|
|
|
break;
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-07-19 16:13:27 +00:00
|
|
|
case SDL_QUIT:
|
|
|
|
running = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Renderer::render();
|
|
|
|
SDL_Flip(Renderer::screen);
|
|
|
|
}
|
|
|
|
|
2012-07-22 21:15:55 +00:00
|
|
|
Renderer::deleteAll();
|
2012-07-21 20:57:53 +00:00
|
|
|
SystemData::deleteSystems();
|
2012-07-19 01:14:17 +00:00
|
|
|
|
2012-07-20 01:08:29 +00:00
|
|
|
std::cout << "EmulationStation cleanly shutting down...\n";
|
|
|
|
|
|
|
|
TTF_Quit();
|
2012-07-19 01:14:17 +00:00
|
|
|
SDL_Quit();
|
|
|
|
return 0;
|
|
|
|
}
|