DolphinWX: fix input bitmaps not working when background input is off

This commit is contained in:
Michael Maltese 2017-07-12 00:11:29 -07:00
parent ab5a5ee3ea
commit 0019c34c73
14 changed files with 53 additions and 8 deletions

View File

@ -125,7 +125,7 @@ void Host_SetStartupDebuggingParameters()
{ {
} }
bool Host_UIHasFocus() bool Host_UINeedsControllerState()
{ {
return true; return true;
} }

View File

@ -23,7 +23,7 @@
// The host can be just a command line app that opens a window, or a full blown debugger // The host can be just a command line app that opens a window, or a full blown debugger
// interface. // interface.
bool Host_UIHasFocus(); bool Host_UINeedsControllerState();
bool Host_RendererHasFocus(); bool Host_RendererHasFocus();
bool Host_RendererIsFullscreen(); bool Host_RendererIsFullscreen();
void Host_ConnectWiimote(int wm_idx, bool connect); void Host_ConnectWiimote(int wm_idx, bool connect);

View File

@ -116,7 +116,7 @@ void Host_RequestRenderWindowSize(int width, int height)
{ {
} }
bool Host_UIHasFocus() bool Host_UINeedsControllerState()
{ {
return false; return false;
} }

View File

@ -103,7 +103,7 @@ void Host_UpdateMainFrame()
void Host_RequestRenderWindowSize(int w, int h) void Host_RequestRenderWindowSize(int w, int h)
{ {
} }
bool Host_UIHasFocus() bool Host_UINeedsControllerState()
{ {
return false; return false;
} }

View File

@ -78,6 +78,7 @@ set(SRCS
PostProcessingConfigDiag.cpp PostProcessingConfigDiag.cpp
SoftwareVideoConfigDialog.cpp SoftwareVideoConfigDialog.cpp
TASInputDlg.cpp TASInputDlg.cpp
UINeedsControllerState.cpp
VideoConfigDiag.cpp VideoConfigDiag.cpp
WxEventUtils.cpp WxEventUtils.cpp
WxUtils.cpp WxUtils.cpp

View File

@ -125,6 +125,7 @@
<ClCompile Include="PatchAddEdit.cpp" /> <ClCompile Include="PatchAddEdit.cpp" />
<ClCompile Include="SoftwareVideoConfigDialog.cpp" /> <ClCompile Include="SoftwareVideoConfigDialog.cpp" />
<ClCompile Include="TASInputDlg.cpp" /> <ClCompile Include="TASInputDlg.cpp" />
<ClCompile Include="UINeedsControllerState.cpp" />
<ClCompile Include="VideoConfigDiag.cpp" /> <ClCompile Include="VideoConfigDiag.cpp" />
<ClCompile Include="PostProcessingConfigDiag.cpp" /> <ClCompile Include="PostProcessingConfigDiag.cpp" />
<ClCompile Include="ControllerConfigDiag.cpp" /> <ClCompile Include="ControllerConfigDiag.cpp" />
@ -203,6 +204,7 @@
<ClInclude Include="PatchAddEdit.h" /> <ClInclude Include="PatchAddEdit.h" />
<ClInclude Include="SoftwareVideoConfigDialog.h" /> <ClInclude Include="SoftwareVideoConfigDialog.h" />
<ClInclude Include="TASInputDlg.h" /> <ClInclude Include="TASInputDlg.h" />
<ClInclude Include="UINeedsControllerState.h" />
<ClInclude Include="VideoConfigDiag.h" /> <ClInclude Include="VideoConfigDiag.h" />
<ClInclude Include="PostProcessingConfigDiag.h" /> <ClInclude Include="PostProcessingConfigDiag.h" />
<ClInclude Include="ControllerConfigDiag.h" /> <ClInclude Include="ControllerConfigDiag.h" />

View File

@ -196,6 +196,9 @@
<ClCompile Include="TASInputDlg.cpp"> <ClCompile Include="TASInputDlg.cpp">
<Filter>GUI</Filter> <Filter>GUI</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="UINeedsControllerState.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="SoftwareVideoConfigDialog.cpp"> <ClCompile Include="SoftwareVideoConfigDialog.cpp">
<Filter>GUI\Video</Filter> <Filter>GUI\Video</Filter>
</ClCompile> </ClCompile>
@ -420,6 +423,9 @@
<ClInclude Include="TASInputDlg.h"> <ClInclude Include="TASInputDlg.h">
<Filter>GUI</Filter> <Filter>GUI</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="UINeedsControllerState.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="SoftwareVideoConfigDialog.h"> <ClInclude Include="SoftwareVideoConfigDialog.h">
<Filter>GUI\Video</Filter> <Filter>GUI\Video</Filter>
</ClInclude> </ClInclude>

View File

@ -55,6 +55,7 @@
#include "DolphinWX/Input/GuitarInputConfigDiag.h" #include "DolphinWX/Input/GuitarInputConfigDiag.h"
#include "DolphinWX/Input/NunchukInputConfigDiag.h" #include "DolphinWX/Input/NunchukInputConfigDiag.h"
#include "DolphinWX/Input/TurntableInputConfigDiag.h" #include "DolphinWX/Input/TurntableInputConfigDiag.h"
#include "DolphinWX/UINeedsControllerState.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
#include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControlReference/ControlReference.h"
@ -1259,6 +1260,7 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config
{ {
Bind(wxEVT_CLOSE_WINDOW, &InputConfigDialog::OnClose, this); Bind(wxEVT_CLOSE_WINDOW, &InputConfigDialog::OnClose, this);
Bind(wxEVT_BUTTON, &InputConfigDialog::OnCloseButton, this, wxID_CLOSE); Bind(wxEVT_BUTTON, &InputConfigDialog::OnCloseButton, this, wxID_CLOSE);
Bind(wxEVT_ACTIVATE, &InputConfigDialog::OnActivate, this);
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED); SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER); SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
@ -1269,6 +1271,12 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config
m_update_timer.Start(PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS); m_update_timer.Start(PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS);
} }
void InputConfigDialog::OnActivate(wxActivateEvent& event)
{
// Needed for input bitmaps
SetUINeedsControllerState(event.GetActive());
}
InputEventFilter::InputEventFilter() InputEventFilter::InputEventFilter()
{ {
wxEvtHandler::AddFilter(this); wxEvtHandler::AddFilter(this);

View File

@ -191,6 +191,7 @@ public:
const int port_num = 0); const int port_num = 0);
virtual ~InputConfigDialog() = default; virtual ~InputConfigDialog() = default;
void OnActivate(wxActivateEvent& event);
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnCloseButton(wxCommandEvent& event); void OnCloseButton(wxCommandEvent& event);

