Avoid creating joy_names map entries when using Map operator[]
This commit is contained in:
parent
701fa8a779
commit
9170314434
1 changed files with 15 additions and 8 deletions
|
@ -1216,9 +1216,10 @@ void InputDefault::add_joy_mapping(String p_mapping, bool p_update_existing) {
|
|||
if (p_update_existing) {
|
||||
Vector<String> entry = p_mapping.split(",");
|
||||
String uid = entry[0];
|
||||
for (int i = 0; i < joy_names.size(); i++) {
|
||||
if (uid == joy_names[i].uid) {
|
||||
joy_names[i].mapping = map_db.size() - 1;
|
||||
for (Map<int, Joypad>::Element *E = joy_names.front(); E; E = E->next()) {
|
||||
Joypad &joy = E->get();
|
||||
if (joy.uid == uid) {
|
||||
joy.mapping = map_db.size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1230,9 +1231,10 @@ void InputDefault::remove_joy_mapping(String p_guid) {
|
|||
map_db.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < joy_names.size(); i++) {
|
||||
if (joy_names[i].uid == p_guid) {
|
||||
joy_names[i].mapping = -1;
|
||||
for (Map<int, Joypad>::Element *E = joy_names.front(); E; E = E->next()) {
|
||||
Joypad &joy = E->get();
|
||||
if (joy.uid == p_guid) {
|
||||
joy.mapping = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1259,8 +1261,13 @@ String InputDefault::get_joy_guid(int p_device) const {
|
|||
|
||||
//platforms that use the remapping system can override and call to these ones
|
||||
bool InputDefault::is_joy_mapped(int p_device) {
|
||||
if (joy_names.has(p_device)) {
|
||||
int mapping = joy_names[p_device].mapping;
|
||||
return mapping != -1 ? (mapping != fallback_mapping) : false;
|
||||
if (mapping != -1 && mapping != fallback_mapping) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String InputDefault::get_joy_guid_remapped(int p_device) const {
|
||||
|
|
Loading…
Reference in a new issue