Skip to content

Commit

Permalink
Fix controller float input
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiaanOlij authored and m4gr3d committed Feb 8, 2022
1 parent 2e66528 commit 7343d54
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions demo/addons/godot-openxr/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changes to the Godot OpenXR asset
- Added controller tracking confidence
- Use correct predictive timing for controllers.
- Renamed `FPSController` node of the first person controller scene to `FPController`.
- Fixed output range for the trigger and grip values.

1.1.1
-------------------
Expand Down
4 changes: 2 additions & 2 deletions src/openxr/OpenXRApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2775,10 +2775,10 @@ void OpenXRApi::update_actions() {
// Button and axis are hardcoded..
// Axis
if (default_actions[ACTION_FRONT_TRIGGER].action != NULL) {
arvr_api->godot_arvr_set_controller_axis(godot_controller, 2, default_actions[ACTION_FRONT_TRIGGER].action->get_as_float(input_path), false); // 0.0 -> 1.0
arvr_api->godot_arvr_set_controller_axis(godot_controller, 2, default_actions[ACTION_FRONT_TRIGGER].action->get_as_float(input_path), true); // 0.0 -> 1.0
}
if (default_actions[ACTION_SIDE_TRIGGER].action != NULL) {
arvr_api->godot_arvr_set_controller_axis(godot_controller, 4, default_actions[ACTION_SIDE_TRIGGER].action->get_as_float(input_path), false); // 0.0 -> 1.0
arvr_api->godot_arvr_set_controller_axis(godot_controller, 4, default_actions[ACTION_SIDE_TRIGGER].action->get_as_float(input_path), true); // 0.0 -> 1.0
}
if (default_actions[ACTION_PRIMARY].action != NULL) {
Vector2 v = default_actions[ACTION_PRIMARY].action->get_as_vector(input_path);
Expand Down
7 changes: 7 additions & 0 deletions src/openxr/actions/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ float Action::get_as_float(XrPath p_path) {

// we should do something with resultState.isActive

// clamp our value between -1.0 and 1.0, shouldn't be outside of this range but better safe then sorry...
if (resultState.currentState < -1.0) {
resultState.currentState = -1.0;
} else if (resultState.currentState > 1.0) {
resultState.currentState = 1.0;
}

return resultState.currentState;
}
}
Expand Down

0 comments on commit 7343d54

Please sign in to comment.