Skip to content

Commit 64c8e11

Browse files
committed
add gamepad sensitivity control
1 parent a487564 commit 64c8e11

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

frontend/src/js/frontendConsts.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ export const GAME_CONTROLLER_BUTTON_CONFIG: GpadBtnConfig[] = [
106106
{ btnName: "button_4", helpLabel: "Depth Hold Mode", tooltipPlacement: "left" },
107107
{ btnName: "shoulder_button_front_left", helpLabel: "Open Claw", tooltipPlacement: "right", fireWhileHolding: true, },
108108
{ btnName: "shoulder_button_front_right", helpLabel: "Close Claw", tooltipPlacement: "left", fireWhileHolding: true, },
109-
{ btnName: "shoulder_trigger_back_left", helpLabel: "N/A (Use sholder clicky button instead)", fireWhileHolding: true, tooltipPlacement: "right" },
110-
{ btnName: "shoulder_trigger_back_right", helpLabel: "N/A (Use sholder clicky button instead)", fireWhileHolding: true, tooltipPlacement: "left" },
109+
{ btnName: "shoulder_trigger_back_left", helpLabel: "Slow motors (Use +/- button for claw)", fireWhileHolding: true, tooltipPlacement: "right" },
110+
{ btnName: "shoulder_trigger_back_right", helpLabel: "Slow motors (Use +/- button for claw)", fireWhileHolding: true, tooltipPlacement: "left" },
111111
{ btnName: "select_button", helpLabel: "Move-Roll Toggle", tooltipPlacement: "right" },
112112
{ btnName: "start_button", helpLabel: "Acrobatic Mode", tooltipPlacement: "left" },
113-
{ btnName: "stick_button_left", helpLabel: "Move Forward-Back & Turn (Click & Hold for alt gamepad actions)", tooltipPlacement: "right" },
113+
{ btnName: "stick_button_left", helpLabel: "Move Forward-Back & Turn (TBD: Click & Hold for alt gamepad actions)", tooltipPlacement: "right" },
114114
{ btnName: "stick_button_right", helpLabel: "Move Up-Down & Left-Right", tooltipPlacement: "left" },
115115
{ btnName: "d_pad_up", helpLabel: "Look Up", fireWhileHolding: true, tooltipPlacement: "right" },
116116
{ btnName: "d_pad_down", helpLabel: "Look Down", fireWhileHolding: true, tooltipPlacement: "right" },

frontend/src/js/rovActions.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RovActionsClass {
2222
};
2323
lastMovementTime = 0;
2424
lastPingTime = 0;
25+
sensitivity = 1;
2526

2627
gamepadButtonTriggers(gamepad: Gamepad, buttonsChangedMask: (false | buttonChangeDetails)[]) {
2728

@@ -41,7 +42,8 @@ class RovActionsClass {
4142
if (buttonsChangedMask[BTN_LT] || buttonsChangedMask[BTN_RT]) {
4243
const LT = buttonsChangedMask[BTN_LT] ? gamepad.buttons[BTN_LT].value : 0;
4344
const RT = buttonsChangedMask[BTN_RT] ? gamepad.buttons[BTN_RT].value : 0;
44-
const throttle = Math.round((LT - RT) * 100);
45+
// const throttle = Math.round((LT - RT) * 100);
46+
this.sensitivity = 1 - Math.max(LT, RT) * 0.8
4547
// do something with throttle
4648
}
4749

@@ -67,7 +69,7 @@ class RovActionsClass {
6769
}
6870

6971
gamepadAxisTriggers(gamepad: Gamepad) {
70-
const sensitivity = 0.2;
72+
const sensitivity = this.sensitivity;
7173
const { VelocityX, VelocityY, VelocityZ, AngularVelocityYaw } = calculateDesiredMotion(gamepad.axes);
7274
if (VelocityX == 0 && VelocityY == 0 && VelocityZ == 0 && AngularVelocityYaw == 0) console.info("GAMEPAD MOTION: STOPed")
7375
this.moveRov(VelocityX * sensitivity, VelocityY * sensitivity, VelocityZ * sensitivity, AngularVelocityYaw * sensitivity);

0 commit comments

Comments
 (0)