Commit graph

2504 commits

Author SHA1 Message Date
Romain Vimont
0c95794463 Do not apply all workarounds for ONYX devices
Calling fillAppInfo() breaks video mirroring on ONYX devices.

Fixes #5182 <https://github.com/Genymobile/scrcpy/issues/5182>
Refs 2b6089cbfc
2024-08-10 14:29:26 +02:00
Romain Vimont
523f939532 Do not create UHID thread if not used
The HandlerThread is used only via the looper queue.
2024-08-08 20:32:35 +02:00
yangfl
dd47cefa47 Fix typos
Refs <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1077968#27>
PR #5171 <https://github.com/Genymobile/scrcpy/pull/5171>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-08-05 16:13:02 +02:00
Romain Vimont
44b3fd82b1 Update links to 2.6.1 2024-08-02 22:58:09 +02:00
Romain Vimont
cc41115625 Bump version to 2.6.1 2024-08-02 22:32:04 +02:00
Romain Vimont
773c23fda2 Inject finger input whenever possible
Even if the pointer is a mouse, inject it as a finger unless it is
required to be a mouse, that is:
 - when it is a HOVER_MOUSE event, or
 - when a secondary button is pressed.

Some apps/games only accept events from a finger/touchscreen, so using a
mouse by default does not work for them.

For simplicity, make this change on the server side just before
event injection (so that the client does not need to know about this
hacky behavior).

Refs 6808288823
Refs c7b1d0ea9a
Fixes #5162 <https://github.com/Genymobile/scrcpy/issues/5162>
Fixes #5163 <https://github.com/Genymobile/scrcpy/issues/5163>
2024-08-02 22:24:31 +02:00
Romain Vimont
992b4922fe Document INJECT_EVENTS permission issue on Xiaomi
Make explicit in the prerequisites the exact error message when "USB
debugging (Security Settings)" is not set.
2024-08-02 18:44:42 +02:00
Romain Vimont
67f93350f6 Update links to 2.6 2024-08-01 18:46:10 +02:00
Romain Vimont
52136268ef Bump version to 2.6 2024-08-01 18:15:59 +02:00
Romain Vimont
0a6ccdc4df Merge branch 'master' into release 2024-08-01 18:15:40 +02:00
Romain Vimont
5d2441d198 Upgrade SDL (2.30.5) for Windows 2024-08-01 18:15:37 +02:00
Romain Vimont
2b6089cbfc Enable workarounds by default
Workarounds were disabled by default, and only enabled for some devices
or under specific conditions.

But it seems they are needed for more and more devices, so enable them
by default. They could be disabled for specific devices if necessary in
the future.

In the past, these workarounds caused a (harmless) exception to be
printed on some Xiaomi devices [1]. But this is not a problem anymore
since commit b8c5853aa6.

They also caused problems for audio on Vivo devices [2], but it seems
this is not the case anymore [3].

They might also impact an old Nvidia Shield [4], but hopefully this is
fixed now.

[1]: <https://github.com/Genymobile/scrcpy/issues/4015#issuecomment-1595382142>
[2]: <https://github.com/Genymobile/scrcpy/issues/3805#issuecomment-1596148031>
[3]: <https://github.com/Genymobile/scrcpy/issues/3805#issuecomment-2260205882>
[4]: <https://github.com/Genymobile/scrcpy/issues/940>

PR #5154 <https://github.com/Genymobile/scrcpy/pull/5154>
2024-08-01 12:16:35 +02:00
Al Grimes
f691ebb1b4 Add workaround for TCL Android 12 Smart TVs
Fixes #5140 <https://github.com/Genymobile/scrcpy/issues/5140>
PR #5148 <https://github.com/Genymobile/scrcpy/pull/5148>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-07-31 14:55:00 +02:00
Romain Vimont
071d459ad7 Fix --no-audio
By default, the audio source is initialized to SC_AUDIO_SOURCE_AUTO, and
is "resolved" only if audio is enabled.

But the server arguments were built assuming that the audio source was
never SC_AUDIO_SOURCE_AUTO (even with audio disabled), causing a crash.

Regression introduced by a10f8cd798.
2024-07-29 20:03:44 +02:00
Romain Vimont
bbfac9ae1f Add FUNDING.yml
The donation links were already in the README.

Also add them in the format expected by GitHub in FUNDING.yml.
2024-07-19 17:56:26 +02:00
Romain Vimont
65bd6bd8d4 Explicitly accept issues for general questions
Add an empty question template, and reword the "Contact" section in the
README.

