Files
VRCT/src-ui/logics/configs/device/useMicThreshold.js
Sakamoto Shiina d44c2dd7d9 [Refactor] Refactor the way import files.
Organize some codes.
2024-10-11 00:23:52 +09:00

42 lines
1.5 KiB
JavaScript

import { useStore_MicThreshold, useStore_EnableAutomaticMicThreshold } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
export const useMicThreshold = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { updateMicThreshold, currentMicThreshold } = useStore_MicThreshold();
const { updateEnableAutomaticMicThreshold, currentEnableAutomaticMicThreshold, pendingEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold();
const getMicThreshold = () => {
asyncStdoutToPython("/get/data/mic_threshold");
};
const setMicThreshold = (mic_threshold) => {
asyncStdoutToPython("/set/data/mic_threshold", mic_threshold);
};
const getEnableAutomaticMicThreshold = () => {
pendingEnableAutomaticMicThreshold();
asyncStdoutToPython("/get/data/mic_automatic_threshold");
};
const toggleEnableAutomaticMicThreshold = () => {
pendingEnableAutomaticMicThreshold();
if (currentEnableAutomaticMicThreshold.data) {
asyncStdoutToPython("/set/disable/mic_automatic_threshold");
} else {
asyncStdoutToPython("/set/enable/mic_automatic_threshold");
}
};
return {
currentMicThreshold,
getMicThreshold,
setMicThreshold,
updateMicThreshold,
currentEnableAutomaticMicThreshold,
getEnableAutomaticMicThreshold,
toggleEnableAutomaticMicThreshold,
updateEnableAutomaticMicThreshold,
};
};