Files
orca/src/shared/emulator-touch-frame.ts
T
2026-06-08 00:08:57 -07:00

19 lines
496 B
TypeScript

export type ServeSimTouchType = 'begin' | 'move' | 'end'
export type ServeSimTouchFrame = {
type: ServeSimTouchType
x: number
y: number
edge?: number
}
export const SERVE_SIM_TOUCH_MESSAGE_TAG = 0x03
export function encodeServeSimTouchFrame(touch: ServeSimTouchFrame): Uint8Array<ArrayBuffer> {
const json = new TextEncoder().encode(JSON.stringify(touch))
const frame = new Uint8Array(1 + json.length)
frame[0] = SERVE_SIM_TOUCH_MESSAGE_TAG
frame.set(json, 1)
return frame
}