Skip to content

Commit

Permalink
feat(scrcpy): expose notification panel controls
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Oct 4, 2023
1 parent 28b1bd3 commit 7c3c045
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/adb/src/server/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export class AdbServerClient {
}
}

async function raceSignal<T>(
export async function raceSignal<T>(
callback: () => Promise<T>,
...signals: (AbortSignal | undefined)[]
): Promise<T> {
Expand Down
25 changes: 25 additions & 0 deletions libraries/scrcpy/src/control/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
ScrcpyScrollController,
} from "../options/index.js";

import { BasicControlMessage } from "./basic.js";
import type { AndroidKeyEventAction } from "./inject-keycode.js";
import { ScrcpyInjectKeyCodeControlMessage } from "./inject-keycode.js";
import type { ScrcpyInjectScrollControlMessage } from "./inject-scroll.js";
Expand Down Expand Up @@ -83,6 +84,30 @@ export class ScrcpyControlMessageSerializer {
});
}

expandNotificationPanel() {
return BasicControlMessage.serialize({
type: this.#typeValues.get(
ScrcpyControlMessageType.ExpandNotificationPanel,
),
});
}

expandSettingPanel() {
return BasicControlMessage.serialize({
type: this.#typeValues.get(
ScrcpyControlMessageType.ExpandSettingPanel,
),
});
}

collapseNotificationPanel() {
return BasicControlMessage.serialize({
type: this.#typeValues.get(
ScrcpyControlMessageType.CollapseNotificationPanel,
),
});
}

rotateDevice() {
return ScrcpyRotateDeviceControlMessage.serialize({
type: this.#typeValues.get(ScrcpyControlMessageType.RotateDevice),
Expand Down
12 changes: 12 additions & 0 deletions libraries/scrcpy/src/control/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export class ScrcpyControlMessageWriter {
await this.write(this.#serializer.setScreenPowerMode(mode));
}

async expandNotificationPanel() {
await this.write(this.#serializer.expandNotificationPanel());
}

async expandSettingPanel() {
await this.write(this.#serializer.expandSettingPanel());
}

async collapseNotificationPanel() {
await this.write(this.#serializer.collapseNotificationPanel());
}

async rotateDevice() {
await this.write(this.#serializer.rotateDevice());
}
Expand Down

0 comments on commit 7c3c045

Please sign in to comment.