mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-29 21:32:50 -08:00
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { useState } from 'react';
|
|
import { RpcMessage } from 'solarxr-protocol';
|
|
import { RecordBVHRequestT } from 'solarxr-protocol/protocol/typescript/dist/solarxr-protocol/rpc/record-bvhrequest';
|
|
import { RecordBVHStatusT } from 'solarxr-protocol/protocol/typescript/dist/solarxr-protocol/rpc/record-bvhstatus';
|
|
import { useWebsocketAPI } from '../hooks/websocket-api';
|
|
import { BigButton } from './commons/BigButton';
|
|
import { RecordIcon } from './commons/icon/RecordIcon';
|
|
|
|
export function BVHButton() {
|
|
const { useRPCPacket, sendRPCPacket } = useWebsocketAPI();
|
|
const [recording, setRecording] = useState(false);
|
|
|
|
const toggleBVH = () => {
|
|
const record = new RecordBVHRequestT();
|
|
record.stop = recording;
|
|
sendRPCPacket(RpcMessage.RecordBVHRequest, record);
|
|
};
|
|
|
|
useRPCPacket(RpcMessage.RecordBVHStatus, (data: RecordBVHStatusT) => {
|
|
setRecording(data.recording);
|
|
});
|
|
|
|
return (
|
|
<BigButton
|
|
text={recording ? 'Recording...' : 'Record BVH'}
|
|
icon={<RecordIcon width={20} />}
|
|
onClick={toggleBVH}
|
|
></BigButton>
|
|
);
|
|
}
|