summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2017-11-01 21:46:37 +1100
committerBastiaan Olij <mux213@gmail.com>2017-11-01 23:59:14 +1100
commit167b7b55338761e3cb48677219d41f5bfc32c839 (patch)
treeb5f3ce606a8ef2cacb163a821cb8639dcda205d7 /scene/3d
parent58889102b6fe3a562e4f5e0cb045def9ff2b1f53 (diff)
Adding rumble support to ARVR controllers (if implemented on the ARVR interface)
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/arvr_nodes.cpp30
-rw-r--r--scene/3d/arvr_nodes.h3
2 files changed, 32 insertions, 1 deletions
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 064a249190..e1e0b9b1ce 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -231,7 +231,7 @@ void ARVRController::_notification(int p_what) {
void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id);
ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id"), "set_controller_id", "get_controller_id");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "1,32,1"), "set_controller_id", "get_controller_id");
ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name);
// passthroughs to information about our related joystick
@@ -242,6 +242,10 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand);
+ ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
+ ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
+
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
};
@@ -299,6 +303,30 @@ float ARVRController::get_joystick_axis(int p_axis) const {
return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
};
+real_t ARVRController::get_rumble() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, 0.0);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ return 0.0;
+ };
+
+ return tracker->get_rumble();
+};
+
+void ARVRController::set_rumble(real_t p_rumble) {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker != NULL) {
+ tracker->set_rumble(p_rumble);
+ };
+};
+
bool ARVRController::get_is_active() const {
return is_active;
};
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index e0ccfab58b..6e940351f2 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -89,6 +89,9 @@ public:
int is_button_pressed(int p_button) const;
float get_joystick_axis(int p_axis) const;
+ real_t get_rumble() const;
+ void set_rumble(real_t p_rumble);
+
bool get_is_active() const;
ARVRPositionalTracker::TrackerHand get_hand() const;