Refs #5117 <https://github.com/Genymobile/scrcpy/issues/5117>
2024-07-19 17:51:50 +02:00
Romain Vimont
ed4066902d Update documentation for audio playback capture
PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
127a271d34 Switch audio source if audio-dup is set
Automatically switch implicit audio source to "playback" if --audio-dup
is passed.

This allows to run:

    scrcpy --audio-dup

without specifying explicitly:

    scrcpy --audio-source=playback --audio-dup

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
31116a60d7 Add --audio-dup
Add an option to duplicate audio on the device, compatible with the new
audio playback capture (--audio-source=playback).

Fixes #3875 <https://github.com/Genymobile/scrcpy/issues/3875>
Fixes #4380 <https://github.com/Genymobile/scrcpy/issues/4380>
PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
2024-07-19 17:48:39 +02:00
Romain Vimont
a10f8cd798 Add audio playback capture method
Add a new method to capture audio playback.

It requires Android 13 (where the Shell app has MODIFY_AUDIO_ROUTING
permission).

The main benefit is that it supports keeping audio playing on the device
(implemented in a further commit).

Fixes #4380 <https://github.com/Genymobile/scrcpy/issues/4380>
PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
2024-07-19 17:48:39 +02:00
Romain Vimont
53c6eb66ea Move audio source value
The MediaRecorder constant should not belong to the AudioSource enum.

This will allow to add a new AudioSource which has no meaningful
MediaRecorder audio source value.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
0f076083e8 Extract AudioCapture interface
Move the implementation to AudioDirectCapture and extract an
AudioCapture interface.

This will allow to provide another AudioCapture implementation.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
053bf83f58 Extract AudioRecordReader
Move the logic to read from an AudioRecord and handle all corner cases
for PTS. This simplifies AudioCapture.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
414ce4c754 Move createAudioFormat() to AudioConfig
This will allow to reuse this method.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
a2f3a5cf18 Move hardcoded audio configuration to AudioConfig
This will allow to use these constants from different classes not
directly related to AudioCapture.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
5e605b9b8f Move audio compatibility check
The compatibility depends on the capture constraints, not the encoding.

This will allow to add a new capture implementation with different
constraints.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
cf09e78323 Throw AudioCaptureException on workaround error
Replace a RuntimeException by a specific AudioCaptureException.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
3b8ec0c38d Rename audio capture exception
The AudioCaptureForegroundException was very specific. Rename it to
AudioCaptureException to support other capture failures.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Romain Vimont
39132ff2dd Make encode() method private
It is only used from AudioEncoder.

PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
2024-07-19 17:48:39 +02:00
Kaiming Hu
9d1d79b004 Fix "turn screen off" for Honor Android 14 devices
Fixes #4823 <https://github.com/Genymobile/scrcpy/issues/4823>
PR #5109 <https://github.com/Genymobile/scrcpy/pull/5109>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-07-17 18:02:29 +02:00
Romain Vimont
e0cdc2ace3 Fix method name
The method indicates whether GetPhysicalDisplayIds() exists. The "Get"
was missing.
2024-07-17 18:02:26 +02:00
Romain Vimont
bbcd763612 Exclude install-release tags from git describe
The install_release.sh script is updated one commit after the release
tag, which may be confusing.

For convenience, new lightweight tags have been added (for example
v2.5-install-release) to point to the commit where install_release.sh is
updated.

But these tags interfere with "git describe" to generate pretty
filenames when executing ./release.sh on a development branch, so ignore
them.

Before:

    release-v2.5-install-release-17-gc57a0512b

After:

    release-v2.5-18-gc57a0512b

Refs #4098 comment <https://github.com/Genymobile/scrcpy/issues/4098#issuecomment-1600332180>
2024-07-17 18:00:27 +02:00
Romain Vimont
c57a0512ba Add assertions
Passing an unknown enum value to convert them to string would return
NULL without any error, possibly causing undefined behavior later.

Add assertions to catch such programming errors early.
2024-07-16 21:31:31 +02:00
Romain Vimont
e84db2914d Reorganize server packages
There are now a lot of classes in the server, reorganize them into
subpackages.
2024-07-11 22:38:00 +02:00
Romain Vimont
80ca7b15e5 Extract sources paths in build_without_gradle.sh
This avoids duplication, and will be useful to add more packages.
2024-07-11 22:34:58 +02:00
Romain Vimont
79242957a0 Add clipboard workaround for Honor device
Fixes #5073 <https://github.com/Genymobile/scrcpy/issues/5073>
2024-07-11 12:21:38 +02:00
Romain Vimont
fe7494c492 Linearize try-catch blocks
There are many possible method signatures for getPrimaryClip() and
setPrimaryClip().

