From 2a722a8c64186ead1aa7212fbca868705f2eee25 Mon Sep 17 00:00:00 2001 From: ARRYTHEBEAST Date: Mon, 27 Jan 2025 18:45:21 -0800 Subject: [PATCH 1/2] add a new state and update the state in science input --- src/store/inputSlice.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/store/inputSlice.js b/src/store/inputSlice.js index 4fd6f48..37d6a6a 100644 --- a/src/store/inputSlice.js +++ b/src/store/inputSlice.js @@ -52,7 +52,8 @@ const initialState = { ikForward: 0, }, science: { - lazySusanPosition: 0 + lazySusanPosition: 0, + instrumentationArm: 0 } }, inverseKinematics: { @@ -251,6 +252,7 @@ function computeScienceInput(prevState, state, action) { if (lazySusanAxis !== prevLazySusanAxis) scienceInput.lazySusanPosition = (((scienceInput.lazySusanPosition + lazySusanAxis) % 6) + 6) % 6; + scienceInput.instrumentationArm = getAxisFromButtons(prevPressedKeys, "C", "V"); } function getAxisFromButtons(gamepad, negativeButton, positiveButton) { From 616d430f1d83165c89e65de24ba0bb0340e01162 Mon Sep 17 00:00:00 2001 From: ARRYTHEBEAST Date: Sat, 1 Feb 2025 12:19:06 -0800 Subject: [PATCH 2/2] add toggleKey function --- src/store/inputSlice.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/store/inputSlice.js b/src/store/inputSlice.js index 37d6a6a..a0f0069 100644 --- a/src/store/inputSlice.js +++ b/src/store/inputSlice.js @@ -53,7 +53,9 @@ const initialState = { }, science: { lazySusanPosition: 0, - instrumentationArm: 0 + instrumentationArm: 0, + drillOn: false + } }, inverseKinematics: { @@ -172,7 +174,7 @@ function computeDriveInput(state, action) { driveInput.left = driveGamepad["LeftStickY"] + getAxisFromKeys(pressedKeys, "ARROWDOWN", "ARROWLEFT") driveInput.right = driveGamepad["RightStickY"] + getAxisFromKeys(pressedKeys, "ARROWRIGHT", "ARROWUP"); driveInput.crab = driveGamepad["LeftStickX"] + getAxisFromKeys(pressedKeys, "ARROWDOWN", "ARROWUP"); - + driveInput.activeSuspension = getAxisFromButtons(driveGamepad, "DPadDown", "DPadUp") + getAxisFromKeys(pressedKeys, "B", "M"); // Apply precision controls and clamp. @@ -252,7 +254,8 @@ function computeScienceInput(prevState, state, action) { if (lazySusanAxis !== prevLazySusanAxis) scienceInput.lazySusanPosition = (((scienceInput.lazySusanPosition + lazySusanAxis) % 6) + 6) % 6; - scienceInput.instrumentationArm = getAxisFromButtons(prevPressedKeys, "C", "V"); + scienceInput.instrumentationArm = getAxisFromKeys(prevPressedKeys, "C", "V"); + scienceInput.drillOn = toggleKey(prevPressedKeys,pressedKeys, "B", scienceInput.drillOn); } function getAxisFromButtons(gamepad, negativeButton, positiveButton) { @@ -269,6 +272,10 @@ function getAxisFromKeys(pressedKeys, negativeKey, positiveKey) { return axis; } +function toggleKey(pressedKeys, key, currState) { + if ((!prevPressedKeys.includes(key)) && pressedKeys.includes(key)) return !currState; +} + function getPrecisionMultiplier(pressedKeys, gamepad) { let multiplier = 1; if (pressedKeys.includes("SHIFT"))