| 
									
										
										
										
											2023-01-05 13:25:55 +01:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  input_map.cpp                                                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the        */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including    */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
					
						
							|  |  |  | /* the following conditions:                                              */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be         */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.        */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #include "input_map.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-07 19:33:38 -03:00
										 |  |  | #include "core/config/project_settings.h"
 | 
					
						
							| 
									
										
										
										
											2020-11-03 11:22:15 +01:00
										 |  |  | #include "core/input/input.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  | #include "core/os/keyboard.h"
 | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | #include "core/os/os.h"
 | 
					
						
							| 
									
										
										
										
											2022-08-05 20:35:08 +02:00
										 |  |  | #include "core/variant/typed_array.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | InputMap *InputMap::singleton = nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-03 22:29:07 +00:00
										 |  |  | int InputMap::ALL_DEVICES = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-23 21:48:16 -04:00
										 |  |  | void InputMap::_bind_methods() { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions); | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.5f)); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-20 20:58:53 +07:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone); | 
					
						
							| 
									
										
										
										
											2021-07-02 00:02:28 -04:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("action_get_deadzone", "action"), &InputMap::action_get_deadzone); | 
					
						
							| 
									
										
										
										
											2017-08-09 13:19:41 +02:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("action_add_event", "action", "event"), &InputMap::action_add_event); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("action_has_event", "action", "event"), &InputMap::action_has_event); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event); | 
					
						
							| 
									
										
										
										
											2018-04-28 19:01:54 +02:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("action_erase_events", "action"), &InputMap::action_erase_events); | 
					
						
							| 
									
										
										
										
											2020-06-09 23:33:32 +02:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("action_get_events", "action"), &InputMap::_action_get_events); | 
					
						
							| 
									
										
										
											
												Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True
Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.
Usage:
```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)
InputMap.event_is_action(p_event, "my_action", true)
func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```
											
										 
											2020-12-14 00:22:42 +10:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("event_is_action", "event", "action", "exact_match"), &InputMap::event_is_action, DEFVAL(false)); | 
					
						
							| 
									
										
										
										
											2020-10-02 17:04:09 +10:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("load_from_project_settings"), &InputMap::load_from_project_settings); | 
					
						
							| 
									
										
										
										
											2014-04-23 21:48:16 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-28 01:31:49 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Returns an nonexistent action error message with a suggestion of the closest | 
					
						
							|  |  |  |  * matching action name (if possible). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | String InputMap::suggest_actions(const StringName &p_action) const { | 
					
						
							| 
									
										
										
										
											2020-01-28 01:31:49 +01:00
										 |  |  | 	List<StringName> actions = get_actions(); | 
					
						
							|  |  |  | 	StringName closest_action; | 
					
						
							|  |  |  | 	float closest_similarity = 0.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Find the most action with the most similar name.
 | 
					
						
							| 
									
										
										
										
											2021-07-24 15:46:25 +02:00
										 |  |  | 	for (const StringName &action : actions) { | 
					
						
							| 
									
										
										
										
											2021-07-15 23:45:57 -04:00
										 |  |  | 		const float similarity = String(action).similarity(p_action); | 
					
						
							| 
									
										
										
										
											2020-01-28 01:31:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (similarity > closest_similarity) { | 
					
						
							| 
									
										
										
										
											2021-07-15 23:45:57 -04:00
										 |  |  | 			closest_action = action; | 
					
						
							| 
									
										
										
										
											2020-01-28 01:31:49 +01:00
										 |  |  | 			closest_similarity = similarity; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	String error_message = vformat("The InputMap action \"%s\" doesn't exist.", p_action); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (closest_similarity >= 0.4) { | 
					
						
							|  |  |  | 		// Only include a suggestion in the error message if it's similar enough.
 | 
					
						
							|  |  |  | 		error_message += vformat(" Did you mean \"%s\"?", closest_action); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return error_message; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-03 22:41:52 +01:00
										 |  |  | #ifdef TOOLS_ENABLED
 | 
					
						
							|  |  |  | void InputMap::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { | 
					
						
							|  |  |  | 	const String pf = p_function; | 
					
						
							|  |  |  | 	bool first_argument_is_action = false; | 
					
						
							|  |  |  | 	if (p_idx == 0) { | 
					
						
							|  |  |  | 		first_argument_is_action = (pf == "has_action" || pf == "erase_action" || | 
					
						
							|  |  |  | 				pf == "action_set_deadzone" || pf == "action_get_deadzone" || | 
					
						
							|  |  |  | 				pf == "action_has_event" || pf == "action_add_event" || pf == "action_get_events" || | 
					
						
							|  |  |  | 				pf == "action_erase_event" || pf == "action_erase_events"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (first_argument_is_action || (p_idx == 1 && pf == "event_is_action")) { | 
					
						
							|  |  |  | 		// Cannot rely on `get_actions()`, otherwise the actions would be in the context of the Editor (no user-defined actions).
 | 
					
						
							|  |  |  | 		List<PropertyInfo> pinfo; | 
					
						
							|  |  |  | 		ProjectSettings::get_singleton()->get_property_list(&pinfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (const PropertyInfo &pi : pinfo) { | 
					
						
							|  |  |  | 			if (!pi.name.begins_with("input/")) { | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); | 
					
						
							|  |  |  | 			r_options->push_back(name.quote()); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Object::get_argument_options(p_function, p_idx, r_options); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | void InputMap::add_action(const StringName &p_action, float p_deadzone) { | 
					
						
							| 
									
										
										
										
											2020-01-28 01:31:49 +01:00
										 |  |  | 	ERR_FAIL_COND_MSG(input_map.has(p_action), "InputMap already has action \"" + String(p_action) + "\"."); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	input_map[p_action] = Action(); | 
					
						
							|  |  |  | 	static int last_id = 1; | 
					
						
							|  |  |  | 	input_map[p_action].id = last_id; | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 	input_map[p_action].deadzone = p_deadzone; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	last_id++; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void InputMap::erase_action(const StringName &p_action) { | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(!input_map.has(p_action), suggest_actions(p_action)); | 
					
						
							| 
									
										
										
										
											2020-01-28 01:31:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	input_map.erase(p_action); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-05 20:35:08 +02:00
										 |  |  | TypedArray<StringName> InputMap::_get_actions() { | 
					
						
							|  |  |  | 	TypedArray<StringName> ret; | 
					
						
							| 
									
										
										
										
											2016-06-04 17:55:09 +02:00
										 |  |  | 	List<StringName> actions = get_actions(); | 
					
						
							| 
									
										
										
										
											2020-12-15 12:04:21 +00:00
										 |  |  | 	if (actions.is_empty()) { | 
					
						
							| 
									
										
										
										
											2016-06-04 17:55:09 +02:00
										 |  |  | 		return ret; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-06-04 17:55:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-15 23:45:57 -04:00
										 |  |  | 	for (const StringName &E : actions) { | 
					
						
							|  |  |  | 		ret.push_back(E); | 
					
						
							| 
									
										
										
										
											2016-06-04 17:55:09 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | List<StringName> InputMap::get_actions() const { | 
					
						
							|  |  |  | 	List<StringName> actions = List<StringName>(); | 
					
						
							| 
									
										
										
										
											2020-12-15 12:04:21 +00:00
										 |  |  | 	if (input_map.is_empty()) { | 
					
						
							| 
									
										
										
										
											2016-06-04 17:55:09 +02:00
										 |  |  | 		return actions; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	for (const KeyValue<StringName, Action> &E : input_map) { | 
					
						
							|  |  |  | 		actions.push_back(E.key); | 
					
						
							| 
									
										
										
										
											2016-06-04 17:55:09 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return actions; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool p_exact_match, bool *r_pressed, float *r_strength, float *r_raw_strength, int *r_event_index) const { | 
					
						
							| 
									
										
										
										
											2020-09-23 15:39:06 +02:00
										 |  |  | 	ERR_FAIL_COND_V(!p_event.is_valid(), nullptr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | 	int i = 0; | 
					
						
							| 
									
										
										
										
											2020-03-17 07:33:00 +01:00
										 |  |  | 	for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2021-07-15 23:45:57 -04:00
										 |  |  | 		int device = E->get()->get_device(); | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 		if (device == ALL_DEVICES || device == p_event->get_device()) { | 
					
						
							| 
									
										
										
										
											2021-10-23 22:38:32 -05:00
										 |  |  | 			if (E->get()->action_match(p_event, p_exact_match, p_action.deadzone, r_pressed, r_strength, r_raw_strength)) { | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | 				if (r_event_index) { | 
					
						
							|  |  |  | 					*r_event_index = i; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-04-03 22:29:07 +00:00
										 |  |  | 				return E; | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | 		i++; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	return nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | bool InputMap::has_action(const StringName &p_action) const { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	return input_map.has(p_action); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 01:21:13 -05:00
										 |  |  | float InputMap::action_get_deadzone(const StringName &p_action) { | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_V_MSG(!input_map.has(p_action), 0.0f, suggest_actions(p_action)); | 
					
						
							| 
									
										
										
										
											2020-11-10 01:21:13 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return input_map[p_action].deadzone; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) { | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(!input_map.has(p_action), suggest_actions(p_action)); | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	input_map[p_action].deadzone = p_deadzone; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) { | 
					
						
							| 
									
										
										
										
											2019-09-25 10:28:50 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(p_event.is_null(), "It's not a reference to a valid InputEvent object."); | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(!input_map.has(p_action), suggest_actions(p_action)); | 
					
						
							| 
									
										
										
											
												Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True
Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.
Usage:
```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)
InputMap.event_is_action(p_event, "my_action", true)
func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```
											
										 
											2020-12-14 00:22:42 +10:00
										 |  |  | 	if (_find_event(input_map[p_action], p_event, true)) { | 
					
						
							| 
									
										
										
										
											2021-05-20 12:07:26 +02:00
										 |  |  | 		return; // Already added.
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	input_map[p_action].inputs.push_back(p_event); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) { | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_V_MSG(!input_map.has(p_action), false, suggest_actions(p_action)); | 
					
						
							| 
									
										
										
											
												Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True
Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.
Usage:
```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)
InputMap.event_is_action(p_event, "my_action", true)
func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```
											
										 
											2020-12-14 00:22:42 +10:00
										 |  |  | 	return (_find_event(input_map[p_action], p_event, true) != nullptr); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) { | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(!input_map.has(p_action), suggest_actions(p_action)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True
Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.
Usage:
```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)
InputMap.event_is_action(p_event, "my_action", true)
func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```
											
										 
											2020-12-14 00:22:42 +10:00
										 |  |  | 	List<Ref<InputEvent>>::Element *E = _find_event(input_map[p_action], p_event, true); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (E) { | 
					
						
							| 
									
										
										
										
											2016-03-07 18:56:44 +01:00
										 |  |  | 		input_map[p_action].inputs.erase(E); | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-03 11:22:15 +01:00
										 |  |  | 		if (Input::get_singleton()->is_action_pressed(p_action)) { | 
					
						
							|  |  |  | 			Input::get_singleton()->action_release(p_action); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-28 19:01:54 +02:00
										 |  |  | void InputMap::action_erase_events(const StringName &p_action) { | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(!input_map.has(p_action), suggest_actions(p_action)); | 
					
						
							| 
									
										
										
										
											2018-04-28 19:01:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	input_map[p_action].inputs.clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-05 20:35:08 +02:00
										 |  |  | TypedArray<InputEvent> InputMap::_action_get_events(const StringName &p_action) { | 
					
						
							|  |  |  | 	TypedArray<InputEvent> ret; | 
					
						
							| 
									
										
										
										
											2020-06-09 23:33:32 +02:00
										 |  |  | 	const List<Ref<InputEvent>> *al = action_get_events(p_action); | 
					
						
							| 
									
										
										
										
											2015-05-18 10:20:54 -03:00
										 |  |  | 	if (al) { | 
					
						
							| 
									
										
										
										
											2020-03-17 07:33:00 +01:00
										 |  |  | 		for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2021-08-07 21:17:55 +02:00
										 |  |  | 			ret.push_back(E->get()); | 
					
						
							| 
									
										
										
										
											2015-05-18 10:20:54 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-09 23:33:32 +02:00
										 |  |  | const List<Ref<InputEvent>> *InputMap::action_get_events(const StringName &p_action) { | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	HashMap<StringName, Action>::Iterator E = input_map.find(p_action); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!E) { | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 		return nullptr; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	return &E->value.inputs; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.
Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True
Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.
Usage:
```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)
InputMap.event_is_action(p_event, "my_action", true)
func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```
											
										 
											2020-12-14 00:22:42 +10:00
										 |  |  | bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match) const { | 
					
						
							|  |  |  | 	return event_get_action_status(p_event, p_action, p_exact_match); | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | int InputMap::event_get_index(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match) const { | 
					
						
							|  |  |  | 	int index = -1; | 
					
						
							|  |  |  | 	event_get_action_status(p_event, p_action, p_exact_match, nullptr, nullptr, nullptr, &index); | 
					
						
							|  |  |  | 	return index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool p_exact_match, bool *r_pressed, float *r_strength, float *r_raw_strength, int *r_event_index) const { | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	HashMap<StringName, Action>::Iterator E = input_map.find(p_action); | 
					
						
							| 
									
										
										
										
											2021-08-16 19:57:34 +02:00
										 |  |  | 	ERR_FAIL_COND_V_MSG(!E, false, suggest_actions(p_action)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 	Ref<InputEventAction> input_event_action = p_event; | 
					
						
							|  |  |  | 	if (input_event_action.is_valid()) { | 
					
						
							| 
									
										
										
										
											2021-10-23 22:38:32 -05:00
										 |  |  | 		const bool pressed = input_event_action->is_pressed(); | 
					
						
							|  |  |  | 		if (r_pressed != nullptr) { | 
					
						
							|  |  |  | 			*r_pressed = pressed; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const float strength = pressed ? input_event_action->get_strength() : 0.0f; | 
					
						
							|  |  |  | 		if (r_strength != nullptr) { | 
					
						
							|  |  |  | 			*r_strength = strength; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-10-23 22:38:32 -05:00
										 |  |  | 		if (r_raw_strength != nullptr) { | 
					
						
							|  |  |  | 			*r_raw_strength = strength; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2023-12-10 19:23:29 +01:00
										 |  |  | 		if (r_event_index) { | 
					
						
							|  |  |  | 			if (input_event_action->get_event_index() >= 0) { | 
					
						
							|  |  |  | 				*r_event_index = input_event_action->get_event_index(); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				*r_event_index = E->value.inputs.size(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 		return input_event_action->get_action() == p_action; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-09 23:54:09 +01:00
										 |  |  | 	List<Ref<InputEvent>>::Element *event = _find_event(E->value, p_event, p_exact_match, r_pressed, r_strength, r_raw_strength, r_event_index); | 
					
						
							| 
									
										
										
										
											2021-10-23 22:38:32 -05:00
										 |  |  | 	return event != nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | const HashMap<StringName, InputMap::Action> &InputMap::get_action_map() const { | 
					
						
							| 
									
										
										
										
											2016-09-01 18:58:52 -03:00
										 |  |  | 	return input_map; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-02 17:04:09 +10:00
										 |  |  | void InputMap::load_from_project_settings() { | 
					
						
							| 
									
										
										
										
											2017-01-14 18:03:38 +01:00
										 |  |  | 	input_map.clear(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	List<PropertyInfo> pinfo; | 
					
						
							| 
									
										
										
										
											2017-07-19 17:00:46 -03:00
										 |  |  | 	ProjectSettings::get_singleton()->get_property_list(&pinfo); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-24 15:46:25 +02:00
										 |  |  | 	for (const PropertyInfo &pi : pinfo) { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (!pi.name.begins_with("input/")) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-18 16:43:37 +02:00
										 |  |  | 		Dictionary action = GLOBAL_GET(pi.name); | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 		float deadzone = action.has("deadzone") ? (float)action["deadzone"] : 0.5f; | 
					
						
							|  |  |  | 		Array events = action["events"]; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 		add_action(name, deadzone); | 
					
						
							|  |  |  | 		for (int i = 0; i < events.size(); i++) { | 
					
						
							|  |  |  | 			Ref<InputEvent> event = events[i]; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (event.is_null()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				continue; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-21 22:06:34 +01:00
										 |  |  | 			action_add_event(name, event); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-06-05 01:19:42 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | struct _BuiltinActionDisplayName { | 
					
						
							|  |  |  | 	const char *name; | 
					
						
							|  |  |  | 	const char *display_name; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const _BuiltinActionDisplayName _builtin_action_display_names[] = { | 
					
						
							|  |  |  | 	/* clang-format off */ | 
					
						
							|  |  |  |     { "ui_accept",                                     TTRC("Accept") }, | 
					
						
							|  |  |  |     { "ui_select",                                     TTRC("Select") }, | 
					
						
							|  |  |  |     { "ui_cancel",                                     TTRC("Cancel") }, | 
					
						
							|  |  |  |     { "ui_focus_next",                                 TTRC("Focus Next") }, | 
					
						
							|  |  |  |     { "ui_focus_prev",                                 TTRC("Focus Prev") }, | 
					
						
							|  |  |  |     { "ui_left",                                       TTRC("Left") }, | 
					
						
							|  |  |  |     { "ui_right",                                      TTRC("Right") }, | 
					
						
							|  |  |  |     { "ui_up",                                         TTRC("Up") }, | 
					
						
							|  |  |  |     { "ui_down",                                       TTRC("Down") }, | 
					
						
							|  |  |  |     { "ui_page_up",                                    TTRC("Page Up") }, | 
					
						
							|  |  |  |     { "ui_page_down",                                  TTRC("Page Down") }, | 
					
						
							|  |  |  |     { "ui_home",                                       TTRC("Home") }, | 
					
						
							|  |  |  |     { "ui_end",                                        TTRC("End") }, | 
					
						
							|  |  |  |     { "ui_cut",                                        TTRC("Cut") }, | 
					
						
							|  |  |  |     { "ui_copy",                                       TTRC("Copy") }, | 
					
						
							|  |  |  |     { "ui_paste",                                      TTRC("Paste") }, | 
					
						
							|  |  |  |     { "ui_undo",                                       TTRC("Undo") }, | 
					
						
							|  |  |  |     { "ui_redo",                                       TTRC("Redo") }, | 
					
						
							|  |  |  |     { "ui_text_completion_query",                      TTRC("Completion Query") }, | 
					
						
							|  |  |  |     { "ui_text_newline",                               TTRC("New Line") }, | 
					
						
							|  |  |  |     { "ui_text_newline_blank",                         TTRC("New Blank Line") }, | 
					
						
							|  |  |  |     { "ui_text_newline_above",                         TTRC("New Line Above") }, | 
					
						
							|  |  |  |     { "ui_text_indent",                                TTRC("Indent") }, | 
					
						
							|  |  |  |     { "ui_text_dedent",                                TTRC("Dedent") }, | 
					
						
							|  |  |  |     { "ui_text_backspace",                             TTRC("Backspace") }, | 
					
						
							|  |  |  |     { "ui_text_backspace_word",                        TTRC("Backspace Word") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_backspace_word.macos",                  TTRC("Backspace Word") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_backspace_all_to_left",                 TTRC("Backspace all to Left") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_backspace_all_to_left.macos",           TTRC("Backspace all to Left") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_delete",                                TTRC("Delete") }, | 
					
						
							|  |  |  |     { "ui_text_delete_word",                           TTRC("Delete Word") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_delete_word.macos",                     TTRC("Delete Word") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_delete_all_to_right",                   TTRC("Delete all to Right") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_delete_all_to_right.macos",             TTRC("Delete all to Right") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_caret_left",                            TTRC("Caret Left") }, | 
					
						
							|  |  |  |     { "ui_text_caret_word_left",                       TTRC("Caret Word Left") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_caret_word_left.macos",                 TTRC("Caret Word Left") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_caret_right",                           TTRC("Caret Right") }, | 
					
						
							|  |  |  |     { "ui_text_caret_word_right",                      TTRC("Caret Word Right") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_caret_word_right.macos",                TTRC("Caret Word Right") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_caret_up",                              TTRC("Caret Up") }, | 
					
						
							|  |  |  |     { "ui_text_caret_down",                            TTRC("Caret Down") }, | 
					
						
							|  |  |  |     { "ui_text_caret_line_start",                      TTRC("Caret Line Start") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_caret_line_start.macos",                TTRC("Caret Line Start") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_caret_line_end",                        TTRC("Caret Line End") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_caret_line_end.macos",                  TTRC("Caret Line End") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_caret_page_up",                         TTRC("Caret Page Up") }, | 
					
						
							|  |  |  |     { "ui_text_caret_page_down",                       TTRC("Caret Page Down") }, | 
					
						
							|  |  |  |     { "ui_text_caret_document_start",                  TTRC("Caret Document Start") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_caret_document_start.macos",            TTRC("Caret Document Start") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_caret_document_end",                    TTRC("Caret Document End") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_caret_document_end.macos",              TTRC("Caret Document End") }, | 
					
						
							| 
									
										
										
										
											2022-10-09 17:07:42 +02:00
										 |  |  |     { "ui_text_caret_add_below",                       TTRC("Caret Add Below") }, | 
					
						
							|  |  |  |     { "ui_text_caret_add_below.macos",                 TTRC("Caret Add Below") }, | 
					
						
							|  |  |  |     { "ui_text_caret_add_above",                       TTRC("Caret Add Above") }, | 
					
						
							|  |  |  |     { "ui_text_caret_add_above.macos",                 TTRC("Caret Add Above") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_scroll_up",                             TTRC("Scroll Up") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_scroll_up.macos",                       TTRC("Scroll Up") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_scroll_down",                           TTRC("Scroll Down") }, | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  |     { "ui_text_scroll_down.macos",                     TTRC("Scroll Down") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_select_all",                            TTRC("Select All") }, | 
					
						
							| 
									
										
										
										
											2021-06-16 09:43:34 -07:00
										 |  |  |     { "ui_text_select_word_under_caret",               TTRC("Select Word Under Caret") }, | 
					
						
							| 
									
										
										
										
											2022-10-19 19:35:14 +02:00
										 |  |  |     { "ui_text_add_selection_for_next_occurrence",     TTRC("Add Selection for Next Occurrence") }, | 
					
						
							| 
									
										
										
										
											2024-02-02 23:10:55 +01:00
										 |  |  |     { "ui_text_skip_selection_for_next_occurrence",    TTRC("Skip Selection for Next Occurrence") }, | 
					
						
							| 
									
										
										
										
											2022-11-02 15:14:08 +01:00
										 |  |  |     { "ui_text_clear_carets_and_selection",            TTRC("Clear Carets and Selection") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_text_toggle_insert_mode",                    TTRC("Toggle Insert Mode") }, | 
					
						
							| 
									
										
										
										
											2023-02-13 11:27:12 +08:00
										 |  |  |     { "ui_text_submit",                                TTRC("Submit Text") }, | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  |     { "ui_graph_duplicate",                            TTRC("Duplicate Nodes") }, | 
					
						
							|  |  |  |     { "ui_graph_delete",                               TTRC("Delete Nodes") }, | 
					
						
							|  |  |  |     { "ui_filedialog_up_one_level",                    TTRC("Go Up One Level") }, | 
					
						
							|  |  |  |     { "ui_filedialog_refresh",                         TTRC("Refresh") }, | 
					
						
							|  |  |  |     { "ui_filedialog_show_hidden",                     TTRC("Show Hidden") }, | 
					
						
							|  |  |  |     { "ui_swap_input_direction ",                      TTRC("Swap Input Direction") }, | 
					
						
							| 
									
										
										
										
											2024-09-05 10:52:29 +03:00
										 |  |  |     { "ui_unicode_start",                              TTRC("Start Unicode Character Input") }, | 
					
						
							| 
									
										
										
										
											2022-03-02 17:02:10 +08:00
										 |  |  |     { "",                                              ""} | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	/* clang-format on */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | String InputMap::get_builtin_display_name(const String &p_name) const { | 
					
						
							|  |  |  | 	int len = sizeof(_builtin_action_display_names) / sizeof(_BuiltinActionDisplayName); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < len; i++) { | 
					
						
							|  |  |  | 		if (_builtin_action_display_names[i].name == p_name) { | 
					
						
							|  |  |  | 			return RTR(_builtin_action_display_names[i].display_name); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return p_name; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() { | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	// Return cache if it has already been built.
 | 
					
						
							|  |  |  | 	if (default_builtin_cache.size()) { | 
					
						
							|  |  |  | 		return default_builtin_cache; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	List<Ref<InputEvent>> inputs; | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ENTER)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::SPACE)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_accept", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::Y)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::SPACE)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_select", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ESCAPE)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_cancel", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::TAB)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_focus_next", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::TAB | KeyModifierMask::SHIFT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_focus_prev", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::LEFT)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_LEFT)); | 
					
						
							| 
									
										
										
										
											2023-02-09 11:25:56 -05:00
										 |  |  | 	inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_X, -1.0)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_left", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::RIGHT)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_RIGHT)); | 
					
						
							| 
									
										
										
										
											2023-02-09 11:25:56 -05:00
										 |  |  | 	inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_X, 1.0)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_right", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::UP)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_UP)); | 
					
						
							| 
									
										
										
										
											2023-02-09 11:25:56 -05:00
										 |  |  | 	inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_Y, -1.0)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_up", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::DOWN)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_DOWN)); | 
					
						
							| 
									
										
										
										
											2023-02-09 11:25:56 -05:00
										 |  |  | 	inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_Y, 1.0)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_down", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::PAGEUP)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_page_up", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::PAGEDOWN)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_page_down", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::HOME)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_home", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::END)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_end", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ///// UI basic Shortcuts /////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::X | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::SHIFT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_cut", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::C | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::INSERT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_copy", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::V | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::INSERT | KeyModifierMask::SHIFT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_paste", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::Z | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_undo", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::Z | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::Y | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_redo", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ///// UI Text Input Shortcuts /////
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::SPACE | KeyModifierMask::CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_completion_query", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:32:00 +10:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ENTER)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:32:00 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_completion_accept", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-13 21:14:20 +01:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::TAB)); | 
					
						
							| 
									
										
										
										
											2020-09-13 21:14:20 +01:00
										 |  |  | 	default_builtin_cache.insert("ui_text_completion_replace", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	// Newlines
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ENTER)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_newline", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ENTER | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_newline_blank", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ENTER | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_newline_above", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Indentation
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::TAB)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_indent", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::TAB | KeyModifierMask::SHIFT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_dedent", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Text Backspace and Delete
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::SHIFT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_backspace", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_backspace_word", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_backspace_word.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_backspace_all_to_left", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_backspace_all_to_left.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_delete", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_delete_word", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_delete_word.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_delete_all_to_right", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_delete_all_to_right.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Text Caret Movement Left/Right
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::LEFT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_left", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::LEFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_word_left", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::LEFT | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_word_left.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::RIGHT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_right", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_word_right", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::RIGHT | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_word_right.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Text Caret Movement Up/Down
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::UP)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_up", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::DOWN)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_down", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Text Caret Movement Line Start/End
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::HOME)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_line_start", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::A | KeyModifierMask::CTRL)); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::LEFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2024-07-08 16:08:27 +02:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::HOME)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_line_start.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::END)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_line_end", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::E | KeyModifierMask::CTRL)); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2024-07-08 16:08:27 +02:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::END)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_line_end.macos", inputs); | 
					
						
							| 
									
										
										
										
											2021-03-12 19:05:16 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	// Text Caret Movement Page Up/Down
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::PAGEUP)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_page_up", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::PAGEDOWN)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_page_down", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Text Caret Movement Document Start/End
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::HOME | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_document_start", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2024-07-08 16:08:27 +02:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::HOME | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_document_start.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::END | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_document_end", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2024-07-08 16:08:27 +02:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::END | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_caret_document_end.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-09 17:07:42 +02:00
										 |  |  | 	// Text Caret Addition Below/Above
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_caret_add_below", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::L | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_caret_add_below.macos", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_caret_add_above", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::O | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_caret_add_above.macos", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	// Text Scrolling
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_scroll_up", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::UP | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_scroll_up.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_scroll_down", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::DOWN | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-08-31 20:38:26 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_scroll_down.macos", inputs); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Text Misc
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::A | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_select_all", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-15 18:22:52 +02:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-10-19 19:35:14 +02:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::G | KeyModifierMask::ALT)); | 
					
						
							| 
									
										
										
										
											2021-05-15 18:22:52 +02:00
										 |  |  | 	default_builtin_cache.insert("ui_text_select_word_under_caret", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-16 11:28:04 +02:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::G | KeyModifierMask::CTRL | KeyModifierMask::META)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_select_word_under_caret.macos", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-19 19:35:14 +02:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_add_selection_for_next_occurrence", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 23:10:55 +01:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_text_skip_selection_for_next_occurrence", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-31 16:55:47 +01:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ESCAPE)); | 
					
						
							| 
									
										
										
										
											2022-11-02 15:14:08 +01:00
										 |  |  | 	default_builtin_cache.insert("ui_text_clear_carets_and_selection", inputs); | 
					
						
							| 
									
										
										
										
											2022-10-31 16:55:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::INSERT)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_text_toggle_insert_mode", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::MENU)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_menu", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-16 09:43:34 -07:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::ENTER)); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER)); | 
					
						
							| 
									
										
										
										
											2021-06-16 09:43:34 -07:00
										 |  |  | 	default_builtin_cache.insert("ui_text_submit", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-05 10:52:29 +03:00
										 |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							|  |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::U | KeyModifierMask::CTRL | KeyModifierMask::SHIFT)); | 
					
						
							|  |  |  | 	default_builtin_cache.insert("ui_unicode_start", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	// ///// UI Graph Shortcuts /////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_graph_duplicate", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_graph_delete", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ///// UI File Dialog Shortcuts /////
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_filedialog_up_one_level", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::F5)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_filedialog_refresh", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::H)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_filedialog_show_hidden", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	inputs = List<Ref<InputEvent>>(); | 
					
						
							| 
									
										
										
										
											2022-09-02 12:37:48 +03:00
										 |  |  | 	inputs.push_back(InputEventKey::create_reference(Key::QUOTELEFT | KeyModifierMask::CMD_OR_CTRL)); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 	default_builtin_cache.insert("ui_swap_input_direction", inputs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return default_builtin_cache; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins_with_feature_overrides_applied() { | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 	if (default_builtin_with_overrides_cache.size() > 0) { | 
					
						
							|  |  |  | 		return default_builtin_with_overrides_cache; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	const HashMap<String, List<Ref<InputEvent>>> &builtins = get_builtins(); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 	// Get a list of all built in inputs which are valid overrides for the OS
 | 
					
						
							|  |  |  | 	// Key = builtin name (e.g. ui_accept)
 | 
					
						
							|  |  |  | 	// Value = override/feature names (e.g. macos, if it was defined as "ui_accept.macos" and the platform supports that feature)
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	HashMap<String, Vector<String>> builtins_with_overrides; | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) { | 
					
						
							|  |  |  | 		String fullname = E.key; | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Vector<String> split = fullname.split("."); | 
					
						
							| 
									
										
										
										
											2023-11-18 17:40:56 -05:00
										 |  |  | 		const String &name = split[0]; | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 		String override_for = split.size() > 1 ? split[1] : String(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 03:42:46 -06:00
										 |  |  | 		if (!override_for.is_empty() && OS::get_singleton()->has_feature(override_for)) { | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 			builtins_with_overrides[name].push_back(override_for); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) { | 
					
						
							|  |  |  | 		String fullname = E.key; | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 		Vector<String> split = fullname.split("."); | 
					
						
							| 
									
										
										
										
											2023-11-18 17:40:56 -05:00
										 |  |  | 		const String &name = split[0]; | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 		String override_for = split.size() > 1 ? split[1] : String(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 03:42:46 -06:00
										 |  |  | 		if (builtins_with_overrides.has(name) && override_for.is_empty()) { | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 			// Builtin has an override but this particular one is not an override, so skip.
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 			continue; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 03:42:46 -06:00
										 |  |  | 		if (!override_for.is_empty() && !OS::get_singleton()->has_feature(override_for)) { | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 			// OS does not support this override - skip.
 | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 			continue; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 		default_builtin_with_overrides_cache.insert(name, E.value); | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return default_builtin_with_overrides_cache; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputMap::load_default() { | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	HashMap<String, List<Ref<InputEvent>>> builtins = get_builtins_with_feature_overrides_applied(); | 
					
						
							| 
									
										
										
										
											2021-08-06 16:30:15 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 	for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) { | 
					
						
							|  |  |  | 		String name = E.key; | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		add_action(name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-08 10:09:19 +02:00
										 |  |  | 		const List<Ref<InputEvent>> &inputs = E.value; | 
					
						
							|  |  |  | 		for (const List<Ref<InputEvent>>::Element *I = inputs.front(); I; I = I->next()) { | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 			Ref<InputEventKey> iek = I->get(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// For the editor, only add keyboard actions.
 | 
					
						
							|  |  |  | 			if (iek.is_valid()) { | 
					
						
							| 
									
										
										
										
											2021-02-24 22:25:15 +10:00
										 |  |  | 				action_add_event(name, I->get()); | 
					
						
							| 
									
										
										
										
											2020-12-07 21:31:51 +10:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputMap::InputMap() { | 
					
						
							| 
									
										
										
										
											2019-09-25 10:28:50 +02:00
										 |  |  | 	ERR_FAIL_COND_MSG(singleton, "Singleton in InputMap already exist."); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	singleton = this; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-07-11 14:26:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | InputMap::~InputMap() { | 
					
						
							|  |  |  | 	singleton = nullptr; | 
					
						
							|  |  |  | } |