Avoid the nested try-catch blocks.
2024-07-11 12:19:47 +02:00
Romain Vimont
9989668226 Add mouse secondary bindings
Add secondary bindings (Shift+click) for mouse buttons.

In addition to:

    --mouse-bind=xxxx

It is now possible to pass a sequence of secondary bindings:

    --mouse-bind=xxxx:xxxx
                 <--> <-->
             primary   secondary
            bindings   bindings

If the second sequence is omitted, then it is the same as the first one.

By default, for SDK mouse, primary bindings trigger shortcuts and
secondary bindings forward all clicks.

For AOA and UHID, the default bindings are reversed: all clicks are
forwarded by default, whereas pressing Shift+click trigger shortcuts.

    --mouse-bind=bhsn:++++  # default for SDK
    --mouse-bind=++++:bhsn  # default for AOA and UHID

Refs 035d60cf5d
Refs f5e6b8092a
Fixes #5055 <https://github.com/Genymobile/scrcpy/issues/5055>
PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
6baea57987 Track mouse buttons state manually
The buttons state was tracked by SDL_GetMouseState(), and scrcpy applied
a mask to ignore buttons used for shortcuts.

Instead, track the buttons actually pressed (ignoring shortcuts)
manually, to prepare the introduction of more dynamic mouse shortcuts.

PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
86b8286217 Remove unused virtual mouse
PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
51fee79bf5 Use finger source when a pointer is simulated
For pinch-to-zoom, rotation and tilt simulation, always use a finger
source (instead of a mouse) for both pointers (the real one and the
simulated one).

A "virtual" mouse does not work on all devices (e.g. on Pixel 8).

PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
6808288823 Make pointer id independent of mouse bindings
The device source (MOUSE or FINGER) to use depended on whether a
secondary click was possible via mouse bindings.

As a first step, always use a mouse source to break this dependency.
Note that this change might cause regressions in some (unknown) cases
(refs f70359f14f), but hopefully not.

Further commits will restore a finger source in some specific use cases,
but independent of secondary clicks.

Refs #5055 <https://github.com/Genymobile/scrcpy/issues/5055>
Fixes #5067 <https://github.com/Genymobile/scrcpy/issues/5067>
PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
0bce4d7f56 Add missing SC_ prefix for pointer id constants
PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
6d98766cd5 Simplify boolean condition using XOR
(A && !B) || (!A && B) <==> A ^ B

PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
487a6b9cf4 Remove top-level const
For consistency, never use top-level const for local variables.

PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
2024-07-11 12:04:09 +02:00
Romain Vimont
b50f9eb41d Add workaround for Skyworth devices
The vendor-modified ROM of Skyworth devices needs a valid app
info/context.

Fixes #4922 <https://github.com/Genymobile/scrcpy/issues/4922>
2024-07-08 17:16:01 +02:00
Yan
46041e0cc0 Always initialize display->gl_context on macOS
Otherwise SDL_GL_DeleteContext() tried to access an uninitialized
pointer upon exit when not using the OpenGL renderer.

SDL_GL_DeleteContext() doesn't try to delete a NULL pointer, so no need
to check for that.

Fixes #5057 <https://github.com/Genymobile/scrcpy/issues/5057>
PR #5058 <https://github.com/Genymobile/scrcpy/pull/5058>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-07-06 00:11:48 +02:00
Romain Vimont
b419eef55e Do not report error on device disconnected
A device disconnection (when the adb connection is closed) makes the
read() on the "receiver" socket fail.

Since commit 063a8339ed, this is reported
as an error. As a consequence, scrcpy fails with:

    ERROR: Controller error

instead of:

    WARN: Device disconnected

To fix the issue, report a device disconnection in that case.

PR #5044 <https://github.com/Genymobile/scrcpy/pull/5044>
2024-07-06 00:04:07 +02:00
Romain Vimont
cc8e6133b0 Upgrade default versions in bug report template 2024-07-06 00:00:56 +02:00
Romain Vimont
126da0cb18 Rework bug report template checks
Remove explicit checkboxes, and add a link to prerequisites.
2024-07-06 00:00:55 +02:00