diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 2847feb204..b1e4189b95 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -71,7 +71,7 @@ void ControlMapper::SetCallbacks( std::function setPSPButtonState, std::function setPSPAnalog) { onVKey_ = onVKey; - onVKeyAnalog_ = onVKey; + onVKeyAnalog_ = onVKeyAnalog; setAllPSPButtonStates_ = setAllPSPButtonStates; setPSPButtonState_ = setPSPButtonState; setPSPAnalog_ = setPSPAnalog; @@ -113,12 +113,9 @@ void ControlMapper::SetPSPAxis(int device, int stick, char axis, float value) { if (!ignore) { history_[stick][axisId] = value; - - float x = history_[stick][0]; - float y = history_[stick][1]; - float convertedX, convertedY; - ConvertAnalogStick(x, y, &convertedX, &convertedY); - setPSPAnalog_(stick, convertedX, convertedY); + float x, y; + ConvertAnalogStick(history_[stick][0], history_[stick][1], &x, &y); + setPSPAnalog_(stick, x, y); } } @@ -187,13 +184,13 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping) { std::vector inputMappings; if (!KeyMap::InputMappingsFromPspButton(vkId, &inputMappings, false)) continue; - float value = 0.0f; // If a mapping could consist of a combo, we could trivially check it here. // Save the first device ID so we can pass it into onVKeyDown, which in turn needs it for the analog // mapping which gets a little hacky. float threshold = 1.0f; bool touchedByMapping = false; + float value = 0.0f; for (auto &mapping : inputMappings) { if (mapping == changedMapping) { touchedByMapping = true; @@ -203,10 +200,8 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping) { if (iter != curInput_.end()) { if (mapping.IsAxis()) { threshold = GetDeviceAxisThreshold(iter->first.deviceId); - value += iter->second; - } else { - value += iter->second; } + value += iter->second; } } @@ -222,11 +217,13 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping) { if (virtKeys_[i] != value) { // INFO_LOG(G3D, "vkeyanalog %s : %f", KeyMap::GetVirtKeyName(vkId), value); onVKeyAnalog(changedMapping.deviceId, vkId, value); + virtKeys_[i] = value; } - virtKeys_[i] = value; if (!bPrevValue && bValue) { + // INFO_LOG(G3D, "vkeyon %s", KeyMap::GetVirtKeyName(vkId)); onVKey(vkId, true); } else if (bPrevValue && !bValue) { + // INFO_LOG(G3D, "vkeyoff %s", KeyMap::GetVirtKeyName(vkId)); onVKey(vkId, false); } } diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index 17b6fb5bfa..300f9bb81e 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -44,9 +44,6 @@ private: // To track mappable virtual keys. We can have as many as we want. float virtKeys_[VIRTKEY_COUNT]{}; - // De-noise mapped axis updates - int axisState_[JOYSTICK_AXIS_MAX]{}; - int lastNonDeadzoneDeviceID_[2]{}; float history_[2][2]{}; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 74bc85fc33..3781180c05 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -177,7 +177,7 @@ EmuScreen::EmuScreen(const Path &filename) startDumping = false; controlMapper_.SetCallbacks( std::bind(&EmuScreen::onVKey, this, _1, _2), - [](int vkey, float analogValue) {}, + std::bind(&EmuScreen::onVKeyAnalog, this, _1, _2), [](uint32_t bitsToSet, uint32_t bitsToClear) { __CtrlSetAllButtons(bitsToSet, bitsToClear); }, @@ -763,6 +763,10 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) { } } +void EmuScreen::onVKeyAnalog(int virtualKeyCode, float value) { + +} + bool EmuScreen::key(const KeyInput &key) { Core_NotifyActivity(); diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index ebb7800b4c..a7ee1c23af 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -69,6 +69,7 @@ private: void renderUI(); void onVKey(int virtualKeyCode, bool down); + void onVKeyAnalog(int virtualKeyCode, float value); void autoLoad(); void checkPowerDown();