Files
orca/src/preload/api/emulator-api.ts
T
Kelvin Amoaba be3d9b7e86 fix(emulator): type and paste into the Android emulator pane (#37139)
The pane's keyboard only sent serve-sim HID frames over the iOS WebSocket.
Android sessions have no serve-sim socket, so every key was dropped and every
paste failed with "device is not ready".

Android panes now send typed characters, paste and editing keys over a new
emulator:scrcpyKeyboard IPC beside emulator:scrcpyTouch, keyed by the streamed
serial. Main writes them straight to the live scrcpy control socket (text
injection, and keycodes with SHIFT_LEFT held for Shift), so keys keep their
order with touches. iOS keeps the HID path.
2026-11-01 20:21:15 +00:00

48 lines
1.6 KiB
TypeScript

export type EmulatorApi = {
onPaneFocus: (callback: (data: { worktreeId: string }) => void) => () => void
onAutoAttach: (
callback: (data: {
worktreeId: string
info: { deviceUdid: string; streamUrl: string; wsUrl: string; axUrl?: string }
}) => void
) => () => void
startFrameStream: (args: { streamUrl: string; streamKey?: string }) => Promise<{
streamId: string
}>
stopFrameStream: (args: { streamId: string }) => Promise<void>
onFrameStreamFrame: (
callback: (data: { streamId: string; bytes: ArrayBuffer }) => void
) => () => void
onFrameStreamError: (
callback: (data: { streamId: string; message: string }) => void
) => () => void
startVideoStream: (args: { deviceId: string; streamId: string }) => Promise<{ streamId: string }>
stopVideoStream: (args: { streamId: string }) => Promise<void>
onVideoStreamMeta: (
callback: (data: {
streamId: string
deviceId: string
meta: { codecId: string; width: number; height: number }
}) => void
) => () => void
sendScrcpyTouch: (touch: {
deviceId: string
type: 'begin' | 'move' | 'end'
x: number
y: number
}) => void
/** Resolves false when the device has no live scrcpy control socket. */
sendScrcpyKeyboard: (
input: { deviceId: string; text: string } | { deviceId: string; key: string; shift: boolean }
) => Promise<boolean>
onVideoStreamFrame: (
callback: (data: {
streamId: string
deviceId: string
config: boolean
keyFrame: boolean
bytes: ArrayBuffer
}) => void
) => () => void
}