mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add an option to ignore gamepads when not focused.
This commit is contained in:
parent
522f9fabd8
commit
cf88c7ff67
6 changed files with 22 additions and 1 deletions
|
@ -540,6 +540,7 @@ static ConfigSetting controlSettings[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ConfigSetting("DisableDpadDiagonals", &g_Config.bDisableDpadDiagonals, false, true, true),
|
ConfigSetting("DisableDpadDiagonals", &g_Config.bDisableDpadDiagonals, false, true, true),
|
||||||
|
ConfigSetting("GamepadOnlyFocused", &g_Config.bGamepadOnlyFocused, false, true, true),
|
||||||
ConfigSetting("TouchButtonStyle", &g_Config.iTouchButtonStyle, 1, true, true),
|
ConfigSetting("TouchButtonStyle", &g_Config.iTouchButtonStyle, 1, true, true),
|
||||||
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, true, true),
|
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, true, true),
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,7 @@ public:
|
||||||
|
|
||||||
// Disable diagonals
|
// Disable diagonals
|
||||||
bool bDisableDpadDiagonals;
|
bool bDisableDpadDiagonals;
|
||||||
|
bool bGamepadOnlyFocused;
|
||||||
// Control Style
|
// Control Style
|
||||||
int iTouchButtonStyle;
|
int iTouchButtonStyle;
|
||||||
// Control Positions
|
// Control Positions
|
||||||
|
|
|
@ -369,6 +369,10 @@ void GameSettingsScreen::CreateViews() {
|
||||||
controlsSettings->Add(new ItemHeader(ms->T("Controls")));
|
controlsSettings->Add(new ItemHeader(ms->T("Controls")));
|
||||||
controlsSettings->Add(new Choice(c->T("Control Mapping")))->OnClick.Handle(this, &GameSettingsScreen::OnControlMapping);
|
controlsSettings->Add(new Choice(c->T("Control Mapping")))->OnClick.Handle(this, &GameSettingsScreen::OnControlMapping);
|
||||||
|
|
||||||
|
#if defined(USING_WIN_UI)
|
||||||
|
controlsSettings->Add(new CheckBox(&g_Config.bGamepadOnlyFocused, c->T("Ignore gamepads when not focused")));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MOBILE_DEVICE)
|
#if defined(MOBILE_DEVICE)
|
||||||
controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, c->T("HapticFeedback", "Haptic Feedback (vibration)")));
|
controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, c->T("HapticFeedback", "Haptic Feedback (vibration)")));
|
||||||
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons"};
|
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons"};
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "input/input_state.h"
|
#include "input/input_state.h"
|
||||||
#include "thread/thread.h"
|
#include "thread/thread.h"
|
||||||
#include "thread/threadutil.h"
|
#include "thread/threadutil.h"
|
||||||
|
#include "Core/Config.h"
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
#include "Windows/InputDevice.h"
|
#include "Windows/InputDevice.h"
|
||||||
#include "Windows/XinputDevice.h"
|
#include "Windows/XinputDevice.h"
|
||||||
|
@ -33,6 +34,7 @@ static volatile bool inputThreadEnabled = false;
|
||||||
static std::thread *inputThread = NULL;
|
static std::thread *inputThread = NULL;
|
||||||
static recursive_mutex inputMutex;
|
static recursive_mutex inputMutex;
|
||||||
static condition_variable inputEndCond;
|
static condition_variable inputEndCond;
|
||||||
|
static bool focused = true;
|
||||||
|
|
||||||
extern InputState input_state;
|
extern InputState input_state;
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ inline static void ExecuteInputPoll() {
|
||||||
input_state.pad_lstick_y = 0;
|
input_state.pad_lstick_y = 0;
|
||||||
input_state.pad_rstick_x = 0;
|
input_state.pad_rstick_x = 0;
|
||||||
input_state.pad_rstick_y = 0;
|
input_state.pad_rstick_y = 0;
|
||||||
if (host) {
|
if (host && (focused || !g_Config.bGamepadOnlyFocused)) {
|
||||||
host->PollControllers(input_state);
|
host->PollControllers(input_state);
|
||||||
}
|
}
|
||||||
UpdateInputState(&input_state);
|
UpdateInputState(&input_state);
|
||||||
|
@ -87,3 +89,11 @@ void InputDevice::StopPolling() {
|
||||||
delete inputThread;
|
delete inputThread;
|
||||||
inputThread = NULL;
|
inputThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputDevice::GainFocus() {
|
||||||
|
focused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputDevice::LoseFocus() {
|
||||||
|
focused = false;
|
||||||
|
}
|
||||||
|
|
|
@ -32,4 +32,7 @@ public:
|
||||||
|
|
||||||
static void BeginPolling();
|
static void BeginPolling();
|
||||||
static void StopPolling();
|
static void StopPolling();
|
||||||
|
|
||||||
|
static void GainFocus();
|
||||||
|
static void LoseFocus();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1083,6 +1083,7 @@ namespace MainWindow
|
||||||
{
|
{
|
||||||
bool pause = true;
|
bool pause = true;
|
||||||
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
|
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
|
||||||
|
InputDevice::GainFocus();
|
||||||
g_activeWindow = WINDOW_MAINWINDOW;
|
g_activeWindow = WINDOW_MAINWINDOW;
|
||||||
pause = false;
|
pause = false;
|
||||||
}
|
}
|
||||||
|
@ -1097,6 +1098,7 @@ namespace MainWindow
|
||||||
|
|
||||||
if (wParam == WA_INACTIVE) {
|
if (wParam == WA_INACTIVE) {
|
||||||
WindowsRawInput::LoseFocus();
|
WindowsRawInput::LoseFocus();
|
||||||
|
InputDevice::LoseFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue