mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Input event and device enums (#17514)
* Switch deviceID from int to enum InputDeviceID, globally * Switch axisId to enum InputAxis * Change int keycodes to InputKeyCode where it makes sense. * SDL input buildfix * SDL keycode buildfix * Switch on enum warning fixes * Qt keycode buildfix * iOS keycode buildfix * UWP keycode buildfix * More iOS buildfix * More iOS buildfix * Update DinputDevice.cpp
This commit is contained in:
1 parent
6f380a7a0a
commit
2675d6ea43
32 files changed
+129
-133
No files matched your search
@@ -39,7 +39,7 @@ std::vector<InputMapping> confirmKeys;
|
||||
std::vector<InputMapping> cancelKeys;
|
||||
std::vector<InputMapping> tabLeftKeys;
|
||||
std::vector<InputMapping> tabRightKeys;
|
||||
static std::unordered_map<int, int> uiFlipAnalogY;
|
||||
static std::unordered_map<InputDeviceID, int> uiFlipAnalogY;
|
||||
|
||||
static void AppendKeys(std::vector<InputMapping> &keys, const std::vector<InputMapping> &newKeys) {
|
||||
for (auto iter = newKeys.begin(); iter != newKeys.end(); ++iter) {
|
||||
@@ -69,11 +69,11 @@ void SetTabLeftRightKeys(const std::vector<InputMapping> &tabLeft, const std::ve
|
||||
tabRightKeys = tabRight;
|
||||
}
|
||||
|
||||
void SetAnalogFlipY(std::unordered_map<int, int> flipYByDeviceId) {
|
||||
void SetAnalogFlipY(std::unordered_map<InputDeviceID, int> flipYByDeviceId) {
|
||||
uiFlipAnalogY = flipYByDeviceId;
|
||||
}
|
||||
|
||||
int GetAnalogYDirection(int deviceId) {
|
||||
int GetAnalogYDirection(InputDeviceID deviceId) {
|
||||
auto configured = uiFlipAnalogY.find(deviceId);
|
||||
if (configured != uiFlipAnalogY.end())
|
||||
return configured->second;
|
||||
@@ -84,8 +84,8 @@ int GetAnalogYDirection(int deviceId) {
|
||||
InputMapping InputMapping::FromConfigString(const std::string &str) {
|
||||
std::vector<std::string> parts;
|
||||
SplitString(str, '-', parts);
|
||||
int deviceId = atoi(parts[0].c_str());
|
||||
int keyCode = atoi(parts[1].c_str());
|
||||
InputDeviceID deviceId = (InputDeviceID)(atoi(parts[0].c_str()));
|
||||
InputKeyCode keyCode = (InputKeyCode)atoi(parts[1].c_str());
|
||||
|
||||
InputMapping mapping;
|
||||
mapping.deviceId = deviceId;
|
||||
@@ -94,15 +94,15 @@ InputMapping InputMapping::FromConfigString(const std::string &str) {
|
||||
}
|
||||
|
||||
std::string InputMapping::ToConfigString() const {
|
||||
return StringFromFormat("%d-%d", deviceId, keyCode);
|
||||
return StringFromFormat("%d-%d", (int)deviceId, keyCode);
|
||||
}
|
||||
|
||||
void InputMapping::FormatDebug(char *buffer, size_t bufSize) const {
|
||||
if (IsAxis()) {
|
||||
int direction;
|
||||
int axis = Axis(&direction);
|
||||
snprintf(buffer, bufSize, "Device: %d Axis: %d (%d)", deviceId, axis, direction);
|
||||
snprintf(buffer, bufSize, "Device: %d Axis: %d (%d)", (int)deviceId, axis, direction);
|
||||
} else {
|
||||
snprintf(buffer, bufSize, "Device: %d Key: %d", deviceId, keyCode);
|
||||
snprintf(buffer, bufSize, "Device: %d Key: %d", (int)deviceId, keyCode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user