View File

@ -47,6 +47,7 @@
#include "DolphinWX/Main.h" #include "DolphinWX/Main.h"
#include "DolphinWX/NetPlay/NetWindow.h" #include "DolphinWX/NetPlay/NetWindow.h"
#include "DolphinWX/SoftwareVideoConfigDialog.h" #include "DolphinWX/SoftwareVideoConfigDialog.h"
#include "DolphinWX/UINeedsControllerState.h"
#include "DolphinWX/VideoConfigDiag.h" #include "DolphinWX/VideoConfigDiag.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
@ -486,9 +487,9 @@ void Host_SetWiiMoteConnectionState(int _State)
main_frame->GetEventHandler()->AddPendingEvent(event); main_frame->GetEventHandler()->AddPendingEvent(event);
} }
bool Host_UIHasFocus() bool Host_UINeedsControllerState()
{ {
return wxGetApp().IsActiveThreadsafe(); return wxGetApp().IsActiveThreadsafe() && GetUINeedsControllerState();
} }
bool Host_RendererHasFocus() bool Host_RendererHasFocus()

View File

@ -0,0 +1,17 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <atomic>
static std::atomic<bool> s_needs_controller_state{false};
void SetUINeedsControllerState(bool needs_controller_state)
{
s_needs_controller_state = needs_controller_state;
}
bool GetUINeedsControllerState()
{
return s_needs_controller_state;
}

View File

@ -0,0 +1,8 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
void SetUINeedsControllerState(bool needs_controller_state);
bool GetUINeedsControllerState();

View File

@ -17,7 +17,8 @@ constexpr ControlState INPUT_DETECT_THRESHOLD = 0.55;
bool ControlReference::InputGateOn() bool ControlReference::InputGateOn()
{ {
return SConfig::GetInstance().m_BackgroundInput || Host_RendererHasFocus(); return SConfig::GetInstance().m_BackgroundInput || Host_RendererHasFocus() ||
Host_UINeedsControllerState();
} }
// //

View File

@ -39,7 +39,7 @@ void Host_RequestRenderWindowSize(int, int)
void Host_SetStartupDebuggingParameters() void Host_SetStartupDebuggingParameters()
{ {
} }
bool Host_UIHasFocus() bool Host_UINeedsControllerState()
{ {
return false; return false;
} }