From 1383401c71c5e0c7a9fad604caf63085c81b489a Mon Sep 17 00:00:00 2001 From: Logan Lang Date: Wed, 6 Mar 2024 08:43:19 -0600 Subject: [PATCH] Expose profile_changed signal to XRController3D --- doc/classes/XRController3D.xml | 6 ++++++ scene/3d/xr_nodes.cpp | 11 +++++++---- scene/3d/xr_nodes.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/classes/XRController3D.xml b/doc/classes/XRController3D.xml index ee67477eb0c..8a068661c99 100644 --- a/doc/classes/XRController3D.xml +++ b/doc/classes/XRController3D.xml @@ -75,5 +75,11 @@ Emitted when a thumbstick or thumbpad on this controller is moved. + + + + Emitted when the interaction profile on this controller is changed. + + diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp index 70e32c1a310..dfb9042a2ef 100644 --- a/scene/3d/xr_nodes.cpp +++ b/scene/3d/xr_nodes.cpp @@ -461,6 +461,7 @@ void XRController3D::_bind_methods() { ADD_SIGNAL(MethodInfo("button_released", PropertyInfo(Variant::STRING, "name"))); ADD_SIGNAL(MethodInfo("input_float_changed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::FLOAT, "value"))); ADD_SIGNAL(MethodInfo("input_vector2_changed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::VECTOR2, "value"))); + ADD_SIGNAL(MethodInfo("profile_changed", PropertyInfo(Variant::STRING, "role"))); }; void XRController3D::_bind_tracker() { @@ -471,6 +472,7 @@ void XRController3D::_bind_tracker() { tracker->connect("button_released", callable_mp(this, &XRController3D::_button_released)); tracker->connect("input_float_changed", callable_mp(this, &XRController3D::_input_float_changed)); tracker->connect("input_vector2_changed", callable_mp(this, &XRController3D::_input_vector2_changed)); + tracker->connect("profile_changed", callable_mp(this, &XRController3D::_profile_changed)); } } @@ -481,31 +483,32 @@ void XRController3D::_unbind_tracker() { tracker->disconnect("button_released", callable_mp(this, &XRController3D::_button_released)); tracker->disconnect("input_float_changed", callable_mp(this, &XRController3D::_input_float_changed)); tracker->disconnect("input_vector2_changed", callable_mp(this, &XRController3D::_input_vector2_changed)); + tracker->disconnect("profile_changed", callable_mp(this, &XRController3D::_profile_changed)); } XRNode3D::_unbind_tracker(); } void XRController3D::_button_pressed(const String &p_name) { - // just pass it on... emit_signal(SNAME("button_pressed"), p_name); } void XRController3D::_button_released(const String &p_name) { - // just pass it on... emit_signal(SNAME("button_released"), p_name); } void XRController3D::_input_float_changed(const String &p_name, float p_value) { - // just pass it on... emit_signal(SNAME("input_float_changed"), p_name, p_value); } void XRController3D::_input_vector2_changed(const String &p_name, Vector2 p_value) { - // just pass it on... emit_signal(SNAME("input_vector2_changed"), p_name, p_value); } +void XRController3D::_profile_changed(const String &p_role) { + emit_signal(SNAME("profile_changed"), p_role); +} + bool XRController3D::is_button_pressed(const StringName &p_name) const { if (tracker.is_valid()) { // Inputs should already be of the correct type, our XR runtime handles conversions between raw input and the desired type diff --git a/scene/3d/xr_nodes.h b/scene/3d/xr_nodes.h index ad52cf113d1..bdcccd51ea5 100644 --- a/scene/3d/xr_nodes.h +++ b/scene/3d/xr_nodes.h @@ -135,6 +135,7 @@ protected: void _button_released(const String &p_name); void _input_float_changed(const String &p_name, float p_value); void _input_vector2_changed(const String &p_name, Vector2 p_value); + void _profile_changed(const String &p_role); public: bool is_button_pressed(const StringName &p_name) const;