Romain Vimont
d95276467b
Extract mouse HID handling
...
Split the mouse implementation using AOA and the code handling HID
events, so that HID events can be reused for another protocol (UHID).
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Romain Vimont
91485e2863
Extract keyboard HID handling
...
Split the keyboard implementation using AOA and the code handling HID
events, so that HID events can be reused for another protocol (UHID).
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Romain Vimont
f2d6203156
Extract HID events struct
...
An event contained several fields:
- the accessory id
- the HID event data
- a field ack_to_wait specific to the AOA implementation.
Extract the HID event part to prepare the factorization of HID event
creation.
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Romain Vimont
2d32557fde
Embed HID event data
...
In the implementation, an HID event is at most 8 bytes. Embed the data
in the HID event structure to avoid allocations and simplify the code.
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Romain Vimont
ae303b8d07
Rename hid event "buffer" to "data"
...
This fields contains the HID event data (there is no "bufferization").
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Romain Vimont
29ce03e337
Rename "buffer" to "data"
...
The variable name is intended to match the parameter name of
libusb_control_transfer().
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Romain Vimont
48adae1728
Fix HID mouse documentation
...
The size of a mouse HID event is 4 bytes.
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
7 months ago
Simon Chan
ea98d49bae
Introduce --keyboard and --mouse
...
Until now, there was two modes for keyboard and mouse:
- event injection using the Android system API (default)
- HID/AOA over USB
For this reason, the options were exposed as simple flags:
- -K or --hid-keyboard to enable physical keyboard simulation (AOA)
- -M or --hid-mouse to enable physical mouse simulation (AOA)
Replace them by explicit --keyboard and --mouse options, with 3 possible
values:
- disabled
- sdk (default)
- aoa
This will allow to add a new mode (uhid).
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473 >
Co-authored-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
7 months ago
Romain Vimont
9e22f3bf1c
Replace unsigned char by uint8_t for buffers
...
For consistency.
7 months ago
Romain Vimont
2ad93d1fc0
Fix scrcpy_otg() return value on error
...
The function now returns an enum scrcpy_exit_code, not a bool.
9 months ago
Avinash Sonawane
76a99a7fcd
Replace raw number by its name
...
PR #4373 <https://github.com/Genymobile/scrcpy/pull/4373 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
11 months ago
Avinash Sonawane
9ade389069
Make sc_usb_devices_destroy() static
...
It is only called from the implementation file.
PR #4371 <https://github.com/Genymobile/scrcpy/pull/4371 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
11 months ago
Romain Vimont
fe6e9acb36
Log device selection at INFO level
...
The selected device should be logged by default.
1 year ago
Romain Vimont
b16d4d1835
Fix adb server vs adb daemon confusion
...
The adb daemon runs on the device, the adb server runs as a background
process on the computer.
1 year ago
Romain Vimont
f978e4d6de
Use VecDeque in aoa_hid
...
Replace cbuf by VecDeque in aoa_hid
2 years ago
Romain Vimont
4f9e9c6619
Prefix UI events constants by SC_
2 years ago
Romain Vimont
4aeb78ece2
Add missing allocation failure check
2 years ago
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
.
2 years ago
Romain Vimont
76b3fcf986
Fix inverted check
...
SDL_RenderSetLogicalSize() returns 0 on success.
Refs fc8942aa03
2 years ago
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 >
2 years ago
Romain Vimont
436b368f9d
Make OTG window resizable
...
PR #3219 <https://github.com/Genymobile/scrcpy/pull/3219 >
2 years ago
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 >
2 years ago
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 >
2 years ago
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>
3 years ago
Romain Vimont
8d91cda4f6
Improve HID event push error message
...
On HID event push failure, add the event type in the error message.
3 years ago
Romain Vimont
59656fe649
Fix typo in error message
3 years ago
Romain Vimont
e4bb2b8728
Add libusb error log
...
Log libusb_get_string_descriptor_ascii() errors.
Refs #3050 <https://github.com/Genymobile/scrcpy/issues/3050 >
3 years ago
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 >
3 years ago
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 >
3 years ago
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 >
3 years ago
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 >
3 years ago
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 >
3 years ago
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 >
3 years ago
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 >
3 years ago
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 >
3 years ago
Romain Vimont
4a95c08d56
Improve error message for unsupported usb hotplug
3 years ago
Romain Vimont
7848a387c8
Do not duplicate relative mouse mode state
...
The relative mouse mode is tracked by SDL, and accessible via
SDL_GetRelativeMouseMode().
This is more robust in case SDL changes the relative mouse mode on its
own.
3 years ago
Romain Vimont
43ae418752
Fix USB device leak on connection error
...
If sc_usb_connect() failed, then the sc_usb_device was never destroyed.
The assignment was mistakenly removed by commit
61969aeb80
.
3 years ago
Romain Vimont
29828aa330
Log device opening errors during listing
...
Without this log, the user would have no way to know that a USB device
is rejected because it could not be opened (typically due to
insufficient permissions).
3 years ago
Romain Vimont
4692d13179
Expose simple API to select a single adb device
...
Select an adb device from the output of `adb device -l`.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
3 years ago
Romain Vimont
700503df6c
List and select USB devices separately
...
List all USB devices in a first step, then select the matching one(s).
This allows to report a user-friendly log message containing the list of
devices, with the matching one(s) highlighted.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
3 years ago
Romain Vimont
61969aeb80
Expose simple API to select a single USB device
...
The caller just wants a single device. Handle all cases and error
messages internally.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
3 years ago
Romain Vimont
b88c4aa75e
Add move-function for sc_usb_device
...
Add a function to "move" a sc_usb_device into another instance.
This will avoid unnecessary copies.
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
3 years ago
Romain Vimont
0eadf95a3e
Rename function to destroy a list of USB devices
...
Rename from "usb_device_" to "usb_devices_".
PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005 >
3 years ago
Romain Vimont
61b6324ee9
Remove LOGC()
...
It is not clear when to use LOGC() rather than LOGE(). Always use
LOGE().
Moreover, enum sc_log_level has no "critical" log level.
3 years ago
Romain Vimont
f20137d2ac
Improve USB device open log
...
For consistency with "List USB devices", log "Open USB device".
3 years ago
Romain Vimont
b60809a4da
Inline USB device opening
...
Such a separate function was useless.
3 years ago
Romain Vimont
b0e04aa327
Remove log_libusb_error()
...
This helper did not help a lot, and prevented the client to choose the
log level and the prefix error message.
3 years ago
Romain Vimont
5508c635cb
Enable mouse focus clickthrough in OTG mode
...
A single click on the window must both give focus and capture the mouse.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
3 years ago
Romain Vimont
ea68a003a2
Make HID keyboard and mouse optional in OTG mode
...
Allow to only enable HID keyboard or HID mouse:
scrcpy --otg -K # keyboard only
scrcpy --otg -M # mouse only
scrcpy --otg -KM # keyboard and mouse
scrcpy --otg # keyboard and mouse
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
3 years ago