diff --git a/libraries/adb-scrcpy/src/options/2_3.ts b/libraries/adb-scrcpy/src/options/2_3.ts new file mode 100644 index 000000000..ab9aaabf8 --- /dev/null +++ b/libraries/adb-scrcpy/src/options/2_3.ts @@ -0,0 +1,57 @@ +import type { Adb } from "@gasol/adb"; +import type { + ScrcpyDisplay, + ScrcpyEncoder, + ScrcpyOptionsInit2_3, +} from "@gasol/scrcpy"; + +import type { AdbScrcpyConnection } from "../connection.js"; + +import { AdbScrcpyOptions1_16 } from "./1_16.js"; +import { AdbScrcpyOptions2_0 } from "./2_0.js"; +import { AdbScrcpyOptions } from "./types.js"; + +export class AdbScrcpyOptions2_3 extends AdbScrcpyOptions< + // Only pick options that are used in this class, + // so changes in `ScrcpyOptionsInitX_XX` won't affect type assignability with this class + Pick< + ScrcpyOptionsInit2_3, + | "displayOrientation" + | "tunnelForward" + | "control" + | "sendDummyByte" + | "scid" + | "audio" + | "video" + > +> { + override async getEncoders( + adb: Adb, + path: string, + version: string, + ): Promise { + return AdbScrcpyOptions2_0.getEncoders(adb, path, version, this); + } + + override getDisplays( + adb: Adb, + path: string, + version: string, + ): Promise { + return AdbScrcpyOptions1_16.getDisplays(adb, path, version, this); + } + + override createConnection(adb: Adb): AdbScrcpyConnection { + return AdbScrcpyOptions1_16.createConnection( + adb, + { + scid: this.value.scid.value, + video: this.value.video, + audio: this.value.audio, + control: this.value.control, + sendDummyByte: this.value.sendDummyByte, + }, + this.tunnelForwardOverride || this.value.tunnelForward, + ); + } +} diff --git a/libraries/scrcpy/src/options/2_3.spec.ts b/libraries/scrcpy/src/options/2_3.spec.ts new file mode 100644 index 000000000..cd0352ebb --- /dev/null +++ b/libraries/scrcpy/src/options/2_3.spec.ts @@ -0,0 +1,15 @@ +import * as assert from "node:assert"; +import { describe, it } from "node:test"; + +import { ScrcpyDisplayOrientation2_3, ScrcpyOptions2_3 } from "./2_3.js"; + +describe("ScrcpyOptions2_3", () => { + describe("displayOrientation", () => { + it("should set `displayOrientation` to `flip180`", () => { + const options = new ScrcpyOptions2_3({ + displayOrientation: ScrcpyDisplayOrientation2_3.Flip180, + }); + assert.strictEqual(options.value.displayOrientation, "flip180"); + }); + }); +}); diff --git a/libraries/scrcpy/src/options/2_3.ts b/libraries/scrcpy/src/options/2_3.ts index 35341ab84..f7c3b03ea 100644 --- a/libraries/scrcpy/src/options/2_3.ts +++ b/libraries/scrcpy/src/options/2_3.ts @@ -9,14 +9,28 @@ import type { ScrcpyAudioStreamMetadata } from "./codec.js"; import { ScrcpyAudioCodec } from "./codec.js"; import { ScrcpyOptions } from "./types.js"; +// https://github.com/Genymobile/scrcpy/pull/4441 +export enum ScrcpyDisplayOrientation2_3 { + Zero = "0", + Ninety = "90", + OneEighty = "180", + TwoSeventy = "270", + Flip0 = "flip0", + Flip90 = "flip90", + Flip180 = "flip180", + Flip270 = "flip270", +} + export interface ScrcpyOptionsInit2_3 extends Omit { audioCodec?: "raw" | "opus" | "aac" | "flac"; + displayOrientation?: ScrcpyDisplayOrientation2_3 | undefined; } export class ScrcpyOptions2_3 extends ScrcpyOptions { static readonly DEFAULTS = { ...ScrcpyOptions2_2.DEFAULTS, + displayOrientation: undefined, } as const satisfies Required; override get defaults(): Required {