Commit Graph

1773 Commits (88543cb5453f74ac611759ff483b6a413f367e1b)
 

Author SHA1 Message Date
Romain Vimont 1ffe312369 Handle file drop from input_manager
A file is pushed (or an apk is installed) to the device on file drop.
This behavior is specific to the screen and its input_manager.
2 years ago
Romain Vimont ebef027c4f Do not return status for event handling
It is never read. Simplify.
2 years ago
Romain Vimont 8e4e7d42f1 Fix leak on file pusher error
If a file_push request fails, the allocated filename must be freed.
2 years ago
Romain Vimont b066dc0bbf Rename file_handler to sc_file_pusher
Rename handler to pusher ("handler" is too generic), and add sc_ prefix.
2 years ago
Romain Vimont 262506c733 Limit retry-on-error to IllegalStateException
MediaCodec errors always trigger IllegalStateException or a subtype
(like MediaCodec.CodecException).

In practice, this avoids to retry if the error is caused by an
IOException when writing the video packet to the socket.
2 years ago
Romain Vimont 2eb6fe7d81 Downsize on error only before the first frame
The purpose of automatic downscaling on error is to make mirroring work
by just starting scrcpy without an explicit -m value, even if the
encoder could not encode at the screen definition.

It is only useful when we detect an encoding failure before the first
frame. Downsizing later could be surprising, so disable it.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 3a0ba7d0a4 Disable downsizing on error if V4L2 is enabled
V4L2 device is created with the initial device size, it does not support
resizing.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 75c5dc6859 Position and size the window on first frame
The optimal initial size was computed from the expected dimensions, sent
immediately by the server before encoding any video frame.

However, the actual frame size may be different, for example when the
device encoder does not support the requested size.

To always handle this case properly, position and size the window only
once the first frame size is known.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont fa30f9806a Move "show window" call on first frame
Show the window only after the actual frame size is known (and if no
error has occurred).

This will allow to properly position and size the window when the size
of the first frame is different from the size initially announced by the
server.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 4fb61ac83d Fix screen comments
The position fields accept SC_WINDOW_POSITION_UNDEFINED, not the size
fields.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 8fa9e6b01a Mention auto-downsize feature in FAQ
PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 0ec64baad4 Remove MediaCodec error suggestion fix
Now that scrcpy attempts with a lower definition on any MediaCodec
error (or the user explicitly requests to disable auto-downsizing), the
suggestion is unnecessary.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 15bf27afdd Make auto-downsize on error optional
Add --no-downsize-on-error option to disable attempts to use a lower
definition on MediaCodec error.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 26b4104844 Downsize on error
Some devices are not able to encode at the device screen definition.

Instead of just failing, try with a lower definition on any MediaCodec
error.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 723faa5dee Remember Device parameters
This will allow to reuse them to recreate a ScreenInfo instance in order
to change the maxSize value on MediaCodec error.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 162043911e Compute screen size without DisplayInfo instance
Use the actual rotation and size values directly.

This will allow to automatically change the maxSize value on MediaCodec
error.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
2 years ago
Romain Vimont 117fe32626 Fix visibility modifier
Refs b7a06278fe
2 years ago
Thomas Rebele b7a06278fe Fix NoSuchMethodException for injectInputEvent()
Some devices with modified ROMs expose a different signature for
injectInputEvent().

Fixes #2250 <https://github.com/Genymobile/scrcpy/issues/2250>
PR #2946 <https://github.com/Genymobile/scrcpy/pull/2946>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2 years ago
Romain Vimont b3ff1f6b3b Upgrade FFmpeg (5.0) for Windows 64-bit
Use FFmpeg win64 binaries from gyan.dev (referenced from ffmpeg.org):

 - https://www.gyan.dev/ffmpeg/builds/
 - https://ffmpeg.org/download.html#build-windows

Keep the old FFmpeg prebuilt binaries (4.3.1) for win32 builds.

Fixes #1753 <https://github.com/Genymobile/scrcpy/issues/1753>
Refs #1838 <https://github.com/Genymobile/scrcpy/pull/1838>
Refs #2583 <https://github.com/Genymobile/scrcpy/pull/2583>
PR #2952 <https://github.com/Genymobile/scrcpy/pull/2952>

Co-authored-by: Yu-Chen Lin <npes87184@gmail.com>
Co-authored-by: nkh0472 <nkh0472@hotmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2 years ago
Romain Vimont a2495c5ef1 Use symlink to simplify Windows ffmpeg dependency
The FFmpeg dependency is downloaded from two separate zipfiles.

Symlink include/ to expose everything from a single directory, to
simplify the meson script.

PR #2952 <https://github.com/Genymobile/scrcpy/pull/2952>
2 years ago
Romain Vimont 37c7827d46 Simplify ffmpeg dependencies Makefile
The fact that the current prebuilt FFmpeg is split into two separate
zipfiles is an implementation detail.

Use a single Makefile recipe for both files.

