Commit Graph

2655 Commits

Author SHA1 Message Date
Romain Vimont
a5844e198e Add GitHub Actions release workflow
Fixes #4490 <https://github.com/Genymobile/scrcpy/issues/4490>
PR #5306 <https://github.com/Genymobile/scrcpy/pull/5306>
2024-10-27 20:31:24 +01:00
Romain Vimont
2687d20280 Rework release.mk for CI
Make it possible to build scrcpy-server and Windows binaries in
parallel from different GitHub Actions workflows, and to package
everything as a final step.

PR #5306 <https://github.com/Genymobile/scrcpy/pull/5306>
2024-10-27 20:29:13 +01:00
Romain Vimont
9c0a328498 Build server without meson in release.mk
This avoids to install meson/ninja to build scrcpy-server on the CI.

PR #5306 <https://github.com/Genymobile/scrcpy/pull/5306>
2024-10-27 20:26:38 +01:00
Romain Vimont
02ef3d57ce Split client and server tests in release.mk
This will allow to run server tests separately on the CI.

PR #5306 <https://github.com/Genymobile/scrcpy/pull/5306>
2024-10-27 20:26:26 +01:00
Romain Vimont
538a32a539 Fix .PHONY in release.mk
The prepare-deps recipe does not exist anymore. It has been split into
prepare-deps-win32 and prepare-deps-win64.

PR #5306 <https://github.com/Genymobile/scrcpy/pull/5306>
2024-10-27 20:26:13 +01:00
Romain Vimont
9578aae34e Use explicit constant for @TargetApi 2024-10-22 19:47:56 +02:00
Romain Vimont
7b3dd595b4 Remove useless version check
Scrcpy requires Android 5.0+, so there is no point testing for older
versions.

Btw, there were two mistakes:
 - the constant name in AndroidVersions should have been
   API_20_ANDROID_4_4W (Android 4.4 without 'W' is API 19)
 - the method isInteractive() was introduced in Android 5.0, not 4.4W:
   <037c33eae7%5E%21/>
2024-10-21 18:51:35 +02:00
Romain Vimont
a46150f753 Upgrade Android SDK to 35
Also adapt the call to build-tools/35.0.0/aidl, which now requires an
import path (-I. for the current directory).

Otherwise, it fails with:

    ERROR: android/view/IRotationWatcher.aidl:23.1-10: directory ./ is not found in any of the import paths:
     -

Also upgrade AGP (8.7.1) and Gradle (8.9), required for SDK 35.

<https://developer.android.com/build/releases/gradle-plugin#updating-gradle>
2024-10-20 15:26:19 +02:00
Romain Vimont
3acffaae57 Use explicit constants for Android versions
Who remembers code names? This avoids to check the mapping every time.
2024-10-20 13:15:22 +02:00
dillonfrederica
e33be3d288 Fix SDL_events.h include
All SDL includes must be prefixed by "SDL2/".

Fixed #5372 <https://github.com/Genymobile/scrcpy/issues/5372>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-10-12 15:57:24 +02:00
Romain Vimont
c15df01171 Reject non-positive camera sizes early
Throw an exception on parsing if the camera size dimensions are not both
positive.
2024-10-11 22:51:15 +02:00
Romain Vimont
09741bc805 Do not duplicate server string params
The server params were passed from the main thread to the server thread,
so a deep copy was performed in case the caller instance was destroyed.

But in practice, it only contains memory that lives until the end of the
program (command line arguments), so simply reference it. Several copies
of string fields were missing anyway.
2024-10-11 22:42:39 +02:00
Romain Vimont
afbaf59abb Cast to sc_tick type in conversion macros
With the old macros definitions, the type of the result depended on the
type of `sec`.

In particular, if sec is a 32-bit type, sec * 1000000 was likely to
overflow (even if the result was assigned to a sc_tick by the caller of
the macro).

This was the case on Windows, where the long type is a 32-bit signed
integer: the --time-limit argument, expressed in seconds, was first
parsed to a long value, then multiplied by 1000000 by the
SC_TICK_FROM_SEC() macro, causing an overflow when the value was greater
than 2147 (2^31 / 1000000).

Fixes #5355 <https://github.com/Genymobile/scrcpy/issues/5355>
2024-10-08 18:18:05 +02:00
Romain Vimont
5b10650f22 Fix time-limit early interruption
If a value for --time-limit was set, then the thread was not interrupted
on stop (the condvar was not signaled).
2024-10-08 18:12:55 +02:00
Yan
0d8014be52 Fix build error on macOS
Fix window access typo for macOS.

