Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support virtual display feature #92

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fix_functional_include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Subject: [PATCH] fix functional include: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276983#c6
---
Index: tls/include/adb/tls/tls_connection.h
<+>UTF-8
===================================================================
diff --git a/tls/include/adb/tls/tls_connection.h b/tls/include/adb/tls/tls_connection.h
@@ -21,6 +21,7 @@

#include <string_view>
#include <vector>
+#include <functional>

#include <android-base/unique_fd.h>
#include <openssl/ssl.h>
4 changes: 2 additions & 2 deletions porting/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ scrcpy:

scrcpy-server:
set -x && \
export SCRCPY_VERSION=2.3 && \
export SCRCPY_VERSION=3.0.2 && \
export ANDROID_SDK_ROOT=~/Library/Android/sdk && \
export JAVA_HOME="$$(/usr/libexec/java_home --version 1.11)" && \
export PATH="$$JAVA_HOME/bin:$$PATH" && \
cd server && rm -rf scrcpy-* && \
curl -o scrcpy.zip -L https://github.com/Genymobile/scrcpy/archive/refs/tags/v$$SCRCPY_VERSION.zip && \
unzip scrcpy.zip && find src -name "*.java" -exec cp -v {} scrcpy-$$SCRCPY_VERSION/server/{} \; && \
unzip scrcpy.zip && \
cd scrcpy-$$SCRCPY_VERSION && \
meson setup x --buildtype=release --strip -Db_lto=true -Dcompile_app=false -Dcompile_server=true && \
sed -ibak 's/exit/echo/g' server/scripts/build-wrapper.sh && \
Expand Down
19 changes: 16 additions & 3 deletions porting/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ add_library( # Sets the name of the library.
../../scrcpy/app/src/cli.c
../../scrcpy/app/src/receiver.c
../../scrcpy/app/src/compat.c
../../scrcpy/app/src/mouse_inject.c
../../scrcpy/app/src/util/log.c
../../scrcpy/app/src/util/net_intr.c
../../scrcpy/app/src/util/thread.c
Expand Down Expand Up @@ -53,7 +52,6 @@ add_library( # Sets the name of the library.
../../scrcpy/app/src/clock.c
../../scrcpy/app/src/frame_buffer.c
../../scrcpy/app/src/server.c
../../scrcpy/app/src/keyboard_inject.c
../../scrcpy/app/src/file_pusher.c

# Disable usb sources
Expand Down Expand Up @@ -101,14 +99,29 @@ add_library( # Sets the name of the library.
../../scrcpy/app/src/packet_merger.c
../../scrcpy/app/src/util/memory.c
../../scrcpy/app/src/util/average.c
../../scrcpy/app/src/util/bytebuf.c
../../scrcpy/app/src/util/rand.c
../../scrcpy/app/src/trait/frame_source.c
../../scrcpy/app/src/trait/packet_source.c

# Added from v2.2
../../porting/src/display-porting.c
../../scrcpy/app/src/util/timeout.c

# Added from v3.0.2
../../scrcpy/app/src/events.c
../../scrcpy/app/src/keyboard_sdk.c
../../scrcpy/app/src/mouse_sdk.c
../../scrcpy/app/src/hid/hid_gamepad.c
../../scrcpy/app/src/hid/hid_keyboard.c
../../scrcpy/app/src/hid/hid_mouse.c
../../scrcpy/app/src/uhid/gamepad_uhid.c
../../scrcpy/app/src/uhid/keyboard_uhid.c
../../scrcpy/app/src/uhid/mouse_uhid.c
../../scrcpy/app/src/uhid/uhid_output.c
../../scrcpy/app/src/util/audiobuf.c
../../scrcpy/app/src/audio_regulator.c
../../scrcpy/app/src/mouse_capture.c
../../scrcpy/app/src/util/env.c
)

target_include_directories(
Expand Down
2 changes: 1 addition & 1 deletion scrcpy
Submodule scrcpy updated 273 files
7 changes: 3 additions & 4 deletions scrcpy-ios/scrcpy-ios/ScrcpyClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,17 @@ -(NSInteger)adbExecuteUnderlying:(NSArray<NSString *> *)commands message:(NSStri
#pragma mark - Scrcpy Options

-(NSArray *)defaultScrcpyOptions {
return @[ @"--verbosity=debug", @"--shortcut-mod=lctrl+rctrl",
@"--fullscreen", @"--display-buffer=33",
return @[ @"--verbosity=debug", @"--fullscreen",
/** @"--video-codec=h265", **/ @"--video-bit-rate=4M",
@"--audio-bit-rate=128K", @"--audio-buffer=60", @"--no-audio",
@"--max-fps=60", @"--print-fps" ];
}

-(NSArray *)availableOptions {
return @[ @"max-size", @"video-bit-rate", @"audio-bit-rate", @"audio-buffer",
@"audio-codec", @"no-audio", @"disable-screensaver", @"display-buffer",
@"audio-codec", @"no-audio", @"disable-screensaver", @"video-buffer",
@"force-adb-forward", @"max-fps", @"power-off-on-close", @"turn-screen-off",
@"show-touches", @"stay-awake", ];
@"show-touches", @"stay-awake", @"new-display", @"start-app", ];
}

-(NSArray *)setScrcpyOption:(NSArray *)options name:(NSString *)name value:(NSString *)value {
Expand Down
34 changes: 33 additions & 1 deletion scrcpy-ios/scrcpy-ios/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ @interface ViewController ()
@property (nonatomic, weak) ScrcpyTextField *maxSize;
@property (nonatomic, weak) ScrcpyTextField *bitRate;
@property (nonatomic, weak) ScrcpyTextField *maxFps;
@property (nonatomic, weak) ScrcpyTextField *display;
@property (nonatomic, weak) ScrcpyTextField *startApp;

@property (nonatomic, weak) ScrcpySwitch *turnScreenOff;
@property (nonatomic, weak) ScrcpySwitch *stayAwake;
Expand Down Expand Up @@ -160,7 +162,31 @@ -(void)setupViews {
view.delegate = (id<UITextFieldDelegate>)_self;
_self.maxFps = view;
}),
CreateScrcpySwitch(NSLocalizedString(@"Turn Screen Off:", nil),
CVCreate.create(ScrcpyTextField.class).size(CGSizeMake(0, 40))
.fontSize(16)
.border(DynamicTextFieldBorderColor(), 2.f)
.cornerRadius(5.f)
.customView(^(ScrcpyTextField *view){
view.optionKey = @"new-display";
view.attributedPlaceholder = DynamicColoredPlaceholder(NSLocalizedString(@"--new-display, format 1920x1080", nil));
view.autocorrectionType = UITextAutocorrectionTypeNo;
view.autocapitalizationType = UITextAutocapitalizationTypeNone;
view.delegate = (id<UITextFieldDelegate>)_self;
_self.display = view;
}),
CVCreate.create(ScrcpyTextField.class).size(CGSizeMake(0, 40))
.fontSize(16)
.border(DynamicTextFieldBorderColor(), 2.f)
.cornerRadius(5.f)
.customView(^(ScrcpyTextField *view){
view.optionKey = @"start-app";
view.attributedPlaceholder = DynamicColoredPlaceholder(NSLocalizedString(@"--start-app, format org.fossify.home", nil));
view.autocorrectionType = UITextAutocorrectionTypeNo;
view.autocapitalizationType = UITextAutocapitalizationTypeNone;
view.delegate = (id<UITextFieldDelegate>)_self;
_self.startApp = view;
}),
CreateScrcpySwitch(NSLocalizedString(@"Turn Screen Off:", nil),
@"turn-screen-off",
^(ScrcpySwitch *view){
self.turnScreenOff = view;
Expand Down Expand Up @@ -284,6 +310,8 @@ -(void)stopEditing {
[self.maxSize endEditing:YES];
[self.bitRate endEditing:YES];
[self.maxFps endEditing:YES];
[self.display endEditing:YES];
[self.startApp endEditing:YES];
}

-(void)stop {
Expand Down Expand Up @@ -327,6 +355,8 @@ -(void)finalStart {
options = updateTextOptions(options, self.maxSize);
options = updateTextOptions(options, self.bitRate);
options = updateTextOptions(options, self.maxFps);
options = updateTextOptions(options, self.display);
options = updateTextOptions(options, self.startApp);

NSArray * (^updateSwitchOptions)(NSArray *options, ScrcpySwitch *) = ^NSArray * (NSArray *options, ScrcpySwitch *s) {
[s updateOptionValue];
Expand Down Expand Up @@ -370,6 +400,8 @@ -(void)copyURLScheme {
urlComps.queryItems = updateURLTextItems(urlComps.queryItems, self.maxSize);
urlComps.queryItems = updateURLTextItems(urlComps.queryItems, self.bitRate);
urlComps.queryItems = updateURLTextItems(urlComps.queryItems, self.maxFps);
urlComps.queryItems = updateURLTextItems(urlComps.queryItems, self.display);
urlComps.queryItems = updateURLTextItems(urlComps.queryItems, self.startApp);

// Assemble bool options
NSArray *(^updateURLBoolItems)(NSArray *, ScrcpySwitch *) = ^NSArray *(NSArray *items, ScrcpySwitch *s) {
Expand Down