PR #2952 <https://github.com/Genymobile/scrcpy/pull/2952>
2 years ago
Tobias Preuss 479abc8c77 Reference Windows USB driver for Google devices
PR #2945 <https://github.com/Genymobile/scrcpy/pull/2945>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2 years ago
Bernhard Rosenkränzer 5e8fa56e7a Fix build with ffmpeg 5.0
PR #2948 <https://github.com/Genymobile/scrcpy/pull/2948>

Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2 years ago
Romain Vimont 60bf133ac2 Add final modifier to ScreenEncoder fields
These fields are only set from the constructor.
2 years ago
Romain Vimont 1c71bd16be Use constant string for known booleans
Boolean options explicitly passed to the server are statically known.
2 years ago
Romain Vimont afa4a1b728 Use sc_ prefix for control_msg 2 years ago
Romain Vimont 3a4d5c7f18 Use sc_ prefix for controller 2 years ago
Romain Vimont 5f7ddff8ae Use sc_ prefix for input_manager 2 years ago
Romain Vimont 2a0c2e5e99 Use sc_ prefix for screen 2 years ago
Romain Vimont a6644e831b Fix code style
Limit to 80 chars.
2 years ago
Romain Vimont 75655194fb Do not pass scrcpy_options to keyboard inject
The components should be configurable independently of the global
scrcpy_options instance: their configuration could be provided
separately, like it is the case for example for some screen parameters.

For consistency, keyboard injection should not depend on scrcpy_options.
2 years ago
Romain Vimont 43aff4af73 Document HID mouse in README 2 years ago
Romain Vimont cba84f6999 Add support for HID mouse 2 years ago
Romain Vimont ed2e45ee29 Refactor AOA/HID keyboard initialization
This paves the way to add support for HID mouse initialization.
2 years ago
Romain Vimont aee1b39790 Add CLAMP() macro 2 years ago
Romain Vimont 17d01b5bf7 Add UI/UX support for relative mouse mode
In relative mouse mode, the mouse pointer must be "captured" from the
computer.

Toggle (disable/enable) relative mouse mode using any of the hardcoded
capture keys:
 - left-Alt
 - left-Super
 - right-Super

These capture keys do not conflict with shortcuts, since a shortcut is
always a combination of the MOD key and some other key, while the
capture key triggers an action only if it is pressed and released alone.

The relative mouse mode is also automatically enabled on any click in
the window, and automatically disabled on focus lost (it is possible to
lose focus even without the mouse).
2 years ago
Romain Vimont 40fca82b60 Forward all motion events to mouse processors
The decision to not send motion events when no click is pressed is
specific to Android mouse injection. Other mouse processors (e.g. for
HID mouse) will need to receive all events.
2 years ago
Romain Vimont 643293752d Provide relative mouse motion vector in event
This will allow the mouse processor to handle relative motion easily.
2 years ago
Romain Vimont b5855e5deb Add relative mode flag to mouse processors
The default mouse injection works in absolute mode: it forwards clicks
at a specific position on screen.

To support HID mouse, add a flag to indicate that the mouse processor
works in relative mode: it forwards mouse motion vectors, without any
absolute reference to the screen.
2 years ago
Romain Vimont 924375487e Pass buttons state in scroll events
A scroll event might be produced when a mouse button is pressed (for
example when scrolling while selecting a text). For consistency, pass
the actual buttons state (instead of 0).

In practice, it seems that this use case does not work properly with
Android event injection, but it will work with HID mouse.
2 years ago
Romain Vimont 7121a0dc53 Destroy acksync immediately on error
If AOA or HID keyboard may not be initialized for some reason, acksync
is useless.
2 years ago
Romain Vimont f04812fc71 Remove duplicate boolean
The AOA initialization state is already tracked by aoa_hid_initialized.
2 years ago
Romain Vimont 5ce1ccde85 Reorder controller and HID initialization
This allows to merge two "#ifdef HAVE_AOA_HID" blocks to simplify.
2 years ago
Romain Vimont 6102a0b5bb Move input_manager into screen
The input_manager is strongly tied to the screen, it could not work
independently of the specific screen implementation.

To implement a user-friendly HID mouse behavior, some SDL events
will need to be handled both by the screen and by the input manager. For
example, a click must typically be handled by the input_manager so that
it is forwarded to the device, but in HID mouse mode, the first click
should be handled by the screen to capture the mouse (enable relative
mouse mode).

Make the input_manager a descendant of the screen, so that the screen
decides what to do on SDL events.

Concretely, replace this structure hierarchy:

     +- struct scrcpy
        +- struct input_manager
        +- struct screen

by this one:

     +- struct scrcpy
        +- struct screen
           +- struct input_manager
2 years ago
Romain Vimont 2b34e1224e Use separate struct for input manager params
This avoids to directly pass the options instance (which contains more
data than strictly necessary), and limit the number of parameters for
the init function.
2 years ago
Romain Vimont a9d23400cd Remove unused enum value requiring SDL 2.0.18
Refs b8fed50639
Fixes #2924 <https://github.com/Genymobile/scrcpy/issues/2924>
2 years ago
Romain Vimont cca3c953da Enable virtual finger only on left click
The pinch-to-zoom feature must only be enabled with Ctrl+left_click.
2 years ago
Romain Vimont 57f1655d4b Make some mouse processors ops optional
Do not force all mouse processors to implement scroll events or touch
events.
2 years ago
Romain Vimont bc674721dc Make process_text() optional
Not all key processors support text injection (HID keyboard does not
support it).

Instead of providing a dummy op function, set it to NULL and check on
the caller side before calling it.
2 years ago
Romain Vimont 63e29b1782 Apply buttons mask if not --forward-all-clicks
If --forward-all-clicks is not set, then only left clicks are forwarded.
For consistency, also mask the buttons state in other events.
2 years ago