-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Add scrcpy window without video playback #4868
Conversation
There is no frame rate to count.
Add the possibility to only control the device with any keyboard and mouse mode without screen mirroring. This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes #4727 <#4727> Fixes #4793 <#4793> PR #4868 <#4868>
Hey, so this is what I got when using the command you mentioned on Reddit. It seems the command works, and there's a window with an Android logo (same as OTG mode), but it quickly disappears and exits the command. Also I'm not sure if this is possible yet via the --no-window or --no-video option, but just wanted to add this feature request from my Reddit comment: A windowless approach to OTG mode (meaning it wouldn't be a window, it could exist in the system tray maybe), where a user-defined hotkey can be used to toggle between the host screen and the android device. This would make it very similar to deskdock. I believe the rest of the things work already: ADB wifi works, UHID keyboards have gestures and hotkeys (unlike OTG mode). Thanks. |
Thank you for your report.
Without any error message? I cannot reproduce the problem. Maybe because the binary was from an old version of this PR. Please test this new one:
Also, do you have the same issue with another device?
Technically, scrcpy receives events from the scrcpy window. If there is no window, I don't think it is possible to receive the events with SDL. It would only be possible by platform-specific means I guess. |
OK, on Windows, I can reproduce. I will investigate. |
Add the possibility to only control the device with any keyboard and mouse mode without screen mirroring: scrcpy -KM --no-video --no-audio This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes #4727 <#4727> Fixes #4793 <#4793> PR #4868 <#4868>
OK, with these two changes it should be fixed: fix 1diff --git a/app/src/screen.c b/app/src/screen.c
index cda562468..9ee61383c 100644
--- a/app/src/screen.c
+++ b/app/src/screen.c
@@ -272,6 +272,8 @@ sc_screen_render(struct sc_screen *screen, bool update_content_rect) {
static int
event_watcher(void *data, SDL_Event *event) {
struct sc_screen *screen = data;
+ assert(screen->video);
+
if (event->type == SDL_WINDOWEVENT
&& event->window.event == SDL_WINDOWEVENT_RESIZED) {
// In practice, it seems to always be called from the same thread in
@@ -477,7 +479,9 @@ sc_screen_init(struct sc_screen *screen,
sc_input_manager_init(&screen->im, &im_params);
#ifdef CONTINUOUS_RESIZING_WORKAROUND
- SDL_AddEventWatch(event_watcher, screen);
+ if (screen->video) {
+ SDL_AddEventWatch(event_watcher, screen);
+ }
#endif
static const struct sc_frame_sink_ops ops = { fix 2diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index cd2706559..5154d474e 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -626,6 +626,23 @@ sc_input_manager_process_key(struct sc_input_manager *im,
im->kp->ops->process_key(im->kp, &evt, ack_to_wait);
}
+static struct sc_position
+sc_input_manager_get_position(struct sc_input_manager *im, int32_t x,
+ int32_t y) {
+ if (im->mp->relative_mode) {
+ // No absolute position
+ return (struct sc_position) {
+ .screen_size = {0, 0},
+ .point = {0, 0},
+ };
+ }
+
+ return (struct sc_position) {
+ .screen_size = im->screen->frame_size,
+ .point = sc_screen_convert_window_to_frame_coords(im->screen, x, y),
+ };
+}
+
static void
sc_input_manager_process_mouse_motion(struct sc_input_manager *im,
const SDL_MouseMotionEvent *event) {
@@ -635,12 +652,7 @@ sc_input_manager_process_mouse_motion(struct sc_input_manager *im,
}
struct sc_mouse_motion_event evt = {
- .position = {
- .screen_size = im->screen->frame_size,
- .point = sc_screen_convert_window_to_frame_coords(im->screen,
- event->x,
- event->y),
- },
+ .position = sc_input_manager_get_position(im, event->x, event->y),
.pointer_id = im->forward_all_clicks ? POINTER_ID_MOUSE
: POINTER_ID_GENERIC_FINGER,
.xrel = event->xrel,
@@ -760,12 +772,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
uint32_t sdl_buttons_state = SDL_GetMouseState(NULL, NULL);
struct sc_mouse_click_event evt = {
- .position = {
- .screen_size = im->screen->frame_size,
- .point = sc_screen_convert_window_to_frame_coords(im->screen,
- event->x,
- event->y),
- },
+ .position = sc_input_manager_get_position(im, event->x, event->y),
.action = sc_action_from_sdl_mousebutton_type(event->type),
.button = sc_mouse_button_from_sdl(event->button),
.pointer_id = im->forward_all_clicks ? POINTER_ID_MOUSE
@@ -840,11 +847,7 @@ sc_input_manager_process_mouse_wheel(struct sc_input_manager *im,
uint32_t buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
struct sc_mouse_scroll_event evt = {
- .position = {
- .screen_size = im->screen->frame_size,
- .point = sc_screen_convert_window_to_frame_coords(im->screen,
- mouse_x, mouse_y),
- },
+ .position = sc_input_manager_get_position(im, mouse_x, mouse_y),
#if SDL_VERSION_ATLEAST(2, 0, 18)
.hscroll = CLAMP(event->preciseX, -1.0f, 1.0f),
.vscroll = CLAMP(event->preciseY, -1.0f, 1.0f),
diff --git a/app/src/screen.c b/app/src/screen.c
index 9ee61383c..11b4f58a1 100644
--- a/app/src/screen.c
+++ b/app/src/screen.c
@@ -962,6 +962,8 @@ sc_screen_handle_event(struct sc_screen *screen, const SDL_Event *event) {
struct sc_point
sc_screen_convert_drawable_to_frame_coords(struct sc_screen *screen,
int32_t x, int32_t y) {
+ assert(screen->video);
+
enum sc_orientation orientation = screen->orientation;
int32_t w = screen->content_size.width; Please test this new binary:
|
Thank you! It's working now. And yes I'm on Windows 10. Just wanted to clarify a few things: So the The But as you mentioned, the control events are not possible without a window? So --no-window can't be combined with -KM Anyway thank you, I will check if I can assign a hotkey with AHK or EventGhost and make this suit my workflow a bit more. |
The main purpose of OTG mode is to work without adb (USB debugging), not to only control the device. With this PR, if you want to only control the device and have USB debugging enabled, you can. OTG uses AOA, so the most similar command would be:
But it is better to use UHID:
In the current stable version, several features do not open a window at all: audio-playback only, recording, v4L2. |
The options It works if I start with |
Is there a reason why this mode has to imply |
Thank you for the report. Fixed:
Yes, legacy paste processing is performed on the server side, and there is no server in OTG mode.
That's it. |
@rom1v Confirm, fixed. Thank you! |
Add the possibility to solely control the device with any keyboard and mouse mode without screen mirroring: scrcpy -KM --no-video --no-audio This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes #4727 <#4727> Fixes #4793 <#4793> PR #4868 <#4868>
c875465
to
b5ed834
Compare
Add the possibility to solely control the device without screen mirroring: scrcpy --no-video --no-audio This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes #4727 <#4727> Fixes #4793 <#4793> PR #4868 <#4868>
I fixed some bugs and merged into |
Add the possibility to only control the device with any keyboard and mouse mode without screen mirroring: scrcpy -KM --no-video --no-audio This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes #4727 <Genymobile/scrcpy#4727> Fixes #4793 <Genymobile/scrcpy#4793> PR #4868 <Genymobile/scrcpy#4868>
Add the possibility to solely control the device without screen mirroring: scrcpy --no-video --no-audio This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes Genymobile#4727 <Genymobile#4727> Fixes Genymobile#4793 <Genymobile#4793> PR Genymobile#4868 <Genymobile#4868>
This is particularly important to react to server socket disconnection since video and audio may be disabled. PR Genymobile#4868 <Genymobile#4868>
This one works but the mouse lag is quite high on the android. Can you suggest how to improve this? also, about using a shortcut to switch between scrcpy windows and other windows seems challenging to do. I as using AI to achieve this and it suggested AHK with these code. I am using backtick ` (the key below ESC button) as my switch immediately shortcut
it does bring the window front BUT NOT clicking it so the mouse & keyboard witll shift to the android |
it only swtith to scrcpy windows. but not FROM out of SCRCPY. |
Add the possibility to solely control the device without screen mirroring: scrcpy --no-video --no-audio This is different from OTG mode, which does not require USB debugging at all. Here, the standard mode is used but with the possibility to disable video playback. By default, always open a window (even without video playback), and add an option --no-window. Fixes Genymobile#4727 <Genymobile#4727> Fixes Genymobile#4793 <Genymobile#4793> PR Genymobile#4868 <Genymobile#4868>
This is particularly important to react to server socket disconnection since video and audio may be disabled. PR Genymobile#4868 <Genymobile#4868>
Add the possibility to solely control the device without screen mirroring:
This is different from OTG mode, which does not require USB debugging at all. Here, it is just the standard mode but with the possibility to disable video playback.
By default, always open a window (even without video playback), and add an option
--no-window
.This impacts the behavior of some usages.
For example, the following command used to only play audio without video or controls:
Now, it opens a window, and allows to control it using the keyboard and mouse (by default, mouse mode is switched to UHID if video mirroring is disabled, because a relative mouse mode is required).
The controls must be disabled explicitly if necessary to play audio only:
To get the same behavior as before (play audio without window), disable the window:
(this implicitly set
--no-control
and--no-video-playback
, which in turn set--no-video
if there is no recording or V4L2 sink)Fixes #4727
Fixes #4793