Simon Chan
57056d078d
Use precise scrolling values
...
Since SDL 2.0.18, the amount scrolled horizontally or vertically is
exposed as a float (between 0 and 1). Forward a precise value to the
Android device when possible.
Refs <https://wiki.libsdl.org/SDL_MouseWheelEvent >
Fixes #3363 <https://github.com/Genymobile/scrcpy/issues/3363 >
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-08-28 15:23:08 +02:00
Romain Vimont
1f138aef41
Add conversion from float to fixed-point i16
...
To encode float values between -1 and 1.
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
fd3483c837
Extract conversion from float to u16 fixed-point
...
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
041cdf6cf5
Rename buffer_util.h to binary.h
...
It will allow to expose more binary util functions not related to
buffers.
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
2022-08-28 15:23:08 +02:00
Romain Vimont
d19606eb0c
Rename net_listen() parameter
...
For consistency with net_accept(), which necessarily uses a server
socket, name the net_listen() parameter "server_socket".
2022-08-17 16:40:45 +02:00
Romain Vimont
d23b3e88a4
Replace '%g' by '%f' as printf format
...
For some reason, '%g' does not work correctly with MinGW.
Refs #3369 <https://github.com/Genymobile/scrcpy/pull/3369 >
PR #3399 <https://github.com/Genymobile/scrcpy/pull/3399 >
2022-08-03 23:25:09 +02:00
Romain Vimont
a47848f304
Detect Windows using _WIN32 in network util
...
For consistency, always use _WIN32 instead of a mix of __WINDOWS__ and
_WIN32.
2022-07-27 14:54:27 +02:00
Romain Vimont
db8c1ce8e1
Fix protocol documentation in comments
...
Flags were in the correct order in the schema, but their description
were reversed.
2022-07-20 11:41:04 +02:00
Romain Vimont
4aeb78ece2
Add missing allocation failure check
2022-07-19 12:17:02 +02:00
Romain Vimont
396e4bd925
Add missing LOG_OOM() on malloc failure
2022-07-19 12:15:06 +02:00
Romain Vimont
af4b7855e1
Remove unused stream.h
...
The file was not removed by 7dec225ceb
.
2022-06-09 15:02:42 +02:00
Romain Vimont
b1d8c72780
Rename function to simplify
...
For consistency with sc_adb_parse_device(), do not include "from_output"
in the function name.
2022-06-09 15:02:42 +02:00
Romain Vimont
2f038c834a
Revert "Make OTG window resizable"
...
On Windows and macOS, resizing blocks the event loop. Handling it
properly would require the same workaround as done in screen.c.
This reverts commit 436b368f9d
.
2022-04-28 20:45:46 +02:00
Romain Vimont
76b3fcf986
Fix inverted check
...
SDL_RenderSetLogicalSize() returns 0 on success.
Refs fc8942aa03
2022-04-28 20:45:46 +02:00
Romain Vimont
854a56e588
Enable linear filtering in OTG mode
...
This improves the icon quality with non-standard window size.
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:16 +02:00
Romain Vimont
436b368f9d
Make OTG window resizable
...
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:12 +02:00
Romain Vimont
fc8942aa03
Apply requested window size in OTG mode
...
Fixes #3099 <https://github.com/Genymobile/scrcpy/issues/3099 >
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:18:09 +02:00
Romain Vimont
c6d9711109
Create OTG window with HIGHDPI flag
...
This will avoid poor quality with HiDPI displays.
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2022-04-28 19:17:49 +02:00
Romain Vimont
0fca2ad830
Add option to not power on on start
...
By default, on start, the device is powered on. To prevent this
behavior, add a new option --no-power-on.
Fixes #3148 <https://github.com/Genymobile/scrcpy/issues/3148 >
PR #3210 <https://github.com/Genymobile/scrcpy/pull/3210 >
2022-04-28 19:12:52 +02:00
Romain Vimont
326897a0d4
Add missing mouse shortcuts in --help
...
Document 4th-click and 5th-click shortcuts.
Fixes #3122 <https://github.com/Genymobile/scrcpy/issues/3122 >
2022-04-25 18:35:06 +02:00
Romain Vimont
fa5b2a29e9
Add missing SC_ prefix to header guards
2022-04-12 23:59:01 +02:00
Romain Vimont
0c94887075
Add missing include
...
Refs c3d45c8397
2022-04-12 23:51:05 +02:00
Romain Vimont
aaf3869a54
Fix OpenGL ES prefix skip
2022-03-30 12:01:01 +02:00
Romain Vimont
c3d45c8397
Consider emulators as TCP/IP devices
...
Emulators were wrongly considered as USB devices, so they were selected
using -d instead of -e (which was inconsistent with the adb behavior).
Refs #3005 <https://github.com/Genymobile/scrcpy/issues/3005 >
Refs #3137 <https://github.com/Genymobile/scrcpy/issues/3137 >
2022-03-22 21:08:08 +01:00
Romain Vimont
e56f2ac7a9
Log an error on unexpected device state
...
Refs #3129 <https://github.com/Genymobile/scrcpy/issues/3129 >
2022-03-20 14:56:52 +01:00
Romain Vimont
4ce7af42c6
Use $ANDROID_SERIAL if no selector is specified
...
Like adb, read the ANDROID_SERIAL environment variable to select a
device by serial if no explicit selection (-s, -d, -e or --tcpip=<addr>)
is provided via the command line.
Fixes #3111 <https://github.com/Genymobile/scrcpy/issues/3111 >
PR #3113 <https://github.com/Genymobile/scrcpy/pull/3113 >
2022-03-15 08:32:34 +01:00
Romain Vimont
b1dbc30072
Document exit status in --help
...
Refs #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
2022-03-10 09:13:21 +01:00
martin f. krafft
b3f5dfe1de
Add specific exit code for device disconnection
...
Modify the return logic such that exit code 1 is used when the initial
connection fails, but if a session is established, and then the device
disconnects, exit code 2 is emitted.
Fixes #3083 <https://github.com/Genymobile/scrcpy/issues/3083 >
PR #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Romain Vimont <rom@rom1v.com>
2022-03-06 22:19:46 +01:00
Romain Vimont
1f4c801f3c
Report server connection state
...
We must distinguish 3 cases for await_for_server():
- an error occurred
- no error occurred, the device is connected
- no error occurred, the device is not connected (user requested to
quit)
For this purpose, use an additional output parameter to indicate if the
device is connected (only set when no error occurs).
Refs #3085 <https://github.com/Genymobile/scrcpy/pull/3085 >
2022-03-06 22:16:13 +01:00
Romain Vimont
8d91cda4f6
Improve HID event push error message
...
On HID event push failure, add the event type in the error message.
2022-02-24 23:28:20 +01:00
Romain Vimont
59656fe649
Fix typo in error message
2022-02-24 23:26:12 +01:00
Romain Vimont
e4bb2b8728
Add libusb error log
...
Log libusb_get_string_descriptor_ascii() errors.
Refs #3050 <https://github.com/Genymobile/scrcpy/issues/3050 >
2022-02-24 23:25:02 +01:00
Romain Vimont
71ef5cc0a9
Add missing include for vector
...
Include stdlib.h for realloc().
2022-02-22 21:00:43 +01:00
Romain Vimont
79ed83ab68
Reorder --tcpip option in cli
...
To keep options in alphabetic order.
2022-02-22 18:10:30 +01:00
Romain Vimont
e2e76c5d48
Increase adb devices -l
max output size
...
For simplicity, the parsing of `adb devices -l` output is performed in a
single pass on the whole output.
This output was limited to 4096 bytes. Since there are about 100 chars
per device line, this limited the number of connected devices to ~40.
Increase to 65536 bytes to avoid a limitation in practice.
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
2022-02-21 00:03:45 +01:00
Romain Vimont
4b8cb042c4
Use vector for listing ADB devices
...
This avoids the hardcoded maximum number of ADB devices detected (16).
Refs #3029 <https://github.com/Genymobile/scrcpy/pull/3029 >
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
Co-authored-by: Daniel Ansorregui <d.ansorregui@samsung.com>
2022-02-20 23:59:35 +01:00
Romain Vimont
1790e88278
Use vector for listing USB devices
...
This avoids the hardcoded maximum number of USB devices detected (16).
Refs #3029 <https://github.com/Genymobile/scrcpy/pull/3029 >
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
2022-02-20 23:59:35 +01:00
Romain Vimont
c070723bc8
Add sc_vector
...
Adapt vlc_vector [1], that I initially wrote while implementing the VLC
playlist [2].
Change the implementation to use "statement expressions" [3], which are
forbidden in VLC because "non-standard", but:
- they are supported by gcc and clang;
- they are already used in the scrcpy codebase;
- they avoid implementation hacks (VLC_VECTOR_FAILFLAG_);
- they allow a better API (sc_vector_index_of() may return the result
without an output parameter).
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035 >
[1]: 0857947aba/include/vlc_vector.h
[2]: https://blog.rom1v.com/2019/05/a-new-core-playlist-for-vlc-4
[3]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
2022-02-20 23:59:35 +01:00
Romain Vimont
73a5311ac6
Forbid HID input without OTG on Windows
...
On Windows, if the adb daemon is running, opening the USB device will
necessarily fail, so HID input is not possible.
Refs #2773 <https://github.com/Genymobile/scrcpy/issues/2773 >
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:42 +01:00
Romain Vimont
25296ae167
Kill adb daemon in OTG mode on Windows
...
On Windows, it is not possible to open a USB device from several
process, so HID events may only work if no adb daemon is running.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:39 +01:00
Romain Vimont
3bb24b3926
Make intr optional for adb commands
...
All adb commands are executed with an "interruptor", so that they can be
interrupted on Ctrl+C.
Make this interruptor optional, so that we could call "adb kill-server"
in OTG mode. This command always returns almost immediately anyway.
Ideally, we should make all blocking calls interruptible (including
libusb calls, by using the asynchronous API), but it's a lot of work,
and in practice it works well enough.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:36 +01:00
Romain Vimont
6ee75c0cff
Remove obsolete text in error message
...
The HID/OTG features are now available on all platforms.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:30 +01:00
Romain Vimont
ff3cb31cb4
Fix libusb callback for Windows
...
Add LIBUSB_CALL so that the callback has the correct signature on
Windows (including __attribute__((stdcall))).
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:09 +01:00
Romain Vimont
06243e7c3c
Avoid PRIx16 printf format on Windows
...
Convert uint16_t to unsigned to avoid using PRIx16, which may not exist
on Windows.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:39:04 +01:00
Romain Vimont
b9b2879789
Remove USB hotplug callback error log
...
If it fails, the error is already logged by sc_usb_register_callback().
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:38:51 +01:00
Romain Vimont
be1936bb85
Report USB device disconnection when detected
...
USB device disconnection is detected via a hotplug callback when it is
supported.
In addition, report disconnection on libusb calls returning
LIBUSB_ERROR_NO_DEVICE or LIBUSB_ERROR_NOT_FOUND. This allows to detect
disconnection after a libusb call when hotplug is not available.
PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011 >
2022-02-20 17:38:14 +01:00
Romain Vimont
3ee3f8dc02
Work around mouse capture SDL bug on macOS
...
On macOS, SDL relative mouse mode does not work correctly when the
cursor is outside the window.
As a workaround, move the cursor inside the window before setting the
relative mouse mode.
Refs SDL/#5340 <https://github.com/libsdl-org/SDL/issues/5340 >
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:28:02 +01:00
Romain Vimont
9db42341e4
Pass screen instance to mouse capture functions
...
Using the screen instance or not in these functions is an implementation
detail. Further changes will require the screen instance.
Refs 7848a387c8
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:27:53 +01:00
Romain Vimont
82a99f69ec
Remove "linux-only" mentions for HID/OTG features
...
HID/OTG features are not limited to Linux anymore.
PR #3031 <https://github.com/Genymobile/scrcpy/pull/3031 >
2022-02-20 17:27:43 +01:00
Romain Vimont
b4fd882ece
Fix typo
2022-02-20 17:21:25 +01:00