Merge pull request #18368 from hrydgard/revert-joystick-change

Revert "Control: Remove the axis event dupe filtering from ScreenManager"
This commit is contained in:
Henrik Rydgård 2023-10-18 23:17:11 +02:00 committed by GitHub
commit e93f9f64cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,9 +119,28 @@ bool ScreenManager::key(const KeyInput &key) {
void ScreenManager::axis(const AxisInput *axes, size_t count) {
std::lock_guard<std::recursive_mutex> guard(inputLock_);
if (stack_.empty())
return;
stack_.back().screen->UnsyncAxis(axes, count);
for (size_t i = 0; i < count; i++) {
const AxisInput &axis = axes[i];
// Ignore duplicate values to prevent axis values overwriting each other.
uint64_t key = ((uint64_t)axis.axisId << 32) | axis.deviceId;
// Center value far from zero just to ensure we send the first zero.
// PSP games can't see higher resolution than this.
int value = 128 + ceilf(axis.value * 127.5f + 127.5f);
if (lastAxis_[key] == value) {
return;
}
lastAxis_[key] = value;
// Send center axis to every screen layer.
if (axis.value == 0) {
for (auto &layer : stack_) {
layer.screen->UnsyncAxis(&axis, 1);
}
} else if (!stack_.empty()) {
stack_.back().screen->UnsyncAxis(&axis, 1);
}
}
}
void ScreenManager::deviceLost() {