You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
Avoid creating joy_names map entries when using Map operator[]
This commit is contained in:
@@ -1329,9 +1329,10 @@ void Input::add_joy_mapping(String p_mapping, bool p_update_existing) {
|
|||||||
if (p_update_existing) {
|
if (p_update_existing) {
|
||||||
Vector<String> entry = p_mapping.split(",");
|
Vector<String> entry = p_mapping.split(",");
|
||||||
String uid = entry[0];
|
String uid = entry[0];
|
||||||
for (int i = 0; i < joy_names.size(); i++) {
|
for (Map<int, Joypad>::Element *E = joy_names.front(); E; E = E->next()) {
|
||||||
if (uid == joy_names[i].uid) {
|
Joypad &joy = E->get();
|
||||||
joy_names[i].mapping = map_db.size() - 1;
|
if (joy.uid == uid) {
|
||||||
|
joy.mapping = map_db.size() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1343,9 +1344,10 @@ void Input::remove_joy_mapping(String p_guid) {
|
|||||||
map_db.remove(i);
|
map_db.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < joy_names.size(); i++) {
|
for (Map<int, Joypad>::Element *E = joy_names.front(); E; E = E->next()) {
|
||||||
if (joy_names[i].uid == p_guid) {
|
Joypad &joy = E->get();
|
||||||
joy_names[i].mapping = -1;
|
if (joy.uid == p_guid) {
|
||||||
|
joy.mapping = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1361,8 +1363,13 @@ void Input::set_fallback_mapping(String p_guid) {
|
|||||||
|
|
||||||
//platforms that use the remapping system can override and call to these ones
|
//platforms that use the remapping system can override and call to these ones
|
||||||
bool Input::is_joy_known(int p_device) {
|
bool Input::is_joy_known(int p_device) {
|
||||||
int mapping = joy_names[p_device].mapping;
|
if (joy_names.has(p_device)) {
|
||||||
return mapping != -1 ? (mapping != fallback_mapping) : false;
|
int mapping = joy_names[p_device].mapping;
|
||||||
|
if (mapping != -1 && mapping != fallback_mapping) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Input::get_joy_guid(int p_device) const {
|
String Input::get_joy_guid(int p_device) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user