| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  input_event.cpp                                                      */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                    http://www.godotengine.org                         */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2017-01-01 22:01:57 +01:00
										 |  |  | /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							| 
									
										
										
										
											2017-04-08 00:11:42 +02:00
										 |  |  | /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* 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.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | #include "input_event.h"
 | 
					
						
							|  |  |  | #include "input_map.h"
 | 
					
						
							|  |  |  | #include "os/keyboard.h"
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | void InputEvent::set_id(uint32_t p_id) { | 
					
						
							|  |  |  | 	id = p_id; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | uint32_t InputEvent::get_id() const { | 
					
						
							|  |  |  | 	return id; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-08-23 08:14:04 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | void InputEvent::set_device(int p_device) { | 
					
						
							|  |  |  | 	device = p_device; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | int InputEvent::get_device() const { | 
					
						
							|  |  |  | 	return device; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | bool InputEvent::is_pressed() const { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | bool InputEvent::is_action(const StringName &p_action) const { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-23 08:13:11 -03:00
										 |  |  | 	return InputMap::get_singleton()->event_is_action(Ref<InputEvent>((InputEvent *)this), p_action); | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | bool InputEvent::is_action_pressed(const StringName &p_action) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; // InputMap::get_singleton()->event_is_action(Ref<InputEvent>(this),p_action);
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEvent::is_action_released(const StringName &p_action) const { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEvent::is_echo() const { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Ref<InputEvent> InputEvent::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return Ref<InputEvent>((InputEvent *)this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | String InputEvent::as_text() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return String(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEvent::action_match(const Ref<InputEvent> &p_event) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEvent::is_action_type() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  | if (String(p_method) == "is_action" && p_argidx == 0) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	List<PropertyInfo> pinfo; | 
					
						
							|  |  |  | 	GlobalConfig::get_singleton()->get_property_list(&pinfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		const PropertyInfo &pi = E->get(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!pi.name.begins_with("input/")) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); | 
					
						
							|  |  |  | 		result.insert("\"" + name + "\""); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } else | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEvent::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_id", "id"), &InputEvent::set_id); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_id"), &InputEvent::get_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_device", "device"), &InputEvent::set_device); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_device"), &InputEvent::get_device); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_pressed"), &InputEvent::is_pressed); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_action", "action"), &InputEvent::is_action); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &InputEvent::is_action_pressed); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_action_released", "action"), &InputEvent::is_action_released); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_echo"), &InputEvent::is_echo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("action_match", "event:InputEvent"), &InputEvent::action_match); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("xformed_by:InputEvent", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEvent::InputEvent() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	id = 0; | 
					
						
							|  |  |  | 	device = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventWithModifiers::set_shift(bool p_enabled) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	shift = p_enabled; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEventWithModifiers::get_shift() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return shift; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventWithModifiers::set_alt(bool p_enabled) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	alt = p_enabled; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventWithModifiers::get_alt() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return alt; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventWithModifiers::set_control(bool p_enabled) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	control = p_enabled; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventWithModifiers::get_control() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return control; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventWithModifiers::set_metakey(bool p_enabled) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	meta = p_enabled; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventWithModifiers::get_metakey() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return meta; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventWithModifiers::set_command(bool p_enabled) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	command = p_enabled; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventWithModifiers::get_command() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return command; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventWithModifiers::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_alt", "enable"), &InputEventWithModifiers::set_alt); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_alt"), &InputEventWithModifiers::get_alt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_shift", "enable"), &InputEventWithModifiers::set_shift); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_shift"), &InputEventWithModifiers::get_shift); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_control", "enable"), &InputEventWithModifiers::set_control); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_control"), &InputEventWithModifiers::get_control); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_metakey", "enable"), &InputEventWithModifiers::set_metakey); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_metakey"), &InputEventWithModifiers::get_metakey); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_command", "enable"), &InputEventWithModifiers::set_command); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_command"), &InputEventWithModifiers::get_command); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "alt"), "set_alt", "get_alt"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shift"), "set_shift", "get_shift"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "control"), "set_control", "get_control"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta"), "set_metakey", "get_metakey"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command"), "set_command", "get_command"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventWithModifiers::InputEventWithModifiers() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	alt = false; | 
					
						
							|  |  |  | 	shift = false; | 
					
						
							|  |  |  | 	control = false; | 
					
						
							|  |  |  | 	meta = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventKey::set_pressed(bool p_pressed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressed = p_pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 21:54:18 +02:00
										 |  |  | bool InputEventKey::is_pressed() const { | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return pressed; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | void InputEventKey::set_scancode(uint32_t p_scancode) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	scancode = p_scancode; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | uint32_t InputEventKey::get_scancode() const { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	return scancode; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | void InputEventKey::set_unicode(uint32_t p_unicode) { | 
					
						
							| 
									
										
										
										
											2015-06-23 16:24:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	unicode = p_unicode; | 
					
						
							| 
									
										
										
										
											2015-06-23 16:24:48 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | uint32_t InputEventKey::get_unicode() const { | 
					
						
							| 
									
										
										
										
											2015-06-23 16:24:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	return unicode; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventKey::set_echo(bool p_enable) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo = p_enable; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventKey::is_echo() const { | 
					
						
							| 
									
										
										
										
											2015-06-23 16:24:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	return echo; | 
					
						
							| 
									
										
										
										
											2015-06-23 16:24:48 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | uint32_t InputEventKey::get_scancode_with_modifiers() const { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	uint32_t sc = scancode; | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	if (get_control()) | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		sc |= KEY_MASK_CTRL; | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	if (get_alt()) | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		sc |= KEY_MASK_ALT; | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	if (get_shift()) | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		sc |= KEY_MASK_SHIFT; | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	if (get_metakey()) | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		sc |= KEY_MASK_META; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return sc; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-06-27 09:59:43 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | bool InputEventKey::action_match(const Ref<InputEvent> &p_event) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventKey> key = p_event; | 
					
						
							|  |  |  | 	if (key.is_null()) | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return get_scancode_with_modifiers() == key->get_scancode_with_modifiers(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventKey::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventKey::set_pressed); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_scancode", "scancode"), &InputEventKey::set_scancode); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_scancode"), &InputEventKey::get_scancode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_unicode", "unicode"), &InputEventKey::set_unicode); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_unicode"), &InputEventKey::get_unicode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_echo", "echo"), &InputEventKey::set_echo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_scancode_with_modifiers"), &InputEventKey::get_scancode_with_modifiers); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "scancode"), "set_scancode", "get_scancode"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "echo"), "set_echo", "is_echo"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventKey::InputEventKey() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressed = false; | 
					
						
							|  |  |  | 	scancode = 0; | 
					
						
							|  |  |  | 	unicode = 0; ///unicode
 | 
					
						
							|  |  |  | 	echo = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouse::set_button_mask(int p_mask) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	button_mask = p_mask; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | int InputEventMouse::get_button_mask() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return button_mask; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouse::set_pos(const Vector2 &p_pos) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pos = p_pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventMouse::get_pos() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouse::set_global_pos(const Vector2 &p_global_pos) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	global_pos = p_global_pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventMouse::get_global_pos() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return global_pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouse::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_button_mask", "button_mask"), &InputEventMouse::set_button_mask); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_button_mask"), &InputEventMouse::get_button_mask); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pos", "pos"), &InputEventMouse::set_pos); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_pos"), &InputEventMouse::get_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_global_pos", "global_pos"), &InputEventMouse::set_global_pos); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_global_pos"), &InputEventMouse::get_global_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "button_mask"), "set_button_mask", "get_button_mask"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pos"), "set_pos", "get_pos"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_pos"), "set_global_pos", "get_global_pos"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventMouse::InputEventMouse() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	button_mask = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ///////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseButton::set_factor(float p_factor) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	factor = p_factor; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | float InputEventMouseButton::get_factor() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return factor; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseButton::set_button_index(int p_index) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	button_index = p_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | int InputEventMouseButton::get_button_index() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return button_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseButton::set_pressed(bool p_pressed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressed = p_pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventMouseButton::is_pressed() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseButton::set_doubleclick(bool p_doubleclick) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	doubleclick = p_doubleclick; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventMouseButton::is_doubleclick() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return doubleclick; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Vector2 g = p_xform.xform(get_global_pos()); | 
					
						
							|  |  |  | 	Vector2 l = p_xform.xform(get_pos() + p_local_ofs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventMouseButton> mb; | 
					
						
							|  |  |  | 	mb.instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mb->set_id(get_id()); | 
					
						
							|  |  |  | 	mb->set_device(get_device()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mb->set_alt(get_alt()); | 
					
						
							|  |  |  | 	mb->set_shift(get_shift()); | 
					
						
							|  |  |  | 	mb->set_control(get_control()); | 
					
						
							|  |  |  | 	mb->set_metakey(get_metakey()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mb->set_pos(l); | 
					
						
							|  |  |  | 	mb->set_global_pos(g); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mb->set_button_mask(get_button_mask()); | 
					
						
							|  |  |  | 	mb->set_pressed(pressed); | 
					
						
							|  |  |  | 	mb->set_doubleclick(doubleclick); | 
					
						
							|  |  |  | 	mb->set_factor(factor); | 
					
						
							|  |  |  | 	mb->set_button_index(button_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return mb; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventMouseButton> mb = p_event; | 
					
						
							|  |  |  | 	if (mb.is_null()) | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return mb->button_index == button_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseButton::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMouseButton::set_factor); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMouseButton::get_factor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventMouseButton::set_button_index); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventMouseButton::get_button_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventMouseButton::set_pressed); | 
					
						
							|  |  |  | 	//	ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventMouseButton::is_pressed);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_doubleclick", "doubleclick"), &InputEventMouseButton::set_doubleclick); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("is_doubleclick"), &InputEventMouseButton::is_doubleclick); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventMouseButton::InputEventMouseButton() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-24 09:40:42 +02:00
										 |  |  | 	factor = 1; | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	button_index = 0; | 
					
						
							|  |  |  | 	pressed = false; | 
					
						
							|  |  |  | 	doubleclick = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseMotion::set_relative(const Vector2 &p_relative) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	relative = p_relative; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventMouseMotion::get_relative() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return relative; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseMotion::set_speed(const Vector2 &p_speed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	speed = p_speed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventMouseMotion::get_speed() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return speed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Vector2 g = p_xform.xform(get_global_pos()); | 
					
						
							|  |  |  | 	Vector2 l = p_xform.xform(get_pos() + p_local_ofs); | 
					
						
							|  |  |  | 	Vector2 r = p_xform.basis_xform(get_relative()); | 
					
						
							|  |  |  | 	Vector2 s = p_xform.basis_xform(get_speed()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventMouseMotion> mm; | 
					
						
							|  |  |  | 	mm.instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mm->set_id(get_id()); | 
					
						
							|  |  |  | 	mm->set_device(get_device()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mm->set_alt(get_alt()); | 
					
						
							|  |  |  | 	mm->set_shift(get_shift()); | 
					
						
							|  |  |  | 	mm->set_control(get_control()); | 
					
						
							|  |  |  | 	mm->set_metakey(get_metakey()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mm->set_pos(l); | 
					
						
							|  |  |  | 	mm->set_global_pos(g); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mm->set_button_mask(get_button_mask()); | 
					
						
							|  |  |  | 	mm->set_relative(r); | 
					
						
							|  |  |  | 	mm->set_speed(s); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return mm; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventMouseMotion::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_relative"), &InputEventMouseMotion::get_relative); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventMouseMotion::set_speed); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventMouseMotion::InputEventMouseMotion() { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadMotion::set_axis(int p_axis) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	axis = p_axis; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int InputEventJoypadMotion::get_axis() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return axis; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadMotion::set_axis_value(float p_value) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	axis_value = p_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | float InputEventJoypadMotion::get_axis_value() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return axis_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventJoypadMotion> jm = p_event; | 
					
						
							|  |  |  | 	if (jm.is_null()) | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return (axis == jm->axis && (axis_value < 0) == (jm->axis_value < 0)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadMotion::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_axis"), &InputEventJoypadMotion::get_axis); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_axis_value", "axis_value"), &InputEventJoypadMotion::set_axis_value); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_axis_value"), &InputEventJoypadMotion::get_axis_value); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::REAL, "axis_value"), "set_axis_value", "get_axis_value"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventJoypadMotion::InputEventJoypadMotion() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	axis = 0; | 
					
						
							|  |  |  | 	axis_value = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | /////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadButton::set_button_index(int p_index) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	button_index = p_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int InputEventJoypadButton::get_button_index() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return button_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadButton::set_pressed(bool p_pressed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressed = p_pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventJoypadButton::is_pressed() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadButton::set_pressure(float p_pressure) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressure = p_pressure; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | float InputEventJoypadButton::get_pressure() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pressure; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventJoypadButton> jb = p_event; | 
					
						
							|  |  |  | 	if (jb.is_null()) | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return button_index == jb->button_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventJoypadButton::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventJoypadButton::get_button_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventJoypadButton::set_pressure); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventJoypadButton::get_pressure); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventJoypadButton::set_pressed); | 
					
						
							|  |  |  | 	//	ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventJoypadButton::is_pressed);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventJoypadButton::InputEventJoypadButton() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	button_index = 0; | 
					
						
							|  |  |  | 	pressure = 0; | 
					
						
							|  |  |  | 	pressed = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenTouch::set_index(int p_index) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	index = p_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | int InputEventScreenTouch::get_index() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenTouch::set_pos(const Vector2 &p_pos) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pos = p_pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventScreenTouch::get_pos() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenTouch::set_pressed(bool p_pressed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressed = p_pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventScreenTouch::is_pressed() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventScreenTouch> st; | 
					
						
							|  |  |  | 	st.instance(); | 
					
						
							|  |  |  | 	st->set_id(get_id()); | 
					
						
							|  |  |  | 	st->set_device(get_device()); | 
					
						
							|  |  |  | 	st->set_index(index); | 
					
						
							|  |  |  | 	st->set_pos(p_xform.xform(pos + p_local_ofs)); | 
					
						
							|  |  |  | 	st->set_pressed(pressed); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return st; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenTouch::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenTouch::set_index); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenTouch::get_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pos", "pos"), &InputEventScreenTouch::set_pos); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_pos"), &InputEventScreenTouch::get_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventScreenTouch::set_pressed); | 
					
						
							|  |  |  | 	//ClassDB::bind_method(D_METHOD("is_pressed"),&InputEventScreenTouch::is_pressed);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pos"), "set_pos", "get_pos"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventScreenTouch::InputEventScreenTouch() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	index = 0; | 
					
						
							|  |  |  | 	pressed = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenDrag::set_index(int p_index) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	index = p_index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int InputEventScreenDrag::get_index() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenDrag::set_pos(const Vector2 &p_pos) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pos = p_pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventScreenDrag::get_pos() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pos; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenDrag::set_relative(const Vector2 &p_relative) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	relative = p_relative; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventScreenDrag::get_relative() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return relative; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenDrag::set_speed(const Vector2 &p_speed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	speed = p_speed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | Vector2 InputEventScreenDrag::get_speed() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return speed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<InputEventScreenDrag> sd; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sd.instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sd->set_id(get_id()); | 
					
						
							|  |  |  | 	sd->set_device(get_device()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sd->set_index(index); | 
					
						
							|  |  |  | 	sd->set_pos(p_xform.xform(pos + p_local_ofs)); | 
					
						
							|  |  |  | 	sd->set_relative(p_xform.basis_xform(relative)); | 
					
						
							|  |  |  | 	sd->set_speed(p_xform.basis_xform(speed)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return sd; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventScreenDrag::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenDrag::get_index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pos", "pos"), &InputEventScreenDrag::set_pos); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_pos"), &InputEventScreenDrag::get_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventScreenDrag::set_relative); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_relative"), &InputEventScreenDrag::get_relative); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventScreenDrag::set_speed); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_speed"), &InputEventScreenDrag::get_speed); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pos"), "set_pos", "get_pos"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | InputEventScreenDrag::InputEventScreenDrag() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	index = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | /////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventAction::set_action(const StringName &p_action) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	action = p_action; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | StringName InputEventAction::get_action() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return action; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventAction::set_pressed(bool p_pressed) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pressed = p_pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | bool InputEventAction::is_pressed() const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return pressed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool InputEventAction::is_action(const StringName &p_action) const { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return action == p_action; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void InputEventAction::_bind_methods() { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_action", "action"), &InputEventAction::set_action); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("get_action"), &InputEventAction::get_action); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventAction::set_pressed); | 
					
						
							|  |  |  | 	//ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventAction::is_pressed);
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-23 09:06:22 -03:00
										 |  |  | 	//	ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action);
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action"); | 
					
						
							|  |  |  | 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-06-27 09:59:43 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | InputEventAction::InputEventAction() { | 
					
						
							|  |  |  | 	pressed = false; | 
					
						
							| 
									
										
										
										
											2016-06-27 09:59:43 -03:00
										 |  |  | } |