Fix joystick config when game is loaded.
Rename the joystick polling timer accessors and add a predicate. Check it and make sure the timer is running in the input and accelerator config dialogs. - Fix #711. - Fix #716. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
61a726a828
commit
378c9493e9
|
@ -2708,9 +2708,16 @@ EVT_HANDLER(JoypadConfigure, "Joypad options...")
|
|||
wxDialog* dlg = GetXRCDialog("JoypadConfig");
|
||||
joy.Add();
|
||||
|
||||
auto frame = wxGetApp().frame;
|
||||
bool joy_timer = frame->IsJoyPollTimerRunning();
|
||||
|
||||
if (!joy_timer) frame->StartJoyPollTimer();
|
||||
|
||||
if (ShowModal(dlg) == wxID_OK)
|
||||
update_opts();
|
||||
|
||||
if (!joy_timer) frame->StopJoyPollTimer();
|
||||
|
||||
SetJoystick();
|
||||
}
|
||||
|
||||
|
@ -2719,9 +2726,16 @@ EVT_HANDLER(Customize, "Customize UI...")
|
|||
wxDialog* dlg = GetXRCDialog("AccelConfig");
|
||||
joy.Add();
|
||||
|
||||
auto frame = wxGetApp().frame;
|
||||
bool joy_timer = frame->IsJoyPollTimerRunning();
|
||||
|
||||
if (!joy_timer) frame->StartJoyPollTimer();
|
||||
|
||||
if (ShowModal(dlg) == wxID_OK)
|
||||
update_opts();
|
||||
|
||||
if (!joy_timer) frame->StopJoyPollTimer();
|
||||
|
||||
SetJoystick();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__WXGTK__) && defined(HAVE_XSS)
|
||||
#include <X11/Xlib.h>
|
||||
#define Status int
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
#include <wx/dcbuffer.h>
|
||||
#include <wx/menu.h>
|
||||
#include <SDL_joystick.h>
|
||||
|
@ -319,7 +328,7 @@ void GameArea::LoadGame(const wxString& name)
|
|||
emulating = true;
|
||||
was_paused = true;
|
||||
MainFrame* mf = wxGetApp().frame;
|
||||
mf->StopPoll();
|
||||
mf->StopJoyPollTimer();
|
||||
mf->SetJoystick();
|
||||
mf->cmd_enable &= ~(CMDEN_GB | CMDEN_GBA);
|
||||
mf->cmd_enable |= ONLOAD_CMDEN;
|
||||
|
@ -570,7 +579,7 @@ void GameArea::UnloadGame(bool destruct)
|
|||
mf->enable_menus();
|
||||
mf->SetJoystick();
|
||||
mf->ResetCheatSearch();
|
||||
mf->StartPoll();
|
||||
mf->StartJoyPollTimer();
|
||||
|
||||
if (rewind_mem)
|
||||
num_rewind_states = 0;
|
||||
|
@ -1374,14 +1383,6 @@ void GameArea::OnSize(wxSizeEvent& ev)
|
|||
ev.Skip();
|
||||
}
|
||||
|
||||
#if defined(__WXGTK__) && defined(HAVE_XSS)
|
||||
#include <X11/Xlib.h>
|
||||
#define Status int
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
void GameArea::OnSDLJoy(wxSDLJoyEvent& ev)
|
||||
{
|
||||
int key = ev.GetControlIndex();
|
||||
|
|
|
@ -929,18 +929,23 @@ void MainFrame::SetJoystick()
|
|||
}
|
||||
}
|
||||
|
||||
void MainFrame::StopPoll()
|
||||
void MainFrame::StopJoyPollTimer()
|
||||
{
|
||||
if (jpoll && jpoll->IsRunning())
|
||||
jpoll->Stop();
|
||||
}
|
||||
|
||||
void MainFrame::StartPoll()
|
||||
void MainFrame::StartJoyPollTimer()
|
||||
{
|
||||
if (jpoll && !jpoll->IsRunning())
|
||||
jpoll->Start();
|
||||
}
|
||||
|
||||
bool MainFrame::IsJoyPollTimerRunning()
|
||||
{
|
||||
return jpoll->IsRunning();
|
||||
}
|
||||
|
||||
void MainFrame::enable_menus()
|
||||
{
|
||||
for (int i = 0; i < ncmds; i++)
|
||||
|
|
|
@ -323,9 +323,10 @@ public:
|
|||
|
||||
void PollJoysticks() { joy.Poll(); }
|
||||
|
||||
// poll joysticks with timer
|
||||
void StopPoll();
|
||||
void StartPoll();
|
||||
// Poll joysticks with timer.
|
||||
void StartJoyPollTimer();
|
||||
void StopJoyPollTimer();
|
||||
bool IsJoyPollTimerRunning();
|
||||
|
||||
// required for building from xrc
|
||||
DECLARE_DYNAMIC_CLASS(MainFrame);
|
||||
|
|
Loading…
Reference in New Issue