Romain Vimont
2d5525eac1
Move PRIu64 Windows workaround to compat.h
...
So that we can use it from several files.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
2a0730ee9b
Add device clipboard set acknowledgement
...
Add a device message type so that the device could send acknowledgements
for SET_CLIPBOARD requests.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
901d837165
Add sequence number to set_clipboard request
...
This will allow the client to request an acknowledgement.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
aba1fc03c3
Add acksync helper to wait for acks
...
This will allow to send requests with sequence numbers to the server
and wait for acknowledgements.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
5b3856c3b6
Explicitly indicate when device clipboard is set
...
Pass the information that device clipboard has been set to the key
processor. This avoids the keyprocessor to "guess", and paves the way to
implement a proper acknowledgement mechanism.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
854de9659a
Do not inject Ctrl+v if clipboard sync failed
...
This prevents to paste the current Android clipboard, which would be
unexpected.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
ea8028332c
Synchronize computer-to-device empty clipboard
...
Set the device clipboard to empty string if necessary. Otherwise, the
current device clipboard will be pasted on Ctrl+v.
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814 >
3 years ago
Romain Vimont
0427a981e5
Use UINT64_C macro for uint64_t constant in tests
...
A long constant might not be sufficient.
3 years ago
Romain Vimont
68eaee5bb0
Force adb forward if tunnel host/port is provided
...
Tunnel host and port are only meaningful in "adb forward" mode.
They indicate where the client must connect to communicate with the
server. In "adb reverse" mode, the client _listens_, it does not
_connect_.
Refs #2807 <https://github.com/Genymobile/scrcpy/pull/2807 >
3 years ago
RipleyTom
7bdbde7363
Add options to configure tunnel host and port
...
In "adb forward" mode, by default, scrcpy connects to localhost:PORT,
where PORT is the local port passed to "adb forward". This assumes that
the tunnel is established on the local host with a local adb server
(which is the common case).
For advanced usage, add --tunnel-host and --tunnel-port to force the
connection to a different destination.
Fixes #2801 <https://github.com/Genymobile/scrcpy/issues/2801 >
PR #2807 <https://github.com/Genymobile/scrcpy/pull/2807 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
RipleyTom
52e5181c84
Add function to parse IPv4 addresses
...
PR #2807 <https://github.com/Genymobile/scrcpy/pull/2807 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
3 years ago
Romain Vimont
ba547e3895
Configure feature test macros in meson
...
Refs #2807 <https://github.com/Genymobile/scrcpy/pull/2807 >
Co-authored-by: RipleyTom <RipleyTom@users.noreply.github.com>
3 years ago
Romain Vimont
226f3b2c91
Add missing include config.h
3 years ago
Romain Vimont
6da6d905c2
Print scrcpy header first
...
Inconditionnally print the scrcpy version first, without using LOGI().
The log level is configured only after parsing the command line
parameters (it may be changed via -V), and command line parsing logs
should not appear before the scrcpy version.
3 years ago
Romain Vimont
b25404ee4b
Print help to stdout
...
The output of -h/--help was printed on stderr, although it is not an
error.
Printing on stdout allows to pipe the result directly:
scrcpy --help | less
Instead of (in bash):
scrcpy --help |& less
3 years ago
Romain Vimont
4cfc1cd70a
Assert that long options are correctly set
3 years ago
Romain Vimont
2fc80eae2d
Simplify adb_tunnel
...
With the new adb functions, the static adb_tunnel functions become
unnecessary.
3 years ago
Romain Vimont
3fdbd994e0
Privatize low-level adb functions
...
Only expose the interruptible user-friendly API.
3 years ago
Romain Vimont
ce225f019a
Use new user-friendly adb API
...
Replace the adb_exec_*() calls by the new adb functions to simplify.
3 years ago
Romain Vimont
b7559744a7
Expose new user-friendly adb functions
...
Expose interruptible adb functions which return the expected result
directly, without exposing the process (sc_pid) to the caller.
3 years ago
Romain Vimont
afb5a5e80f
Rename adb functions to adb_exec_*
...
This paves the way to replace them by more user-friendly functions that
will call them internally.
3 years ago
Romain Vimont
84334cf7db
Use sc_intr in file_handler
...
Replace manual interruption handling by the recent sc_intr mechanism.
3 years ago
Romain Vimont
0ba2686e1d
Simplify file_handler
...
Call the target functions directly.
3 years ago
Romain Vimont
55648d4d64
Improve file_handler readability
...
Use local variables as short name aliases.
3 years ago
Romain Vimont
13fd693b50
Simplify adb_execute_p()
...
Only pass the stdout pipe as parameter, scrcpy never writes to stdin or
reads from stderr of an adb process.
3 years ago
Romain Vimont
0426ae885c
Make "adb get-serialno" interruptible
...
All process executions must be interruptible, so that Ctrl+c reacts
immediately.
3 years ago
Romain Vimont
ea454e9cee
Add interruptible function to read from pipe
...
This will avoid to block Ctrl+c if the process the pipe is read from
takes too much time.
3 years ago
Romain Vimont
cb65531533
Simplify sc_str_truncate()
...
Use strcspn() to get the prefix length directly.
3 years ago
Romain Vimont
9619ade706
Generalize string trunctation util function
...
Add an additional argument to let the client pass the possible end
chars.
3 years ago
Romain Vimont
f2781a8b6d
Expose util function to truncate first line
...
Move the local implementation from adb functions to the string util
functions.
3 years ago
Romain Vimont
443cb14d6e
Assume non-NULL serial in file_handler
...
The previous commit guarantees to always initialize the serial, so the
file_handle may assume it is never NULL.
3 years ago
Romain Vimont
b30c3a429f
Always retrieve device serial
...
This allows to execute all adb commands with the specific -s parameter,
even if it is not provided by the user.
In practice, calling adb without -s works if there is exactly one device
connected. But some adb commands (for example "adb push" on drag & drop)
could be executed after another device is connected, so the actual
device serial must be known.
3 years ago
Romain Vimont
632bd5697b
Add missing error handling
...
If "adb get-serialno" fails, attempting to read from the uninitialized
pipe is incorrect.
3 years ago
Romain Vimont
de50846905
Close process on check success
...
The interruptible version of the function to check process success
(sc_process_check_success_intr()) did not accept a close parameter to
avoid a race condition. But as the result, the processes were not closed
at all.
Add a close parameter, and close the process separately to avoid the
race condition.
3 years ago
Romain Vimont
9cb14b5166
Inherit only specific handles on Windows
...
To be able to communicate with a child process via stdin, stdout and
stderr, the CreateProcess() parameter bInheritHandles must be set to
TRUE. But this causes *all* handles to be inherited, including sockets.
As a result, the server socket was inherited by the process running adb
to execute the server on the device, so it could not be closed properly,
causing other scrcpy instances to fail.
To fix the issue, use an extended API to explicitly set the HANDLEs to
inherit:
- <https://stackoverflow.com/a/28185363/1987178 >
- <https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873 >
Fixes #2779 <https://github.com/Genymobile/scrcpy/issues/2779 >
PR #2783 <https://github.com/Genymobile/scrcpy/pull/2783 >
3 years ago
Romain Vimont
9cb8766220
Factorize resource release after CreateProcess()
...
Free the wide characters string in all cases before checking for errors.
3 years ago
Romain Vimont
fd4ec784e0
Remove useless assignments on error
...
Leave the output parameter untouched on error.
3 years ago
Romain Vimont
52cebe1597
Fix Windows sc_pipe function names
...
The implementation name was incorrect (it was harmless, because they are
not used on Windows).
3 years ago
Romain Vimont
6a27062f48
Stop connection attempts if interrupted
...
If the interruptor is interrupted, every network call will fail, but the
retry-on-error mechanism must also be stopped.
3 years ago
Romain Vimont
739ff9dce0
Fix compilation errors with old SDL versions
...
SDL_PixelFormatEnum has been introduced in SDL 2.0.10:
<cc6a8ac87e
>
SDL_PIXELFORMAT_BGR444 has been introduced in SDL 2.0.12:
<a1c11854f2
>
Fixes #2777 <https://github.com/Genymobile/scrcpy/issues/2777 >
PR #2781 <https://github.com/Genymobile/scrcpy/pull/2781 >
Reviewed-by: Yu-Chen Lin <npes87184@gmail.com>
3 years ago
Romain Vimont
45b0f8123a
Increase delay to inject HID on Ctrl+v
...
2 milliseconds turn out to be insufficient sometimes. It seems that 5
milliseconds is enough (and still not noticeable).
3 years ago
Romain Vimont
c1a34881d7
Use sc_ prefix for server
3 years ago
Romain Vimont
057c7a4df4
Move str_util to str
...
Simplify naming.
3 years ago
Romain Vimont
979ce64dc0
Improve string util API
...
Use prefixed names and improve documentation.
3 years ago
Romain Vimont
9a0bd545d5
Rename SC_INVALID_SOCKET to SC_SOCKET_NONE
...
For consistency with SC_PROCESS_NONE.
3 years ago
Romain Vimont
c4d008b96a
Extract adb tunnel to a separate component
...
This simplifies the server code.
3 years ago
Romain Vimont
0d45c29d13
Move IPV4_LOCALHOST to net.h
...
This constant will be used from several files.
3 years ago
Romain Vimont
37c840a4c8
Interrupt on process terminated
...
Interrupt any blocking call on process terminated, like on
server_stop().
This allows to interrupt any blocking accept() with correct
synchronization without additional complexity.
3 years ago
Romain Vimont
f488cbd7e7
Make server interruptible
...
Use an interruptor to immediately wake up blocking calls on
server_stop().
3 years ago
Romain Vimont
40340509d9
Add interruptor utilities
...
Expose wrapper functions for interrupting blocking calls, for process
and sockets.
3 years ago