diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 601ffb2a73..724081a3ee 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -14,6 +14,8 @@ #include "Common/Math/lin/matrix4x4.h" #include "Core/HLE/sceDisplay.h" +#include "Core/HLE/sceCtrl.h" + #include "Core/Config.h" #include "Core/KeyMap.h" #include "Core/System.h" diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 9970c282e5..743c4f250f 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -4,6 +4,7 @@ #include "Common/TimeUtil.h" #include "Common/Log.h" +#include "Core/HLE/sceCtrl.h" #include "Core/KeyMap.h" #include "Core/ControlMapper.h" #include "Core/Config.h" @@ -40,9 +41,10 @@ void ConvertAnalogStick(float &x, float &y) { y = Clamp(y / norm * mappedNorm, -1.0f, 1.0f); } -void ControlMapper::SetCallbacks(std::function onVKeyDown, std::function onVKeyUp, std::function setPSPAnalog) { +void ControlMapper::SetCallbacks(std::function onVKeyDown, std::function onVKeyUp, std::function setPSPButtonState, std::function setPSPAnalog) { onVKeyDown_ = onVKeyDown; onVKeyUp_ = onVKeyUp; + setPSPButtonState_ = setPSPButtonState; setPSPAnalog_ = setPSPAnalog; } @@ -71,7 +73,6 @@ void ControlMapper::SetPSPAxis(int device, char axis, float value, int stick) { bool inDeadZone = fabsf(value) < g_Config.fAnalogDeadzone * 0.7f; bool ignore = false; - if (inDeadZone && lastNonDeadzoneDeviceID_[stick] != device) { // Ignore this event! See issue #15465 ignore = true; @@ -221,9 +222,9 @@ void ControlMapper::pspKey(int deviceId, int pspKeyCode, int flags) { } else { // INFO_LOG(SYSTEM, "pspKey %i %i", pspKeyCode, flags); if (flags & KEY_DOWN) - __CtrlButtonDown(pspKeyCode); + setPSPButtonState_(pspKeyCode, true); if (flags & KEY_UP) - __CtrlButtonUp(pspKeyCode); + setPSPButtonState_(pspKeyCode, false); } } @@ -301,12 +302,12 @@ void ControlMapper::onVKeyUp(int deviceId, int vkey) { case VIRTKEY_ANALOG_ROTATE_CW: autoRotatingAnalogCW_ = false; - __CtrlSetAnalogXY(0, 0.0f, 0.0f); + setPSPAnalog_(0, 0.0f, 0.0f); break; case VIRTKEY_ANALOG_ROTATE_CCW: autoRotatingAnalogCCW_ = false; - __CtrlSetAnalogXY(0, 0.0f, 0.0f); + setPSPAnalog_(0, 0.0f, 0.0f); break; default: diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index bc45007228..92f54c56f6 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -23,6 +23,7 @@ public: void SetCallbacks( std::function onVKeyDown, std::function onVKeyUp, + std::function setPSPButtonState, std::function setPSPAnalog); // Optional callback, only used in config @@ -53,6 +54,7 @@ private: bool autoRotatingAnalogCCW_ = false; // Callbacks + std::function setPSPButtonState_; std::function onVKeyDown_; std::function onVKeyUp_; std::function setPSPAnalog_; diff --git a/Core/ELF/PBPReader.h b/Core/ELF/PBPReader.h index ad84740e84..af322deb74 100644 --- a/Core/ELF/PBPReader.h +++ b/Core/ELF/PBPReader.h @@ -19,6 +19,7 @@ #pragma once #include + #include "Common/CommonTypes.h" #include "Common/Swap.h" diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index 6b072fadb3..df4097f01b 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -29,6 +29,7 @@ #include "Common/Log.h" #include "Common/StringUtils.h" #include "Core/HLE/sceUtility.h" +#include "Core/HLE/sceCtrl.h" // psp keys #include "Core/Config.h" #include "Core/KeyMap.h" #include "Core/KeyMapDefaults.h" diff --git a/Core/KeyMap.h b/Core/KeyMap.h index c81958ab26..5d4edd73ce 100644 --- a/Core/KeyMap.h +++ b/Core/KeyMap.h @@ -24,7 +24,6 @@ #include "Common/Input/InputState.h" // KeyDef #include "Common/Input/KeyCodes.h" // keyboard keys -#include "Core/HLE/sceCtrl.h" // psp keys #include "Core/KeyMapDefaults.h" #define KEYMAP_ERROR_KEY_ALREADY_USED -1 diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index b729fac4e9..7fdda9f568 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -448,7 +448,11 @@ void KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) { } AnalogSetupScreen::AnalogSetupScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { - mapper_.SetCallbacks([](int vkey) {}, [](int vkey) {}, [&](int stick, float x, float y) { + mapper_.SetCallbacks( + [](int vkey) {}, + [](int vkey) {}, + [&](int button, bool down) {}, + [&](int stick, float x, float y) { analogX_[stick] = x; analogY_[stick] = y; }); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 2eca633fa5..aed79db158 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -178,6 +178,13 @@ EmuScreen::EmuScreen(const Path &filename) controlMapper_.SetCallbacks( std::bind(&EmuScreen::onVKeyDown, this, _1), std::bind(&EmuScreen::onVKeyUp, this, _1), + [](int pspKey, bool down) { + if (down) { + __CtrlButtonDown(pspKey); + } else { + __CtrlButtonUp(pspKey); + } + }, &SetPSPAnalog); // Make sure we don't leave it at powerdown after the last game. diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index d839ec735f..9236038a68 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -23,6 +23,7 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Core/CoreParameter.h" +#include "Core/HLE/sceCtrl.h" #include "UI/EmuScreen.h" class GamepadView : public UI::View { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 68641be108..b67b8c6d1f 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -42,6 +42,7 @@ #include "Common/StringUtils.h" #include "Core/System.h" #include "Core/Reporting.h" +#include "Core/HLE/sceCtrl.h" #include "Core/ELF/PBPReader.h" #include "Core/ELF/ParamSFO.h" #include "Core/Util/GameManager.h"