Browse Source

Add InputEvent::ACTION get/set support for variant
Add action_press/action_release method bind

sanikoyes 10 years ago
parent
commit
317c496f5c
2 changed files with 26 additions and 0 deletions
  1. 2 0
      core/os/input.cpp
  2. 24 0
      core/variant_op.cpp

+ 2 - 0
core/os/input.cpp

@@ -62,6 +62,8 @@ void Input::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode);
 	ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode);
 	ObjectTypeDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode);
 	ObjectTypeDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode);
 	ObjectTypeDB::bind_method(_MD("warp_mouse_pos","to"),&Input::warp_mouse_pos);
 	ObjectTypeDB::bind_method(_MD("warp_mouse_pos","to"),&Input::warp_mouse_pos);
+	ObjectTypeDB::bind_method(_MD("action_press"),&Input::action_press);
+	ObjectTypeDB::bind_method(_MD("action_release"),&Input::action_release);
 
 
 	BIND_CONSTANT( MOUSE_MODE_VISIBLE );
 	BIND_CONSTANT( MOUSE_MODE_VISIBLE );
 	BIND_CONSTANT( MOUSE_MODE_HIDDEN );
 	BIND_CONSTANT( MOUSE_MODE_HIDDEN );

+ 24 - 0
core/variant_op.cpp

@@ -1687,6 +1687,19 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
 					return;
 					return;
 				}
 				}
 			}
 			}
+			if (ie.type == InputEvent::ACTION) {
+
+				if (str =="action") {
+					valid=true;
+					ie.action.action=p_value;
+					return;
+				}
+				else if (str == "pressed") {
+					valid=true;
+					ie.action.pressed=p_value;
+					return;
+				}
+			}
 
 
 		} break;
 		} break;
 		case DICTIONARY: {
 		case DICTIONARY: {
@@ -2365,6 +2378,17 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
 					return Vector2(ie.screen_drag.speed_x,ie.screen_drag.speed_y);
 					return Vector2(ie.screen_drag.speed_x,ie.screen_drag.speed_y);
 				}
 				}
 			}
 			}
+			if (ie.type == InputEvent::ACTION) {
+
+				if (str =="action") {
+					valid=true;
+					return ie.action.action;
+				}
+				else if (str == "pressed") {
+					valid=true;
+					ie.action.pressed;
+				}
+			}
 
 
 		} break;
 		} break;
 		case DICTIONARY: {
 		case DICTIONARY: {