PR #5348 <https://github.com/Genymobile/scrcpy/pull/5348>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-10-07 16:54:15 +02:00
Romain Vimont
064670ab4c Add missing include common.h 2024-10-06 18:07:05 +02:00
Romain Vimont
ff9fb5994d Use shortcut mods as mouse capture keys
Instead of using separate hardcoded keys for mouse capture/uncapture,
use the shortcut mods.

By changing the shortcut mods (for example --shortcut-mod=rctrl), it
allows to forward Alt and Super to the device.

Fixes #5318 <https://github.com/Genymobile/scrcpy/issues/5318>
PR #5322 <https://github.com/Genymobile/scrcpy/pull/5322>
2024-10-06 18:01:02 +02:00
Romain Vimont
a36de26969 Move shortcut mod functions to a separate header
This will allow to reuse it for mouse capture keys, which are handled by
a component separate from the input manager.

PR #5322 <https://github.com/Genymobile/scrcpy/pull/5322>
2024-10-06 18:00:59 +02:00
Romain Vimont
281fcc7052 Extract mouse capture
Factorize mouse capture for relative mouse mode to reduce code
duplication between normal and OTG modes.

PR #5322 <https://github.com/Genymobile/scrcpy/pull/5322>
2024-10-06 18:00:56 +02:00
Romain Vimont
65fc53eace Simplify (and inline) is_shortcut_mod()
Masking was unnecessary (im->sdl_shortcut_mods is implicitly masked).

PR #5322 <https://github.com/Genymobile/scrcpy/pull/5322>
2024-10-06 18:00:52 +02:00
Romain Vimont
a6f74d72f5 Forward Alt and Super with SDK keyboard
Alt and Super (also named Meta) modifier keys are captured for shortcuts
by default (cf --shortcut-mod).

However, when shortcut modifiers are changed, Alt and Super should be
forwarded to the device. This is the case for AOA and UHID keyboards,
but it was not the case for SDK keyboard.

Fixes #5318 <https://github.com/Genymobile/scrcpy/issues/5318>
PR #5322 <https://github.com/Genymobile/scrcpy/pull/5322>
2024-10-06 18:00:25 +02:00
Romain Vimont
e724ff4349 Simplify IO.writeFully() for Android >= 6
Do not handle buffer properties manually for Android >= 6 (where it is
already handled by Os.write()).

Refs <d9f7e57f5d%5E%21/>
2024-10-01 22:50:34 +02:00
Romain Vimont
79014143b9 Fix IO.writeFully() on Android 5
Os.write() did not update the ByteBuffer position before Android 6.

A workaround was added by commit
b882322f73, which fixed part of the
problem, but the position was still not updated across calls, causing
the wrong chunk to be written.

Refs <d9f7e57f5d%5E%21/>
2024-10-01 22:49:55 +02:00
Romain Vimont
c0a6432967 Extract EINTR handling for Os.write()
Expose a function which retries automatically on EINTR, and throws an
IOException on other errors.
2024-10-01 22:39:06 +02:00
Romain Vimont
ec602a0334 Suggest command line arguments without quotes
Replace argument suggestion:

    --video-encoder='c2.android.avc.encoder'

by:

    --video-encoder=c2.android.avc.encoder

On Linux, the quotes are interpreted by the shell, but on Windows they
are passed as is.

This was harmless, because even transmitted as is, they were interpreted
by the shell on the device. However, special characters are now
validated since commit bec3321fff, making
the command fail.

Fixes #5329 <https://github.com/Genymobile/scrcpy/issues/5329>
2024-09-30 08:16:33 +02:00
Romain Vimont
7a9ea5c66f Add shortcut for horizontal tilt
Use Ctrl+Shift for horizontal tilt.

Refs #4529 comment <https://github.com/Genymobile/scrcpy/pull/4529#issuecomment-1855397118>
Fixes #5317 <https://github.com/Genymobile/scrcpy/issues/5317>
2024-09-25 21:38:09 +02:00
Romain Vimont
d92b7a6024 Rename switch_fullscreen() to toggle_fullscreen()
Toggle means to switch between two states.
2024-09-25 19:59:49 +02:00
Romain Vimont
0bb3955b95 Split audio player
The audio player had 2 roles:
 - handle the SDL audio output device;
 - resample input samples to maintain a target latency.

Extract the latter to a separate component (an "audio regulator"),
independent of SDL.
2024-09-23 23:59:08 +02:00
Romain Vimont
62776fb261 Make audio buffering independant of output buffer
This will allow to extract the "audio regulator" part from the audio
player.
2024-09-23 23:59:08 +02:00
Romain Vimont
10f60054ac Use exact-width integer types 2024-09-23 23:59:08 +02:00
Romain Vimont
42fb947780 Use local mutex for audio player
Replace SDL_LockAudioDevice() by a local mutex, to minimize the lock
section and to make the code independent of SDL.
2024-09-23 23:59:08 +02:00
Romain Vimont
2e7a15a998 Remove unused audio player fields
They are only used locally.
2024-09-23 23:59:08 +02:00
Romain Vimont
a7e61fb871 Remove unused audio player callbacks
The callbacks were never used: the player can report errors directly
from sc_audio_player_frame_sink_push().
2024-09-23 23:59:08 +02:00
Romain Vimont
0cc6f6aa09 Detect codec/encoder mismatch
Fail with an explicit error when the requested encoder does not match
the requested codec.

