Commit Graph

1303 Commits (db484d82dbb41f3aeca6a02e4b818ad54af03a47)
 

Author SHA1 Message Date
Romain Vimont db484d82db Upgrade gradle build tools to 7.0.2 3 years ago
Romain Vimont 0c9666b733 Upgrade Android checkstyle to 9.0.1
Adapt checkstyle.xml to match the latest version, and remove a line
break between imports which trigger a checkstyle volation.
3 years ago
Romain Vimont 8bf28e9f53 Upgrade Android SDK to 31 3 years ago
Romain Vimont 06131ef634 Fix typo in clock comments 3 years ago
Romain Vimont 34eb10ea0b Define v4l2 option field only if HAVE_V4L2 3 years ago
Romain Vimont 27fa23846d Define default options as const struct
This is more readable than a macro, and we could ifdef some fields.
3 years ago
Romain Vimont e4d5c1ce36 Move scrcpy option structs to options.h
This will allow to define symbols in options.c without all the
dependencies of scrcpy.c.
3 years ago
Romain Vimont ac23bec144 Expose socket interruption
On Linux, socket functions are unblocked by shutdown(), but on Windows
they are unblocked by closesocket().

Expose net_interrupt() and net_close() to abstract these differences:
 - net_interrupt() calls shutdown() on Linux and closesocket() on
   Windows (if not already called);
 - net_close() calls close() on Linux and closesocket() on Windows (if
   not already called).

This simplifies the server code, and prevents a data race on close
(reported by TSAN) on Linux (but does not fix it on Windows):

    WARNING: ThreadSanitizer: data race (pid=836124)
      Write of size 8 at 0x7ba0000000d0 by main thread:
        #0 close ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1690 (libtsan.so.0+0x359d8)
        #1 net_close ../app/src/util/net.c:211 (scrcpy+0x1c76b)
        #2 close_socket ../app/src/server.c:330 (scrcpy+0x19442)
        #3 server_stop ../app/src/server.c:522 (scrcpy+0x19e33)
        #4 scrcpy ../app/src/scrcpy.c:532 (scrcpy+0x156fc)
        #5 main ../app/src/main.c:92 (scrcpy+0x622a)

      Previous read of size 8 at 0x7ba0000000d0 by thread T6:
        #0 recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6603 (libtsan.so.0+0x4f4a6)
        #1 net_recv ../app/src/util/net.c:167 (scrcpy+0x1c5a7)
        #2 run_receiver ../app/src/receiver.c:76 (scrcpy+0x12819)
        #3 <null> <null> (libSDL2-2.0.so.0+0x84f40)
3 years ago
Romain Vimont e5ea13770b Add socket wrapper
This paves the way to store an additional "closed" flag on Windows
to interrupt and close properly.
3 years ago
Romain Vimont 3eac212af1 Use net_send() from net_send_all()
This will make net_send_all() continue to work even if net_send()
behavior is changed.
3 years ago
Romain Vimont 3adff37c2d Use sc_ prefix for sockets
Rename:
 - socket_t to sc_socket
 - INVALID_SOCKET to SC_INVALID_SOCKET
3 years ago
Romain Vimont eb6afe7669 Move net_init() and net_cleanup() upwards
These two functions are global, define them at the top of the
implementation file. This is consistent with the header file.
3 years ago
Romain Vimont 5222f213f4 Update FAQ to mention HID keyboard 3 years ago
Romain Vimont e4163321f0 Delay HID events on Ctrl+v
When Ctrl+v is pressed, a control is sent to the device to set the
device clipboard before injecting Ctrl+v.

With the InputManager method, it is guaranteed that the device
synchronization is executed before handling Ctrl+v, since the commands
are executed on the device in sequence.

However, HID are injected from the computer, so there is no such
guarantee. As a consequence, on Android, Ctrl+v triggers a paste with
the old clipboard content.

To workaround the issue, wait a bit (2 milliseconds) from the AOA
thread before injecting the event, to leave enough time for the
clipboard to be set before injecting Ctrl+v.
3 years ago
Romain Vimont c96874b257 Synchronize HID keyboard state on first event
When an AOA HID keyboard is registered, CAPSLOCK and NUMLOCK are both
disabled, regardless of the state of the computer keyboard.

To synchronize the state, on first key event, inject CAPSLOCK and/or
NUMLOCK if necessary.
3 years ago
Romain Vimont 511356710d Retrieve device serial for AOA
The serial is necessary to find the correct Android device for AOA.

If it is not explicitly provided by the user via -s, then execute "adb
getserialno" to retrieve it.
3 years ago
Romain Vimont d55015e4cf Expose function to get the device serial
Expose adb_get_serialno() to retrieve the device serial via the command
"adb getserialno".
3 years ago
Romain Vimont 0681480809 Add read_pipe_all()
Add a convenience function to read from a pipe until all requested data
has been read.
3 years ago
Romain Vimont 96b18dabaa Expose adb execution with redirection
Expose the redirection feature to the adb API.
3 years ago
Romain Vimont eaf4afaad9 Add command execution with redirection
Expose command execution with pipes to stdin, stdout and stderr.

This will allow to read the result of adb commands.
3 years ago
Alynx Zhou 207082977a Add support for USB HID keyboard over AOAv2
This provides a better input experience, by simulating a physical
keyboard. It converts SDL keyboard events to proper HID events, and send
them over AOAv2.

