2012-07-22 21:15:55 +00:00
# include "GuiInputConfig.h"
# include "GuiGameList.h"
# include <iostream>
# include <fstream>
2013-01-04 23:31:51 +00:00
# include "../Log.h"
2012-07-22 21:15:55 +00:00
2012-12-20 18:29:05 +00:00
extern bool DEBUG ; //defined in main.cpp
2013-04-08 16:52:40 +00:00
std : : string GuiInputConfig : : sInputs [ ] = { " UP " , " DOWN " , " LEFT " , " RIGHT " , " A " , " B " , " START " , " SELECT " , " PAGEUP " , " PAGEDOWN " } ; //must be same order as InputManager::InputButton enum; only add to the end to preserve backwards compatibility
int GuiInputConfig : : sInputCount = 10 ;
2012-07-22 21:15:55 +00:00
2013-04-08 16:52:40 +00:00
GuiInputConfig : : GuiInputConfig ( Window * window ) : Gui ( window )
2012-07-22 21:15:55 +00:00
{
2013-04-08 16:52:40 +00:00
mInputNum = 0 ;
2012-07-22 21:15:55 +00:00
mDone = false ;
if ( SDL_NumJoysticks ( ) < 1 )
{
std : : cerr < < " Error - GuiInputConfig found no SDL joysticks! \n " ;
mJoystick = NULL ;
mDone = true ;
return ;
} else {
2013-01-04 23:31:51 +00:00
LOG ( LogInfo ) < < " Opening joystick \" " < < SDL_JoystickName ( 0 ) < < " \" for configuration... " ;
2012-07-22 21:15:55 +00:00
mJoystick = SDL_JoystickOpen ( 0 ) ;
}
2013-03-29 02:57:01 +00:00
SDL_JoystickEventState ( SDL_ENABLE ) ;
2012-07-22 21:15:55 +00:00
}
GuiInputConfig : : ~ GuiInputConfig ( )
{
}
void GuiInputConfig : : onRender ( )
{
2012-10-17 18:21:56 +00:00
Renderer : : drawRect ( 0 , 0 , Renderer : : getScreenWidth ( ) , Renderer : : getScreenHeight ( ) , 0xFFFFFFFF ) ;
2012-07-22 21:15:55 +00:00
2012-10-24 15:28:37 +00:00
Font * font = Renderer : : getDefaultFont ( Renderer : : MEDIUM ) ;
2012-08-02 01:43:55 +00:00
2012-10-24 15:28:37 +00:00
int height = font - > getHeight ( ) + 6 ;
Renderer : : drawCenteredText ( " It looks like you have a joystick plugged in! " , 0 , 2 , 0x000000FF , font ) ;
Renderer : : drawCenteredText ( " POV hats (some D-Pads) are automatically mapped to directions. " , 0 , height , 0x000000FF , font ) ;
Renderer : : drawCenteredText ( " You can press a keyboard key to skip any input. " , 0 , height * 2 , 0x000000FF , font ) ;
2012-10-25 18:03:35 +00:00
Renderer : : drawCenteredText ( " If you want to remap later, delete ~/.emulationstation/es_input.cfg. " , 0 , height * 3 , 0x000000FF , font ) ;
2012-10-24 15:28:37 +00:00
Renderer : : drawCenteredText ( " This interface only configures the first joystick plugged in. " , 0 , height * 4 , 0x000000FF , font ) ;
Renderer : : drawCenteredText ( " Remember - you'll need to set up your emulator separately! " , 0 , Renderer : : getScreenHeight ( ) - height , 0x000000FF , font ) ;
2012-07-23 23:53:33 +00:00
2012-07-22 21:15:55 +00:00
if ( mDone )
2012-12-20 18:29:05 +00:00
Renderer : : drawCenteredText ( " All done! Press a key or button to save. " , 0 , height * 5 , 0x00BB00FF , font ) ;
2012-07-22 21:15:55 +00:00
else
2012-10-24 15:28:37 +00:00
Renderer : : drawCenteredText ( " Please press the axis/button for " + sInputs [ mInputNum ] , 0 , height * 5 , 0x00C000FF , font ) ;
2012-07-22 21:15:55 +00:00
}
2013-04-08 16:52:40 +00:00
void GuiInputConfig : : input ( InputConfig * config , Input input )
2012-07-22 21:15:55 +00:00
{
}