Input: Fix action matching for projects saved before device ID change

Normalize legacy device=0 on keyboard/mouse events when loading
input actions from project settings. Before eadec6c605, these
events defaulted to device=0; now they use DEVICE_ID_KEYBOARD (16)
and DEVICE_ID_MOUSE (32), causing _find_event() mismatches.
This commit is contained in:
Stuart Carnie 2026-02-20 19:29:40 +11:00
parent 897172fa25
commit f81ee0679a

View file

@ -205,6 +205,22 @@ void InputMap::action_add_event(const StringName &p_action, RequiredParam<InputE
return; // Already added.
}
// Normalize legacy device IDs: before the device ID change,
// keyboard and mouse events defaulted to device=0.
if (p_event->get_device() == 0) {
switch (p_event->get_type()) {
case InputEventType::KEY:
p_event->set_device(InputEvent::DEVICE_ID_KEYBOARD);
break;
case InputEventType::MOUSE_BUTTON:
case InputEventType::MOUSE_MOTION:
p_event->set_device(InputEvent::DEVICE_ID_MOUSE);
break;
default:
break;
}
}
input_map[p_action].inputs.push_back(p_event);
}