Skip to content

Commit

Permalink
feat(scrcpy): add class for crop option
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Dec 3, 2024
1 parent c0d0695 commit fdf674a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 19 additions & 1 deletion libraries/scrcpy/src/1_15/impl/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ export namespace CodecOptions {
export type Init = CodecOptionsInit;
}

export class Crop implements ScrcpyOptionValue {
width: number;
height: number;
x: number;
y: number;

constructor(width: number, height: number, x: number, y: number) {
this.width = width;
this.height = height;
this.x = x;
this.y = y;
}

toOptionValue(): string | undefined {
return `${this.width}:${this.height}:${this.x}:${this.y}`;
}
}

export interface Init {
logLevel?: LogLevel;

Expand Down Expand Up @@ -124,7 +142,7 @@ export interface Init {
*/
tunnelForward?: boolean;

crop?: string | undefined;
crop?: Crop | undefined;

/**
* Send PTS so that the client may record properly
Expand Down
3 changes: 3 additions & 0 deletions libraries/scrcpy/src/latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export {
BackOrScreenOnControlMessage as ScrcpyBackOrScreenOnControlMessage,
CaptureOrientation as ScrcpyCaptureOrientation,
CodecOptions as ScrcpyCodecOptions,
Crop as ScrcpyCrop,
InjectScrollControlMessage as ScrcpyInjectScrollControlMessage,
InjectTouchControlMessage as ScrcpyInjectTouchControlMessage,
InstanceId as ScrcpyInstanceId,
Expand All @@ -13,3 +14,5 @@ export {
UHidCreateControlMessage as ScrcpyUHidCreateControlMessage,
UHidOutputDeviceMessage as ScrcpyUHidOutputDeviceMessage,
} from "./3_0/impl/index.js";

export { ScrcpyOptions3_0 as ScrcpyOptionsLatest } from "./3_0/index.js";

0 comments on commit fdf674a

Please sign in to comment.