mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 09:35:09 +02: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:
+10
-9
@@ -45,8 +45,8 @@ KeyMapping g_controllerMap;
|
||||
// Incremented on modification, so we know when to update menus.
|
||||
int g_controllerMapGeneration = 0;
|
||||
std::set<std::string> g_seenPads;
|
||||
std::map<int, std::string> g_padNames;
|
||||
std::set<int> g_seenDeviceIds;
|
||||
std::map<InputDeviceID, std::string> g_padNames;
|
||||
std::set<InputDeviceID> g_seenDeviceIds;
|
||||
|
||||
// Utility for UI navigation
|
||||
void SingleInputMappingFromPspButton(int btn, std::vector<InputMapping> *mappings, bool ignoreMouse) {
|
||||
@@ -120,8 +120,8 @@ void UpdateNativeMenuKeys() {
|
||||
SetConfirmCancelKeys(confirmKeys, cancelKeys);
|
||||
SetTabLeftRightKeys(tabLeft, tabRight);
|
||||
|
||||
std::unordered_map<int, int> flipYByDeviceId;
|
||||
for (int deviceId : g_seenDeviceIds) {
|
||||
std::unordered_map<InputDeviceID, int> flipYByDeviceId;
|
||||
for (InputDeviceID deviceId : g_seenDeviceIds) {
|
||||
auto analogs = MappedAxesForDevice(deviceId);
|
||||
flipYByDeviceId[deviceId] = analogs.leftY.direction;
|
||||
}
|
||||
@@ -441,6 +441,7 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
||||
{CTRL_NOTE, "Note"},
|
||||
};
|
||||
|
||||
// key here can be other things than InputKeyCode.
|
||||
static std::string FindName(int key, const KeyMap_IntStrPair list[], size_t size) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (list[i].key == key)
|
||||
@@ -449,7 +450,7 @@ static std::string FindName(int key, const KeyMap_IntStrPair list[], size_t size
|
||||
return StringFromFormat("%02x?", key);
|
||||
}
|
||||
|
||||
std::string GetKeyName(int keyCode) {
|
||||
std::string GetKeyName(InputKeyCode keyCode) {
|
||||
return FindName(keyCode, key_names, ARRAY_SIZE(key_names));
|
||||
}
|
||||
|
||||
@@ -532,7 +533,7 @@ bool PspButtonHasMappings(int btn) {
|
||||
return !iter->second.empty();
|
||||
}
|
||||
|
||||
MappedAnalogAxes MappedAxesForDevice(int deviceId) {
|
||||
MappedAnalogAxes MappedAxesForDevice(InputDeviceID deviceId) {
|
||||
MappedAnalogAxes result{};
|
||||
|
||||
// Find the axisId mapped for a specific virtual button.
|
||||
@@ -578,7 +579,7 @@ void RemoveButtonMapping(int btn) {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsKeyMapped(int device, int key) {
|
||||
bool IsKeyMapped(InputDeviceID device, int key) {
|
||||
std::lock_guard<std::recursive_mutex> guard(g_controllerMapLock);
|
||||
for (auto &iter : g_controllerMap) {
|
||||
for (auto &mappedKey : iter.second) {
|
||||
@@ -778,7 +779,7 @@ bool HasBuiltinController(const std::string &name) {
|
||||
return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name) || IsMOQII7S(name) || IsRetroid(name);
|
||||
}
|
||||
|
||||
void NotifyPadConnected(int deviceId, const std::string &name) {
|
||||
void NotifyPadConnected(InputDeviceID deviceId, const std::string &name) {
|
||||
g_seenPads.insert(name);
|
||||
g_padNames[deviceId] = name;
|
||||
}
|
||||
@@ -814,7 +815,7 @@ const std::set<std::string> &GetSeenPads() {
|
||||
return g_seenPads;
|
||||
}
|
||||
|
||||
std::string PadName(int deviceId) {
|
||||
std::string PadName(InputDeviceID deviceId) {
|
||||
auto it = g_padNames.find(deviceId);
|
||||
if (it != g_padNames.end())
|
||||
return it->second;
|
||||
|
||||
Reference in New Issue
Block a user