Refs #5066 <https://github.com/Genymobile/scrcpy/issues/5066>
2024-09-20 08:45:46 +02:00
Romain Vimont
f69ac40534 Reorganize server imports
Moving classes into subpackages changed the expected imports order.

Reorganize them all at once automatically to avoid spurious changes in
future commits.
2024-09-20 08:43:42 +02:00
Romain Vimont
665ccb32f5 Update links to 2.7 2024-09-15 21:18:15 +02:00
Romain Vimont
292adf294d Bump version to 2.7 2024-09-15 18:59:27 +02:00
Romain Vimont
f9f3bfabe3 Merge branch 'master' into release 2024-09-15 18:59:16 +02:00
Romain Vimont
6d23a389ca Upgrade FFmpeg (7.0.2) for Windows 2024-09-15 18:58:53 +02:00
Romain Vimont
337901368e Upgrade SDL (2.30.7) for Windows 2024-09-15 18:58:53 +02:00
Romain Vimont
4cc4abdcc8 Mention issue with AOA and multiple gamepads
Android does not support multiple HID gamepads properly over AOA.

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 18:58:53 +02:00
Romain Vimont
befc0fac5b Mention UHID permission errors
UHID may not work on old Android versions due to permission errors.

Mention it in UHID mouse and gamepad documentation (it was already
mentioned for UHID keyboard).

Refs #4473 comment <https://github.com/Genymobile/scrcpy/pull/4473#issuecomment-1975133226>
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 18:58:44 +02:00
Romain Vimont
f01a622ead Enable joystick events in background
Capture the gamepads even when the window is not focused.

Note: In theory, with this flag set, we could capture gamepad events
even without a window (--no-window). In practice, scrcpy still requires
a window, because --no-window implies --no-control, and the input
manager is owned by the sc_screen instance, which does not exist if
there is no window. Supporting this use case would require a lot of
refactors.

Refs <https://github.com/Genymobile/scrcpy/pull/5270#issuecomment-2339360460>
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>

Suggested-by: Luiz Henrique Laurini <luizhenriquelaurini@gmail.com>
2024-09-15 11:21:56 +02:00
Romain Vimont
0ba430a462 Add gamepad user documentation
Mainly copied and adapted from HID keyboard and mouse documentation.

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00
Romain Vimont
91d40c7548 Fix link in OTG documentation
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00
Romain Vimont
9f3d51106d Remove fragile assert()
The sc_uhid_devices instance is initialized only when there is a UHID
keyboard.

The device message receiver assumed that it could not receive HID output
reports without a sc_uhid_devices instance (i.e. without a UHID
keyboard), but in practice, a UHID driver implementation on the device
may decide to send UHID output reports for mouse or for gamepads (and we
must just ignore them).

So remove the assert().

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00
Romain Vimont
bf2b679e70 Simplify UHID outputs routing
There was a registration mechanism to listen to HID outputs with a
specific HID id.

However, the UHID gamepad processor handles several ids, so it cannot
work. We could complexify the registration mechanism, but instead,
directly dispatch to the expected processor based on the UHID id.

Concretely, instead of passing a sc_uhid_devices instance to construct a
sc_keyboard_uhid, so that it can register itself, construct the
sc_uhid_devices with all the UHID instances (currently only
sc_keyboard_uhid) so that it can dispatch HID outputs directly.

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00
Romain Vimont
7f250dd669 Mention physical gamepad names for UHID devices
Initialize UHID devices with a custom name:
 - "scrcpy: $GAMEPAD_NAME" for gamepads
 - "scrcpy" for keyboard and mouse (or if no gamepad name is available)

The name may appear in Android apps.

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00
Romain Vimont
68e27c7357 Reorder function parameters for consistency
Make the local function write_string() accept the output buffer as a
first parameter, like the other similar functions.

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00
Romain Vimont
c4febd55eb Make -K -M and -G use AOA in OTG mode
For convenience, short options were added to select UHID input modes:
 - -K for --keyboard=uhid
 - -M for --mouse=uhid
 - -G for --gamepad=uhid

In OTG mode, UHID is not available, so the short options should select
AOA instead.

PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
2024-09-15 11:21:56 +02:00