mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Allows to map an action to all devices.
This is accomplished by setting a special value (-1) to the device variable in the InputEvent that's being used to compare with the one received from the OS. This special value is invalid for a regular input, so it should be safe. Implements #17942
This commit is contained in:
parent
bcf5b748b5
commit
1e28f63bcf
4 changed files with 47 additions and 19 deletions
|
@ -35,6 +35,8 @@
|
|||
|
||||
InputMap *InputMap::singleton = NULL;
|
||||
|
||||
int InputMap::ALL_DEVICES = -1;
|
||||
|
||||
void InputMap::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
|
||||
|
@ -103,10 +105,10 @@ List<Ref<InputEvent> >::Element *InputMap::_find_event(List<Ref<InputEvent> > &p
|
|||
//if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here?
|
||||
// continue;
|
||||
|
||||
if (e->get_device() != p_event->get_device())
|
||||
continue;
|
||||
if (e->action_match(p_event))
|
||||
return E;
|
||||
int device = e->get_device();
|
||||
if (device == ALL_DEVICES || device == p_event->get_device())
|
||||
if (e->action_match(p_event))
|
||||
return E;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue