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");
|
wxDialog* dlg = GetXRCDialog("JoypadConfig");
|
||||||
joy.Add();
|
joy.Add();
|
||||||
|
|
||||||
|
auto frame = wxGetApp().frame;
|
||||||
|
bool joy_timer = frame->IsJoyPollTimerRunning();
|
||||||
|
|
||||||
|
if (!joy_timer) frame->StartJoyPollTimer();
|
||||||
|
|
||||||
if (ShowModal(dlg) == wxID_OK)
|
if (ShowModal(dlg) == wxID_OK)
|
||||||
update_opts();
|
update_opts();
|
||||||
|
|
||||||
|
if (!joy_timer) frame->StopJoyPollTimer();
|
||||||
|
|
||||||
SetJoystick();
|
SetJoystick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2719,9 +2726,16 @@ EVT_HANDLER(Customize, "Customize UI...")
|
||||||
wxDialog* dlg = GetXRCDialog("AccelConfig");
|
wxDialog* dlg = GetXRCDialog("AccelConfig");
|
||||||
joy.Add();
|
joy.Add();
|
||||||
|
|
||||||
|
auto frame = wxGetApp().frame;
|
||||||
|
bool joy_timer = frame->IsJoyPollTimerRunning();
|
||||||
|
|
||||||
|
if (!joy_timer) frame->StartJoyPollTimer();
|
||||||
|
|
||||||
if (ShowModal(dlg) == wxID_OK)
|
if (ShowModal(dlg) == wxID_OK)
|
||||||
update_opts();
|
update_opts();
|
||||||
|
|
||||||
|
if (!joy_timer) frame->StopJoyPollTimer();
|
||||||
|
|
||||||
SetJoystick();
|
SetJoystick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,15 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#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/dcbuffer.h>
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
#include <SDL_joystick.h>
|
#include <SDL_joystick.h>
|
||||||
|
@ -319,7 +328,7 @@ void GameArea::LoadGame(const wxString& name)
|
||||||
emulating = true;
|
emulating = true;
|
||||||
was_paused = true;
|
was_paused = true;
|
||||||
MainFrame* mf = wxGetApp().frame;
|
MainFrame* mf = wxGetApp().frame;
|
||||||
mf->StopPoll();
|
mf->StopJoyPollTimer();
|
||||||
mf->SetJoystick();
|
mf->SetJoystick();
|
||||||
mf->cmd_enable &= ~(CMDEN_GB | CMDEN_GBA);
|
mf->cmd_enable &= ~(CMDEN_GB | CMDEN_GBA);
|
||||||
mf->cmd_enable |= ONLOAD_CMDEN;
|
mf->cmd_enable |= ONLOAD_CMDEN;
|
||||||
|
@ -570,7 +579,7 @@ void GameArea::UnloadGame(bool destruct)
|
||||||
mf->enable_menus();
|
mf->enable_menus();
|
||||||
mf->SetJoystick();
|
mf->SetJoystick();
|
||||||
mf->ResetCheatSearch();
|
mf->ResetCheatSearch();
|
||||||
mf->StartPoll();
|
mf->StartJoyPollTimer();
|
||||||
|
|
||||||
if (rewind_mem)
|
if (rewind_mem)
|
||||||
num_rewind_states = 0;
|
num_rewind_states = 0;
|
||||||
|
@ -1374,14 +1383,6 @@ void GameArea::OnSize(wxSizeEvent& ev)
|
||||||
ev.Skip();
|
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)
|
void GameArea::OnSDLJoy(wxSDLJoyEvent& ev)
|
||||||
{
|
{
|
||||||
int key = ev.GetControlIndex();
|
int key = ev.GetControlIndex();
|
||||||
|
|
|
@ -929,18 +929,23 @@ void MainFrame::SetJoystick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::StopPoll()
|
void MainFrame::StopJoyPollTimer()
|
||||||
{
|
{
|
||||||
if (jpoll && jpoll->IsRunning())
|
if (jpoll && jpoll->IsRunning())
|
||||||
jpoll->Stop();
|
jpoll->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::StartPoll()
|
void MainFrame::StartJoyPollTimer()
|
||||||
{
|
{
|
||||||
if (jpoll && !jpoll->IsRunning())
|
if (jpoll && !jpoll->IsRunning())
|
||||||
jpoll->Start();
|
jpoll->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainFrame::IsJoyPollTimerRunning()
|
||||||
|
{
|
||||||
|
return jpoll->IsRunning();
|
||||||
|
}
|
||||||
|
|
||||||
void MainFrame::enable_menus()
|
void MainFrame::enable_menus()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ncmds; i++)
|
for (int i = 0; i < ncmds; i++)
|
||||||
|
|
|
@ -323,9 +323,10 @@ public:
|
||||||
|
|
||||||
void PollJoysticks() { joy.Poll(); }
|
void PollJoysticks() { joy.Poll(); }
|
||||||
|
|
||||||
// poll joysticks with timer
|
// Poll joysticks with timer.
|
||||||
void StopPoll();
|
void StartJoyPollTimer();
|
||||||
void StartPoll();
|
void StopJoyPollTimer();
|
||||||
|
bool IsJoyPollTimerRunning();
|
||||||
|
|
||||||
// required for building from xrc
|
// required for building from xrc
|
||||||
DECLARE_DYNAMIC_CLASS(MainFrame);
|
DECLARE_DYNAMIC_CLASS(MainFrame);
|
||||||
|
|
Loading…
Reference in New Issue