Hey! I recently upgraded from v3.1.2 to the most recent commit and noticed one tiny regression in how the addon selects icons.
In get_matching_event, the use of push_front for ALL_DEVICE events means that if there are multiple controller mappings for the same event, the last one on the list will end up at the front, which is the opposite of how it behaved in v3.1.2.
There may be a nicer way to handle this, but here's the quick fix I made locally. Since the comments suggest we're prioritizing ALL_DEVICE, I just make two fallback arrays, one for ALL_DEVICE events and one for everything else, fill them up in order, then smash them together at the end.
func get_matching_event(path: String, input_type: InputType = _last_input_type, controller: int = _last_controller) -> InputEvent:
var events : Array
if _custom_input_actions.has(path):
events = _custom_input_actions[path]
else:
events = InputMap.action_get_events(path)
var fallbacks_all = []
var fallbacks_other = []
for event in events:
if not is_instance_valid(event): continue
match event.get_class():
"InputEventKey", "InputEventMouse", "InputEventMouseMotion", "InputEventMouseButton":
if input_type == InputType.KEYBOARD_MOUSE:
return event
"InputEventJoypadButton", "InputEventJoypadMotion":
if input_type == InputType.CONTROLLER:
# Use the first device specific mapping if there is one.
if event.device == controller:
return event
# Otherwise, we create a fallback prioritizing events with 'ALL_DEVICE'
if event.device < 0: # All-device event
fallbacks_all.push_back(event)
else:
fallbacks_other.push_back(event)
var fallbacks = fallbacks_all + fallbacks_other
return fallbacks[0] if not fallbacks.is_empty() else null
Hey! I recently upgraded from v3.1.2 to the most recent commit and noticed one tiny regression in how the addon selects icons.
In
get_matching_event, the use ofpush_frontfor ALL_DEVICE events means that if there are multiple controller mappings for the same event, the last one on the list will end up at the front, which is the opposite of how it behaved in v3.1.2.There may be a nicer way to handle this, but here's the quick fix I made locally. Since the comments suggest we're prioritizing ALL_DEVICE, I just make two fallback arrays, one for ALL_DEVICE events and one for everything else, fill them up in order, then smash them together at the end.