UI: Move to ScreenManager for mapping.

Otherwise we'll detect repeated axis for some devices and you won't be
able to map what you want.
This commit is contained in:
Unknown W. Brackets committed 2021-05-23 15:18:21 -07:00
1 parent e1e5a8b49b
commit b0de7ee0e1
4 files changed
+16 -14

No files matched your search

+11
View File
@@ -106,6 +106,17 @@ bool ScreenManager::key(const KeyInput &key) {
bool ScreenManager::axis(const AxisInput &axis) {
std::lock_guard<std::recursive_mutex> guard(inputLock_);
// 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 false;
}
lastAxis_[key] = value;
bool result = false;
// Send center axis to every screen layer.
if (axis.value == 0) {
+5 -1
View File
@@ -13,9 +13,11 @@
#pragma once
#include <vector>
#include <cstdint>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "Common/Common.h"
#include "Common/Input/InputState.h"
@@ -165,4 +167,6 @@ private:
// Used for options, in-game menus and other things you expect to be able to back out from onto something.
std::vector<Layer> stack_;
std::vector<Layer> nextStack_;
std::unordered_map<int64_t, int> lastAxis_;
};
-10
View File
@@ -864,16 +864,6 @@ void EmuScreen::pspKey(int pspKeyCode, int flags) {
bool EmuScreen::axis(const AxisInput &axis) {
Core_NotifyActivity();
// 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 false;
}
lastAxis_[key] = value;
if (axis.value > 0) {
processAxis(axis, 1);
return true;
-3
View File
@@ -17,10 +17,8 @@
#pragma once
#include <cstdint>
#include <list>
#include <string>
#include <unordered_map>
#include <vector>
#include "Common/File/Path.h"
@@ -115,5 +113,4 @@ private:
bool autoRotatingAnalogCW_ = false;
bool autoRotatingAnalogCCW_ = false;
std::unordered_map<int64_t, int> lastAxis_;
};