From 025ec248e46de6c3ab867c8763fc0b0194d7e5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 31 Mar 2023 11:11:46 +0200 Subject: [PATCH] Don't need two SetCallback functions. --- Core/ControlMapper.cpp | 6 ++---- Core/ControlMapper.h | 12 ++++++------ UI/ControlMappingScreen.cpp | 14 +++++++------- UI/EmuScreen.cpp | 3 ++- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index a61604e09c..ee512bc988 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -87,15 +87,13 @@ void ControlMapper::SetCallbacks( std::function onVKeyAnalog, std::function setAllPSPButtonStates, std::function setPSPButtonState, - std::function setPSPAnalog) { + std::function setPSPAnalog, + std::function setRawAnalog) { onVKey_ = onVKey; onVKeyAnalog_ = onVKeyAnalog; setAllPSPButtonStates_ = setAllPSPButtonStates; setPSPButtonState_ = setPSPButtonState; setPSPAnalog_ = setPSPAnalog; -} - -void ControlMapper::SetRawCallback(std::function setRawAnalog) { setRawAnalog_ = setRawAnalog; } diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index 9d116d5517..878e2eade9 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -18,21 +18,21 @@ public: bool Key(const KeyInput &key, bool *pauseTrigger); void Axis(const AxisInput &axis); - // Required callbacks + // Required callbacks. + // TODO: These are so many now that a virtual interface might be more appropriate.. void SetCallbacks( std::function onVKey, std::function onVKeyAnalog, std::function setAllPSPButtonStates_, std::function setPSPButtonState, - std::function setPSPAnalog); + std::function setPSPAnalog, + std::function setRawAnalog); // Inject raw PSP key input directly, such as from touch screen controls. - // Combined with the mapped input. + // Combined with the mapped input. Unlike __Ctrl APIs, this supports + // virtual key codes, though not analog mappings. void PSPKey(int deviceId, int pspKeyCode, int flags); - // Optional callback, only used in config - void SetRawCallback(std::function setRawAnalog); - private: bool UpdatePSPState(const InputMapping &changedMapping); diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 8aad793e0d..badf788125 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -454,13 +454,13 @@ AnalogSetupScreen::AnalogSetupScreen(const Path &gamePath) : UIDialogScreenWithG [&](uint32_t bitsToSet, uint32_t bitsToClear) {}, [&](int button, bool down) {}, [&](int stick, float x, float y) { - analogX_[stick] = x; - analogY_[stick] = y; - }); - mapper_.SetRawCallback([&](int stick, float x, float y) { - rawX_[stick] = x; - rawY_[stick] = y; - }); + analogX_[stick] = x; + analogY_[stick] = y; + }, + [&](int stick, float x, float y) { + rawX_[stick] = x; + rawY_[stick] = y; + }); } void AnalogSetupScreen::update() { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 5868ae079a..d7c1102c04 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -188,7 +188,8 @@ EmuScreen::EmuScreen(const Path &filename) __CtrlButtonUp(pspButton); } }, - &SetPSPAnalog); + &SetPSPAnalog, + nullptr); // Make sure we don't leave it at powerdown after the last game. // TODO: This really should be handled elsewhere if it isn't.