This is a rewriting and bugfix of the origin code from @amosbird:
<https://github.com/Genymobile/scrcpy/issues/279#issuecomment-453819354>

The feature is enabled the command line option -K or --hid-keyboard,
and is only available on Linux, over USB.

Refs <https://source.android.com/devices/accessories/aoa2#hid-support>
Refs <https://www.usb.org/sites/default/files/hid1_11.pdf>

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

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont f7d1efdf1d Extract mouse processor trait
Mainly for consistency with the keyboard processor trait.

This could allow to provide alternative mouse processors.
3 years ago
Romain Vimont bcf5a9750f Extract keyboard processor trait
This will allow to provide alternative key processors.
3 years ago
Romain Vimont 056d36ce4a Fix trait header guards 3 years ago
Romain Vimont bea3197c3f Remove unused markdown link in README 3 years ago
Romain Vimont d6568f64af Mention SCRCPY_ICON_PATH envvar in README 3 years ago
Romain Vimont 580f5d8bb9 Add scrcpy icon to README 3 years ago
Romain Vimont 1e340caf76 Remove legacy scrcpy icon
Remove the old icon in XPM format and the code to load it.
3 years ago
Romain Vimont 3d5b31e0cb Add icon source in SVG format
Scrcpy only uses the PNG format (because SDL only supports bitmap
icons), but keep the SVG source in the repo.
3 years ago
Romain Vimont 6004f0b6b0 Use a new scrcpy icon
Use the new icon designed by @varlesh:
<https://github.com/Genymobile/scrcpy/pull/1987#issuecomment-949684080>

Load it from a PNG file (SDL only supports bitmap icons).
3 years ago
Romain Vimont 12ed2f2402 Add support for palette icon formats
To support more icon formats.
3 years ago
Romain Vimont 0e4564da03 Add icon loader
Add helper to load icons from image files via FFmpeg.
3 years ago
Romain Vimont 156d958e77 Move common instruction out of ifdef
Both ifdef-branches return server_path.
3 years ago
Romain Vimont 7229e3cce0 Extract util function to build a local file path
Finding a local file in the scrcpy directory may be useful for files
other than scrcpy-server in the future.
3 years ago
Romain Vimont a7e41b0f85 Fix code style 3 years ago
zhongkaizhu 46d3e35c30 Fix "Could not find v4l2 muxer"
The AVOutputFormat name is a comma-separated list. In theory, possible
names for V4L2 are:

    - "video4linux2,v4l2"
    - "v4l2,video4linux2"
    - "v4l2"
    - "video4linux2"

To find the muxer in all cases, we must request exactly one muxer name
at a time.

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

Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 07d75eb336 Simplify net_send_all()
There is no need to declare the variable before the loop.
3 years ago
Romain Vimont 8df42cec82 Fix workarounds for Meizu
Workarounds.fillAppInfo() is necessary for Meizu devices even before the
first call to internalStreamScreen(), but it is harmful on other
devices (#940).

Therefore, simplify the workaround, by calling fillAppInfo() only if
Build.BRAND equals "meizu" (case insensitive).

Fixes #240 <https://github.com/Genymobile/scrcpy/issues/240> (again)
Fixes #2656 <https://github.com/Genymobile/scrcpy/issues/2656>
3 years ago
Romain Vimont 31131039bb Add missing includes
Refs #2616 <https://github.com/Genymobile/scrcpy/issues/2616>
3 years ago
Romain Vimont fa100b814b Add support for expandNotificationsPanel() variant
Some custom vendor ROM added an int as a parameter.

Fixes #2551 <https://github.com/Genymobile/scrcpy/issues/2551>
3 years ago
Romain Vimont 069fe93f74 Update links to v1.19 3 years ago
Romain Vimont 228e2c15f4 Bump version to 1.19 3 years ago
Romain Vimont 9a8f06af65 Merge branch 'master' into dev 3 years ago
Romain Vimont 1d1c9f36f4 Retrieve correct error messages on Windows
For sockets functions, Windows does not store error codes in errno, so
perror() does not print any error. Use WSAGetLastError() instead.

Refs #2624 <https://github.com/Genymobile/scrcpy/issues/2624>
3 years ago
Romain Vimont 4d6dd9d281 Compute scrcpy directory manually
The function dirname() does not work correctly everywhere with non-ASCII
characters.

Fixes #2619 <https://github.com/Genymobile/scrcpy/issues/2619>
3 years ago
a1346054 b5e98db635 Fix typo in manpage
PR #2606 <https://github.com/Genymobile/scrcpy/pull/2606>

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 116acc8d25 Use SOURCE_MOUSE for scroll events
This has no practical impact (AFAIK), but a scroll events should come
from a mouse.

Refs #2602 <https://github.com/Genymobile/scrcpy/issues/2602>
3 years ago
nkh0472 3a39bacb76 Upgrade SDL (2.0.16) for Windows
Include the latest version of SDL in Windows releases.

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

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
nkh0472 3fdc89ad42 Upgrade platform-tools (31.0.3) for Windows
Include the latest version of adb in Windows releases.

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

Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont 3761f56c28 Declare callbacks static
It was a typo, "static" was missing.
3 years ago