mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-03 23:21:15 +00:00 
			
		
		
		
	Add get_dead_zone() method to InputMap
				
					
				
			This commit adds a new method to the `InputMap`, allowing the user to get the value of an action's dead zone as a float.
(cherry picked from commit c6f28ed62b)
			
			
This commit is contained in:
		
							parent
							
								
									686a27b278
								
							
						
					
					
						commit
						28ea0cf1e2
					
				
					 3 changed files with 17 additions and 0 deletions
				
			
		| 
						 | 
					@ -46,6 +46,7 @@ void InputMap::_bind_methods() {
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
 | 
						ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone);
 | 
						ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone);
 | 
				
			||||||
 | 
						ClassDB::bind_method(D_METHOD("action_get_deadzone", "action"), &InputMap::action_get_deadzone);
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("action_add_event", "action", "event"), &InputMap::action_add_event);
 | 
						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_has_event", "action", "event"), &InputMap::action_has_event);
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
 | 
						ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
 | 
				
			||||||
| 
						 | 
					@ -156,6 +157,12 @@ bool InputMap::has_action(const StringName &p_action) const {
 | 
				
			||||||
	return input_map.has(p_action);
 | 
						return input_map.has(p_action);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					float InputMap::action_get_deadzone(const StringName &p_action) {
 | 
				
			||||||
 | 
						ERR_FAIL_COND_V_MSG(!input_map.has(p_action), 0.0f, _suggest_actions(p_action));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return input_map[p_action].deadzone;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
 | 
					void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_FAIL_COND_MSG(!input_map.has(p_action), _suggest_actions(p_action));
 | 
						ERR_FAIL_COND_MSG(!input_map.has(p_action), _suggest_actions(p_action));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,7 @@ public:
 | 
				
			||||||
	void add_action(const StringName &p_action, float p_deadzone = 0.5);
 | 
						void add_action(const StringName &p_action, float p_deadzone = 0.5);
 | 
				
			||||||
	void erase_action(const StringName &p_action);
 | 
						void erase_action(const StringName &p_action);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						float action_get_deadzone(const StringName &p_action);
 | 
				
			||||||
	void action_set_deadzone(const StringName &p_action, float p_deadzone);
 | 
						void action_set_deadzone(const StringName &p_action, float p_deadzone);
 | 
				
			||||||
	void action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event);
 | 
						void action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event);
 | 
				
			||||||
	bool action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event);
 | 
						bool action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,6 +41,15 @@
 | 
				
			||||||
				Removes all events from an action.
 | 
									Removes all events from an action.
 | 
				
			||||||
			</description>
 | 
								</description>
 | 
				
			||||||
		</method>
 | 
							</method>
 | 
				
			||||||
 | 
							<method name="action_get_deadzone">
 | 
				
			||||||
 | 
								<return type="float">
 | 
				
			||||||
 | 
								</return>
 | 
				
			||||||
 | 
								<argument index="0" name="action" type="String">
 | 
				
			||||||
 | 
								</argument>
 | 
				
			||||||
 | 
								<description>
 | 
				
			||||||
 | 
									Returns a deadzone value for the action.
 | 
				
			||||||
 | 
								</description>
 | 
				
			||||||
 | 
							</method>
 | 
				
			||||||
		<method name="action_has_event">
 | 
							<method name="action_has_event">
 | 
				
			||||||
			<return type="bool">
 | 
								<return type="bool">
 | 
				
			||||||
			</return>
 | 
								</return>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue