Skip to content

Commit

Permalink
feat(tracker-emulation): add the ability to send the UserAction packe…
Browse files Browse the repository at this point in the history
…t (id 21)
  • Loading branch information
TheDevMinerTV committed Jun 3, 2024
1 parent 1b2cd7f commit 8b9f905
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wise-hornets-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@slimevr/tracker-emulation': patch
---

add the ability to send the UserAction (21) packet
1 change: 1 addition & 0 deletions packages/firmware-protocol/src/packets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './DeviceBoundHandshakePacket';
export * from './DeviceBoundHeartbeatPacket';
export * from './DeviceBoundPingPacket';
export * from './DeviceBoundSensorInfoPacket';
export * from './inspection';
export * from './Packet';
export * from './PacketParser';
export * from './ServerBoundAccelPacket';
Expand Down
8 changes: 7 additions & 1 deletion packages/tracker-emulation/src/EmulatedTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import {
ServerBoundRotationDataPacket,
ServerBoundSignalStrengthPacket,
ServerBoundTemperaturePacket,
ServerFeatureFlags
ServerBoundUserActionPacket,
ServerFeatureFlags,
UserAction
} from '@slimevr/firmware-protocol';
import { createSocket, RemoteInfo, Socket } from 'dgram';
import EventEmitter from 'events';
Expand Down Expand Up @@ -166,6 +168,10 @@ export class EmulatedTracker extends (EventEmitter as {
await this.sendPacketToServer(new ServerBoundSignalStrengthPacket(sensorId, signalStrength));
}

async sendUserAction(action: UserAction) {
await this.sendPacketToServer(new ServerBoundUserActionPacket(action));
}

async sendPacketToServer(packet: Packet) {
if (this.state.status !== 'connected-to-server') return;

Expand Down

0 comments on commit 8b9f905

Please sign in to comment.