mirror of
https://github.com/godotengine/godot.git
synced 2026-02-24 22:36:38 +03:00
Merge pull request #116526 from stuartcarnie/fix_legacy_input_events
Input: Fix action matching for projects saved before device ID change
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user