GUI navigation improvements, only initializing game controller once now
This commit is contained in:
parent
3f8a881cfb
commit
0f6617d3dd
10 changed files with 343 additions and 321 deletions
|
@ -36,7 +36,6 @@
|
|||
#define DIALOG_WIDTH 620
|
||||
#define DIALOG_HEIGHT 202
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
static const char* harddisk_filter[] = {".hdf", "\0"};
|
||||
|
@ -225,7 +224,6 @@ static void CreateFilesysHardfileLoop()
|
|||
{
|
||||
FocusBugWorkaround(wndCreateFilesysHardfile);
|
||||
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -282,6 +280,8 @@ static void CreateFilesysHardfileLoop()
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
|
@ -324,6 +324,8 @@ static void CreateFilesysHardfileLoop()
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guisan-controls
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#define DIALOG_WIDTH 620
|
||||
#define DIALOG_HEIGHT 272
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
static const char* harddisk_filter[] = {".hdf", "\0"};
|
||||
|
@ -455,6 +454,8 @@ static void EditFilesysHardfileLoop()
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
|
@ -497,6 +498,8 @@ static void EditFilesysHardfileLoop()
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#define DIALOG_WIDTH 520
|
||||
#define DIALOG_HEIGHT 202
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
extern string volName;
|
||||
|
@ -284,6 +283,8 @@ static void EditFilesysVirtualLoop()
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
|
@ -326,6 +327,8 @@ static void EditFilesysVirtualLoop()
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "androidsdl_event.h"
|
||||
#endif
|
||||
|
||||
static SDL_Joystick *GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
extern SDL_Surface* screen;
|
||||
|
@ -89,7 +88,6 @@ void checkInput()
|
|||
//-------------------------------------------------
|
||||
// Check user input
|
||||
//-------------------------------------------------
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
while (SDL_PollEvent(&msg_event))
|
||||
{
|
||||
if (msg_event.type == SDL_KEYDOWN)
|
||||
|
@ -107,12 +105,14 @@ void checkInput()
|
|||
}
|
||||
else if (msg_event.type == SDL_JOYBUTTONDOWN)
|
||||
{
|
||||
|
||||
if (GUIjoy)
|
||||
{
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button))
|
||||
|
||||
msg_done = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#define FILE_SELECT_KEEP_POSITION
|
||||
#endif
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
static bool dialogResult = false;
|
||||
|
@ -335,8 +334,6 @@ static void SelectFileLoop()
|
|||
{
|
||||
FocusBugWorkaround(wndSelectFile);
|
||||
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -377,6 +374,8 @@ static void SelectFileLoop()
|
|||
}
|
||||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYHATMOTION)
|
||||
{
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
|
@ -412,6 +411,8 @@ static void SelectFileLoop()
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guisan-controls
|
||||
|
|
|
@ -35,7 +35,6 @@ static bool dialogResult = false;
|
|||
static bool dialogFinished = false;
|
||||
static char workingDir[MAX_DPATH];
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
static gcn::Window* wndSelectFolder;
|
||||
static gcn::Button* cmdOK;
|
||||
|
@ -278,6 +277,8 @@ static void SelectFolderLoop()
|
|||
}
|
||||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYHATMOTION)
|
||||
{
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
|
@ -318,6 +319,8 @@ static void SelectFolderLoop()
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guisan-controls
|
||||
|
|
|
@ -27,10 +27,8 @@
|
|||
#include "androidsdl_event.h"
|
||||
#endif
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
|
||||
#define DIALOG_WIDTH 760
|
||||
#define DIALOG_HEIGHT 420
|
||||
|
||||
|
@ -150,8 +148,6 @@ static void ShowHelpLoop(void)
|
|||
{
|
||||
FocusBugWorkaround(wndShowHelp);
|
||||
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -186,6 +182,8 @@ static void ShowHelpLoop(void)
|
|||
}
|
||||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN)
|
||||
{
|
||||
if (GUIjoy)
|
||||
{
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
|
@ -199,6 +197,8 @@ static void ShowHelpLoop(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guisan-controls
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
static bool dialogResult = false;
|
||||
static bool dialogFinished = false;
|
||||
static SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
static const char* dialogControlPressed;
|
||||
static Uint8 dialogButtonPressed;
|
||||
|
@ -179,8 +178,6 @@ static void ShowMessageLoop()
|
|||
{
|
||||
FocusBugWorkaround(wndShowMessage);
|
||||
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -220,6 +217,8 @@ static void ShowMessageLoop()
|
|||
}
|
||||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYHATMOTION)
|
||||
{
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
|
@ -244,6 +243,8 @@ static void ShowMessageLoop()
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guisan-controls
|
||||
|
|
|
@ -41,6 +41,7 @@ extern gcn::Color gui_baseCol;
|
|||
extern gcn::Color colTextboxBackground;
|
||||
extern gcn::SDLInput* gui_input;
|
||||
extern SDL_Surface* gui_screen;
|
||||
extern SDL_Joystick* GUIjoy;
|
||||
|
||||
extern char currentDir[MAX_DPATH];
|
||||
extern char last_loaded_config[MAX_DPATH];
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
static SDL_Joystick* GUIjoy;
|
||||
SDL_Joystick* GUIjoy;
|
||||
extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
|
||||
|
||||
bool gui_running = false;
|
||||
|
@ -62,9 +62,7 @@ ConfigCategory categories[] = {
|
|||
{ "Display", "data/screen.ico", nullptr, nullptr, InitPanelDisplay, ExitPanelDisplay, RefreshPanelDisplay, HelpPanelDisplay },
|
||||
{ "Sound", "data/sound.ico", nullptr, nullptr, InitPanelSound, ExitPanelSound, RefreshPanelSound, HelpPanelSound },
|
||||
{ "Input", "data/joystick.ico", nullptr, nullptr, InitPanelInput, ExitPanelInput, RefreshPanelInput, HelpPanelInput },
|
||||
#ifndef PANDORA
|
||||
{ "Custom controls", "data/controller.png", NULL, NULL, InitPanelCustom, ExitPanelCustom, RefreshPanelCustom, HelpPanelCustom },
|
||||
#endif
|
||||
{ "Miscellaneous", "data/misc.ico", NULL, NULL, InitPanelMisc, ExitPanelMisc, RefreshPanelMisc, HelpPanelMisc },
|
||||
{ "Savestates", "data/savestate.png", NULL, NULL, InitPanelSavestate, ExitPanelSavestate, RefreshPanelSavestate, HelpPanelSavestate },
|
||||
#ifdef ANDROIDSDL
|
||||
|
@ -280,7 +278,7 @@ namespace sdl
|
|||
|
||||
void gui_init()
|
||||
{
|
||||
#ifdef USE_SDL1
|
||||
#ifdef PANDORA
|
||||
//-------------------------------------------------
|
||||
// Set layer for GUI screen
|
||||
//-------------------------------------------------
|
||||
|
@ -294,10 +292,10 @@ namespace sdl
|
|||
// Create new screen for GUI
|
||||
//-------------------------------------------------
|
||||
#ifdef USE_SDL1
|
||||
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
||||
gui_screen = SDL_SetVideoMode(GUI_WIDTH, GUI_HEIGHT, 16, SDL_SWSURFACE | SDL_FULLSCREEN);
|
||||
SDL_EnableUNICODE(1);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
#endif
|
||||
#ifdef USE_SDL2
|
||||
setup_cursor();
|
||||
|
@ -350,14 +348,18 @@ namespace sdl
|
|||
delete gui_input;
|
||||
delete gui_graphics;
|
||||
|
||||
#ifdef USE_SDL1
|
||||
if (gui_screen != nullptr)
|
||||
{
|
||||
SDL_FreeSurface(gui_screen);
|
||||
#elif USE_SDL2
|
||||
SDL_FreeSurface(gui_screen);
|
||||
gui_screen = nullptr;
|
||||
}
|
||||
|
||||
#ifdef USE_SDL2
|
||||
if (gui_texture != nullptr)
|
||||
{
|
||||
SDL_DestroyTexture(gui_texture);
|
||||
gui_texture = nullptr;
|
||||
}
|
||||
|
||||
if (cursor)
|
||||
{
|
||||
|
@ -370,7 +372,6 @@ namespace sdl
|
|||
cursorSurface = nullptr;
|
||||
}
|
||||
#endif
|
||||
gui_screen = nullptr;
|
||||
}
|
||||
|
||||
void checkInput()
|
||||
|
@ -399,6 +400,8 @@ namespace sdl
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
|
@ -471,6 +474,8 @@ namespace sdl
|
|||
gui_running = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (gui_event.type == SDL_KEYDOWN)
|
||||
{
|
||||
|
@ -584,6 +589,7 @@ namespace sdl
|
|||
|
||||
void gui_run()
|
||||
{
|
||||
if (SDL_NumJoysticks() > 0)
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -612,11 +618,12 @@ namespace sdl
|
|||
currFunc();
|
||||
}
|
||||
}
|
||||
|
||||
if (GUIjoy)
|
||||
SDL_JoystickClose(GUIjoy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace widgets
|
||||
{
|
||||
class MainButtonActionListener : public gcn::ActionListener
|
||||
|
@ -936,7 +943,8 @@ void run_gui()
|
|||
{
|
||||
sdl::gui_init();
|
||||
widgets::gui_init();
|
||||
if (_tcslen(startup_message) > 0) {
|
||||
if (_tcslen(startup_message) > 0)
|
||||
{
|
||||
ShowMessage(startup_title, startup_message, _T(""), _T("Ok"), _T(""));
|
||||
_tcscpy(startup_title, _T(""));
|
||||
_tcscpy(startup_message, _T(""));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue