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,47 +280,51 @@ static void CreateFilesysHardfileLoop()
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
continue;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button)) // need this to be START button
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
continue;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button)) // need this to be START button
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -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,47 +454,51 @@ static void EditFilesysHardfileLoop()
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button)) // need this to be START button
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button)) // need this to be START button
|
||||
{
|
||||
dialogFinished = true;
|
||||
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,47 +283,51 @@ static void EditFilesysVirtualLoop()
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button)) // need this to be START button
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button)) // need this to be START button
|
||||
{
|
||||
dialogFinished = true;
|
||||
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,13 +105,15 @@ void checkInput()
|
|||
}
|
||||
else if (msg_event.type == SDL_JOYBUTTONDOWN)
|
||||
{
|
||||
|
||||
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;
|
||||
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;
|
||||
|
@ -378,39 +375,43 @@ static void SelectFileLoop()
|
|||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYHATMOTION)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT))
|
||||
{
|
||||
navigate_left();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT))
|
||||
{
|
||||
navigate_right();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP))
|
||||
{
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN))
|
||||
{
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT))
|
||||
{
|
||||
navigate_left();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT))
|
||||
{
|
||||
navigate_right();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP))
|
||||
{
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN))
|
||||
{
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -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;
|
||||
|
@ -279,44 +278,48 @@ static void SelectFolderLoop()
|
|||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYHATMOTION)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
if (GUIjoy)
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT))
|
||||
{
|
||||
navigate_left();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT))
|
||||
{
|
||||
navigate_right();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT))
|
||||
{
|
||||
navigate_left();
|
||||
break;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP))
|
||||
{
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT))
|
||||
{
|
||||
navigate_right();
|
||||
break;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN))
|
||||
{
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP))
|
||||
{
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN))
|
||||
{
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -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;
|
||||
|
@ -187,17 +183,21 @@ static void ShowHelpLoop(void)
|
|||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN)
|
||||
{
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
if (GUIjoy)
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -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;
|
||||
|
@ -221,28 +218,32 @@ static void ShowMessageLoop()
|
|||
}
|
||||
else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYHATMOTION)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
if (GUIjoy)
|
||||
{
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) ||
|
||||
(hat & SDL_HAT_LEFT) ||
|
||||
(hat & SDL_HAT_RIGHT))
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button))
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].east_button) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].start_button))
|
||||
{
|
||||
dialogFinished = true;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) ||
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) ||
|
||||
(hat & SDL_HAT_LEFT) ||
|
||||
(hat & SDL_HAT_RIGHT))
|
||||
|
||||
{
|
||||
navigate_left_right();
|
||||
break;
|
||||
{
|
||||
navigate_left_right();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -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,15 +62,13 @@ 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 },
|
||||
{ "Custom controls", "data/controller.png", NULL, NULL, InitPanelCustom, ExitPanelCustom, RefreshPanelCustom, HelpPanelCustom },
|
||||
{ "Miscellaneous", "data/misc.ico", NULL, NULL, InitPanelMisc, ExitPanelMisc, RefreshPanelMisc, HelpPanelMisc },
|
||||
{ "Savestates", "data/savestate.png", NULL, NULL, InitPanelSavestate, ExitPanelSavestate, RefreshPanelSavestate, HelpPanelSavestate },
|
||||
#ifdef ANDROIDSDL
|
||||
{ "OnScreen", "data/screen.ico", NULL, NULL, InitPanelOnScreen, ExitPanelOnScreen, RefreshPanelOnScreen, HelpPanelOnScreen },
|
||||
{ "OnScreen", "data/screen.ico", NULL, NULL, InitPanelOnScreen, ExitPanelOnScreen, RefreshPanelOnScreen, HelpPanelOnScreen },
|
||||
#endif
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
SDL_DestroyTexture(gui_texture);
|
||||
gui_texture = 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,77 +400,81 @@ namespace sdl
|
|||
gcn::FocusHandler* focusHdl;
|
||||
gcn::Widget* activeWidget;
|
||||
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
if (GUIjoy)
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
const int hat = SDL_JoystickGetHat(GUIjoy, 0);
|
||||
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].left_shoulder)) // dpad
|
||||
{
|
||||
for (int z = 0; z<10; ++z)
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_up) || (hat & SDL_HAT_UP)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_UP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].right_shoulder)) // dpad
|
||||
{
|
||||
for (int z = 0; z<10; ++z)
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_down) || (hat & SDL_HAT_DOWN)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].left_shoulder)) // dpad
|
||||
{
|
||||
for (int z = 0; z<10; ++z)
|
||||
{
|
||||
PushFakeKey(SDLK_UP);
|
||||
}
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].right_shoulder)) // dpad
|
||||
{
|
||||
for (int z = 0; z<10; ++z)
|
||||
{
|
||||
PushFakeKey(SDLK_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].quit_button) &&
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].hotkey_button)) // use the HOTKEY button
|
||||
{
|
||||
uae_quit();
|
||||
gui_running = false;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].left_trigger))
|
||||
{
|
||||
ShowHelpRequested();
|
||||
widgets::cmdHelp->requestFocus();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].menu_button)) // use the HOTKEY button
|
||||
{
|
||||
gui_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_right) || (hat & SDL_HAT_RIGHT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_RIGHT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].dpad_left) || (hat & SDL_HAT_LEFT)) // dpad
|
||||
{
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
PushFakeKey(SDLK_LEFT);
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].south_button)) // need this to be X button
|
||||
{
|
||||
PushFakeKey(SDLK_RETURN);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].quit_button) &&
|
||||
SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].hotkey_button)) // use the HOTKEY button
|
||||
{
|
||||
uae_quit();
|
||||
gui_running = false;
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].left_trigger))
|
||||
{
|
||||
ShowHelpRequested();
|
||||
widgets::cmdHelp->requestFocus();
|
||||
break;
|
||||
}
|
||||
if (SDL_JoystickGetButton(GUIjoy, host_input_buttons[0].menu_button)) // use the HOTKEY button
|
||||
{
|
||||
gui_running = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (gui_event.type == SDL_KEYDOWN)
|
||||
|
@ -562,9 +567,9 @@ namespace sdl
|
|||
#elif USE_SDL2
|
||||
case SDL_SCANCODE_F1:
|
||||
#endif
|
||||
ShowHelpRequested();
|
||||
widgets::cmdHelp->requestFocus();
|
||||
break;
|
||||
ShowHelpRequested();
|
||||
widgets::cmdHelp->requestFocus();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -584,7 +589,8 @@ namespace sdl
|
|||
|
||||
void gui_run()
|
||||
{
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
if (SDL_NumJoysticks() > 0)
|
||||
GUIjoy = SDL_JoystickOpen(0);
|
||||
|
||||
//-------------------------------------------------
|
||||
// The main loop
|
||||
|
@ -607,16 +613,17 @@ namespace sdl
|
|||
|
||||
if (refreshFuncAfterDraw != nullptr)
|
||||
{
|
||||
void (*currFunc)() = refreshFuncAfterDraw;
|
||||
void(*currFunc)() = refreshFuncAfterDraw;
|
||||
refreshFuncAfterDraw = nullptr;
|
||||
currFunc();
|
||||
}
|
||||
}
|
||||
SDL_JoystickClose(GUIjoy);
|
||||
|
||||
if (GUIjoy)
|
||||
SDL_JoystickClose(GUIjoy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace widgets
|
||||
{
|
||||
class MainButtonActionListener : public gcn::ActionListener
|
||||
|
@ -851,7 +858,7 @@ namespace widgets
|
|||
gui_top->add(cmdStart, GUI_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
|
||||
|
||||
gui_top->add(selectors, DISTANCE_BORDER + 1, DISTANCE_BORDER + 1);
|
||||
for (i = 0 , yPos = 0; categories[i].category != nullptr; ++i , yPos += 24)
|
||||
for (i = 0, yPos = 0; categories[i].category != nullptr; ++i, yPos += 24)
|
||||
{
|
||||
selectors->add(categories[i].selector, 0, yPos);
|
||||
gui_top->add(categories[i].panel, panelStartX, DISTANCE_BORDER + 1);
|
||||
|
@ -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(""));
|
||||
|
@ -953,7 +961,7 @@ void run_gui()
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Catch all GUI framework exceptions.
|
||||
catch (gcn::Exception e)
|
||||
{
|
||||
|
@ -967,14 +975,14 @@ void run_gui()
|
|||
cout << "Std exception: " << e.what() << endl;
|
||||
uae_quit();
|
||||
}
|
||||
|
||||
|
||||
// Catch all unknown exceptions.
|
||||
catch (...)
|
||||
{
|
||||
cout << "Unknown exception" << endl;
|
||||
uae_quit();
|
||||
}
|
||||
|
||||
|
||||
expansion_generate_autoconfig_info(&changed_prefs);
|
||||
cfgfile_compatibility_romtype(&changed_prefs);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue