Skip to content

Commit

Permalink
Merge pull request #45054 from dsnopek/webxr-yaxis-master
Browse files Browse the repository at this point in the history
Invert the Y-axis on thumbsticks and trackpads in WebXR
  • Loading branch information
akien-mga authored Jan 10, 2021
2 parents a594243 + 7a0d427 commit c3b23f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/webxr/native/library_godot_webxr.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,13 @@ const GodotWebXR = {
const buf = GodotRuntime.malloc((axes_count + 1) * 4);
GodotRuntime.setHeapValue(buf, axes_count, 'i32');
for (let i = 0; i < axes_count; i++) {
GodotRuntime.setHeapValue(buf + 4 + (i * 4), controller.gamepad.axes[i], 'float');
let value = controller.gamepad.axes[i];
if (i === 1 || i === 3) {
// Invert the Y-axis on thumbsticks and trackpads, in order to
// match OpenXR and other XR platform SDKs.
value *= -1.0;
}
GodotRuntime.setHeapValue(buf + 4 + (i * 4), value, 'float');
}
return buf;
},
Expand Down

0 comments on commit c3b23f0

Please sign in to comment.