This commit is contained in:
legop3
2025-12-02 14:43:56 -05:00
parent 9bc5d2d06d
commit ace39d5a70
21 changed files with 238 additions and 18 deletions
+6
View File
@@ -254,6 +254,10 @@ export function ControlSystemProvider({ children }) {
[pipeline],
);
const toggleNightVision = useCallback(() => {
pipeline.sendNightVision('toggle');
}, [pipeline]);
const registerInputState = useCallback((source, data) => {
dispatch({ type: 'control/register-input-state', payload: { source, state: data } });
}, []);
@@ -274,6 +278,7 @@ export function ControlSystemProvider({ children }) {
stopAllMotion,
sendOiCommand,
setSensorStream,
toggleNightVision,
updateKeyBinding,
resetKeyBindings,
registerInputState,
@@ -292,6 +297,7 @@ export function ControlSystemProvider({ children }) {
stopAllMotion,
sendOiCommand,
setSensorStream,
toggleNightVision,
updateKeyBinding,
resetKeyBindings,
registerInputState,
+21
View File
@@ -19,6 +19,11 @@ export function useCommandPipeline() {
return rosterEntry.cameraServo;
}, [rosterEntry]);
const nightVision = useMemo(() => {
if (!rosterEntry?.nightVision || !rosterEntry.nightVision.enabled) return null;
return rosterEntry.nightVision;
}, [rosterEntry]);
const emitCommand = useCallback(
(payload, cb) => {
if (!roverId) return;
@@ -134,29 +139,45 @@ export function useCommandPipeline() {
[roverId, sendOiCommand, sendDriveDirect, sendAuxMotors, sendServoAngle],
);
const sendNightVision = useCallback(
(action = 'toggle') => {
if (!roverId || !nightVision) return null;
emitCommand({
type: 'nightVision',
data: { nightVision: { action } },
});
return action;
},
[emitCommand, nightVision, roverId],
);
return useMemo(
() => ({
roverId,
rosterEntry,
servoConfig,
nightVision,
emitCommand,
enableSensorStream,
sendDriveDirect,
sendAuxMotors,
sendServoAngle,
sendOiCommand,
sendNightVision,
runMacroSteps,
}),
[
roverId,
rosterEntry,
servoConfig,
nightVision,
emitCommand,
enableSensorStream,
sendDriveDirect,
sendAuxMotors,
sendServoAngle,
sendOiCommand,
sendNightVision,
runMacroSteps,
],
);
+1
View File
@@ -36,6 +36,7 @@ export const DEFAULT_KEYMAP = {
auxAllForward: [","],
cameraUp: ['u'],
cameraDown: ['j'],
nightVisionToggle: ['e'],
driveMacro: ['f'],
dockMacro: ['g'],
chatFocus: ['enter'],
@@ -86,6 +86,7 @@ export default function KeyboardInputManager() {
runMacro,
stopAllMotion,
registerInputState,
toggleNightVision,
},
} = useControlSystem();
const { focusChat, blurChat, isChatFocused } = useChat();
@@ -208,6 +209,8 @@ export default function KeyboardInputManager() {
} else if (newlyPressed.some((token) => keymap.dockMacro?.has(token))) {
setMode('dock');
runMacro('seek-dock');
} else if (newlyPressed.some((token) => keymap.nightVisionToggle?.has(token))) {
toggleNightVision();
}
}