mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-02 03:32:17 +00:00
Add an option to ignore gamepads when not focused.
This commit is contained in:
parent
522f9fabd8
commit
cf88c7ff67
@ -540,6 +540,7 @@ static ConfigSetting controlSettings[] = {
|
||||
#endif
|
||||
|
||||
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("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, true, true),
|
||||
|
||||
|
@ -234,6 +234,7 @@ public:
|
||||
|
||||
// Disable diagonals
|
||||
bool bDisableDpadDiagonals;
|
||||
bool bGamepadOnlyFocused;
|
||||
// Control Style
|
||||
int iTouchButtonStyle;
|
||||
// Control Positions
|
||||
|
@ -369,6 +369,10 @@ void GameSettingsScreen::CreateViews() {
|
||||
controlsSettings->Add(new ItemHeader(ms->T("Controls")));
|
||||
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)
|
||||
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"};
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "input/input_state.h"
|
||||
#include "thread/thread.h"
|
||||
#include "thread/threadutil.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Windows/InputDevice.h"
|
||||
#include "Windows/XinputDevice.h"
|
||||
@ -33,6 +34,7 @@ static volatile bool inputThreadEnabled = false;
|
||||
static std::thread *inputThread = NULL;
|
||||
static recursive_mutex inputMutex;
|
||||
static condition_variable inputEndCond;
|
||||
static bool focused = true;
|
||||
|
||||
extern InputState input_state;
|
||||
|
||||
@ -46,7 +48,7 @@ inline static void ExecuteInputPoll() {
|
||||
input_state.pad_lstick_y = 0;
|
||||
input_state.pad_rstick_x = 0;
|
||||
input_state.pad_rstick_y = 0;
|
||||
if (host) {
|
||||
if (host && (focused || !g_Config.bGamepadOnlyFocused)) {
|
||||
host->PollControllers(input_state);
|
||||
}
|
||||
UpdateInputState(&input_state);
|
||||
@ -87,3 +89,11 @@ void InputDevice::StopPolling() {
|
||||
delete inputThread;
|
||||
inputThread = NULL;
|
||||
}
|
||||
|
||||
void InputDevice::GainFocus() {
|
||||
focused = true;
|
||||
}
|
||||
|
||||
void InputDevice::LoseFocus() {
|
||||
focused = false;
|
||||
}
|
||||
|
@ -32,4 +32,7 @@ public:
|
||||
|
||||
static void BeginPolling();
|
||||
static void StopPolling();
|
||||
|
||||
static void GainFocus();
|
||||
static void LoseFocus();
|
||||
};
|
||||
|
@ -1083,6 +1083,7 @@ namespace MainWindow
|
||||
{
|
||||
bool pause = true;
|
||||
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
|
||||
InputDevice::GainFocus();
|
||||
g_activeWindow = WINDOW_MAINWINDOW;
|
||||
pause = false;
|
||||
}
|
||||
@ -1097,6 +1098,7 @@ namespace MainWindow
|
||||
|
||||
if (wParam == WA_INACTIVE) {
|
||||
WindowsRawInput::LoseFocus();
|
||||
InputDevice::LoseFocus();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user