forked from yume-chan/ya-webadb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add display orientation options for Scrcpy version 2.3
Introduce new classes and enums to handle Scrcpy version 2.3 options. This update includes new display orientation options and modifies the existing interfaces to accommodate additional settings. See Genymobile/scrcpy#4441
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ScrcpyEncoder[]> { | ||
return AdbScrcpyOptions2_0.getEncoders(adb, path, version, this); | ||
} | ||
|
||
override getDisplays( | ||
adb: Adb, | ||
path: string, | ||
version: string, | ||
): Promise<ScrcpyDisplay[]> { | ||
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters