Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fix the controller vibration API #107

Merged
merged 1 commit into from
May 24, 2020

Conversation

m4gr3d
Copy link
Collaborator

@m4gr3d m4gr3d commented May 21, 2020

The vrapi_SetHapticVibrationSimple(...) method is supposed to be called once per frame.
To comply, the new logic batches the vibration requests (last one wins), and fire the method call once per frame during _process if a vibration request for the controller is available.
The API exposed by the plugin is augmented to take a duration_in_ms parameter, which the logic uses to keep firing vrapi_SetHapticVibrationSimple(...) calls until the duration has been reached.

The controller demo has been updated to make the touch controllers vibrate when the A/X button is pressed.

@m4gr3d m4gr3d added this to the 2.0.0 milestone May 21, 2020
@m4gr3d m4gr3d added the enhancement New feature or request label May 21, 2020
@m4gr3d m4gr3d force-pushed the fix_controller_vibration_api branch from d279165 to 09f55d7 Compare May 22, 2020 17:56
@NeoSpark314
Copy link
Collaborator

Later today I will be able to give this a test-run. Just a quick question. How does this new rumble API relate to the godot ARVRController.set_rumble(float) (https://docs.godotengine.org/en/stable/classes/class_arvrcontroller.html)
that is implemented here

void OvrMobileController::update_controller_vibration(ovrMobile *ovr, ControllerState& controller_state) {
?

@m4gr3d
Copy link
Collaborator Author

m4gr3d commented May 24, 2020

Later today I will be able to give this a test-run. Just a quick question. How does this new rumble API relate to the godot ARVRController.set_rumble(float) (https://docs.godotengine.org/en/stable/classes/class_arvrcontroller.html)
that is implemented here

void OvrMobileController::update_controller_vibration(ovrMobile *ovr, ControllerState& controller_state) {

?

It's a superset of that API.
With this PR, there are now two ways to make the controllers vibrate:

  • Either the ARVRController.set_rumble(float) is used, in which case same behavior as before.
  • Or the OvrInput.vibrate_controller method can be used, in which case the vibration request is batched and executed in the next frame (unless a new request overrides it).

Although I do see your point that now in GDScript there are two ways to do the same thing.
I'll drop the GDScript API binding for this change, so that controller vibration is only done via the ARVRController node. I'll leave java/kotlin binding since that layer doesn't have access to the ARVRController node.

@m4gr3d m4gr3d force-pushed the fix_controller_vibration_api branch from 09f55d7 to cc5ef67 Compare May 24, 2020 18:29
The vrapi_SetHapticVibrationSimple(...) method is supposed to be called once per frame.
To comply, the new logic batches the vibration requests (last one wins), and fire the method call once per frame during `_process` if a vibration request for the controller is available.
The API exposed by the plugin is augmented to take a `duration_in_ms` parameter, which the logic uses to keep firing vrapi_SetHapticVibrationSimple(...) calls until the duration has been reached.
@m4gr3d m4gr3d force-pushed the fix_controller_vibration_api branch from cc5ef67 to 46615b7 Compare May 24, 2020 20:15
@m4gr3d m4gr3d merged commit 2f169d1 into GodotVR:master May 24, 2020
@m4gr3d m4gr3d deleted the fix_controller_vibration_api branch May 24, 2020 20:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants