Don't need two SetCallback functions.

This commit is contained in:
Henrik Rydgård 2023-03-31 11:11:46 +02:00
parent 778d9ac5ca
commit 025ec248e4
4 changed files with 17 additions and 18 deletions

View File

@ -87,15 +87,13 @@ void ControlMapper::SetCallbacks(
std::function<void(int, float)> onVKeyAnalog,
std::function<void(uint32_t, uint32_t)> setAllPSPButtonStates,
std::function<void(int, bool)> setPSPButtonState,
std::function<void(int, float, float)> setPSPAnalog) {
std::function<void(int, float, float)> setPSPAnalog,
std::function<void(int, float, float)> setRawAnalog) {
onVKey_ = onVKey;
onVKeyAnalog_ = onVKeyAnalog;
setAllPSPButtonStates_ = setAllPSPButtonStates;
setPSPButtonState_ = setPSPButtonState;
setPSPAnalog_ = setPSPAnalog;
}
void ControlMapper::SetRawCallback(std::function<void(int, float, float)> setRawAnalog) {
setRawAnalog_ = setRawAnalog;
}

View File

@ -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<void(int, bool)> onVKey,
std::function<void(int, float)> onVKeyAnalog,
std::function<void(uint32_t, uint32_t)> setAllPSPButtonStates_,
std::function<void(int, bool)> setPSPButtonState,
std::function<void(int, float, float)> setPSPAnalog);
std::function<void(int, float, float)> setPSPAnalog,
std::function<void(int, float, float)> 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<void(int, float, float)> setRawAnalog);
private:
bool UpdatePSPState(const InputMapping &changedMapping);

View File

@ -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() {

View File

@ -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.