Skip to content

Commit

Permalink
Document UHID
Browse files Browse the repository at this point in the history
Rework the documentation to present the keyboard and mouse input modes.

PR #4473 <#4473>
  • Loading branch information
rom1v committed Feb 29, 2024
1 parent dd479ed commit b9d244b
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 169 deletions.
9 changes: 5 additions & 4 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ Try with another USB cable or plug it into another USB port. See [#281] and
[#283]: https://github.com/Genymobile/scrcpy/issues/283


## HID/OTG issues on Windows
## OTG issues on Windows

On Windows, if `scrcpy --otg` (or `--hid-keyboard`/`--hid-mouse`) results in:
On Windows, if `scrcpy --otg` (or `--keyboard=aoa`/`--mouse=aoa`) results in:

> ERROR: Could not find any USB device
Expand Down Expand Up @@ -170,12 +170,13 @@ The default text injection method is [limited to ASCII characters][text-input].
A trick allows to also inject some [accented characters][accented-characters],
but that's all. See [#37].

It is also possible to simulate a [physical keyboard][hid] (HID).
To avoid the problem, [change the keyboard mode to simulate a physical
keyboard][hid].

[text-input]: https://github.com/Genymobile/scrcpy/issues?q=is%3Aopen+is%3Aissue+label%3Aunicode
[accented-characters]: https://blog.rom1v.com/2018/03/introducing-scrcpy/#handle-accented-characters
[#37]: https://github.com/Genymobile/scrcpy/issues/37
[hid]: doc/hid-otg.md
[hid]: doc/keyboard.md#physical-keyboard-simulation


## Client issues
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ Its features include:
- [configurable quality](doc/video.md)
- [camera mirroring](doc/camera.md) (Android 12+)
- [mirroring as a webcam (V4L2)](doc/v4l2.md) (Linux-only)
- [physical keyboard/mouse simulation (HID)](doc/hid-otg.md)
- [OTG mode](doc/hid-otg.md#otg)
- physical [keyboard][hid-keyboard] and [mouse][hid-mouse] simulation (HID)
- [OTG mode](doc/otg.md)
- and more…

[hid-keyboard]: doc/keyboard.md#physical-keyboard-simulation
[hid-mouse]: doc/mouse.md#physical-mouse-simulation

## Prerequisites

The Android device requires at least API 21 (Android 5.0).
Expand All @@ -53,8 +56,7 @@ this option is set.

[control]: https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323

Note that USB debugging is not required to run scrcpy in [OTG
mode](doc/hid-otg.md#otg).
Note that USB debugging is not required to run scrcpy in [OTG mode](doc/otg.md).


## Get the app
Expand All @@ -73,11 +75,13 @@ documented in the following pages:
- [Video](doc/video.md)
- [Audio](doc/audio.md)
- [Control](doc/control.md)
- [Keyboard](doc/keyboard.md)
- [Mouse](doc/mouse.md)
- [Device](doc/device.md)
- [Window](doc/window.md)
- [Recording](doc/recording.md)
- [Tunnels](doc/tunnels.md)
- [HID/OTG](doc/hid-otg.md)
- [OTG](doc/otg.md)
- [Camera](doc/camera.md)
- [Video4Linux](doc/v4l2.md)
- [Shortcuts](doc/shortcuts.md)
Expand Down
51 changes: 4 additions & 47 deletions doc/control.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,9 @@ scrcpy --no-control
scrcpy -n # short version
```

## Keyboard and mouse

## Text injection preference

Two kinds of [events][textevents] are generated when typing text:
- _key events_, signaling that a key is pressed or released;
- _text events_, signaling that a text has been entered.

By default, letters are injected using key events, so that the keyboard behaves
as expected in games (typically for WASD keys).

But this may [cause issues][prefertext]. If you encounter such a problem, you
can avoid it by:

```bash
scrcpy --prefer-text
```

(but this will break keyboard behavior in games)

On the contrary, you could force to always inject raw key events:

```bash
scrcpy --raw-key-events
```

These options have no effect on HID keyboard (all key events are sent as
scancodes in this mode).

[textevents]: https://blog.rom1v.com/2018/03/introducing-scrcpy/#handle-text-input
[prefertext]: https://github.com/Genymobile/scrcpy/issues/650#issuecomment-512945343
Read [keyboard](keyboard.md) and [mouse](mouse.md).


## Copy-paste
Expand Down Expand Up @@ -85,6 +58,7 @@ way as <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>).
To disable automatic clipboard synchronization, use
`--no-clipboard-autosync`.


## Pinch-to-zoom, rotate and tilt simulation

To simulate "pinch-to-zoom": <kbd>Ctrl</kbd>+_click-and-move_.
Expand All @@ -100,20 +74,7 @@ at a location inverted through the center of the screen. When pressing
<kbd>Ctrl</kbd> the x and y coordinates are inverted. Using <kbd>Shift</kbd>
only inverts x.


## Key repeat

By default, holding a key down generates repeated key events. This can cause
performance problems in some games, where these events are useless anyway.

To avoid forwarding repeated key events:

```bash
scrcpy --no-key-repeat
```

This option has no effect on HID keyboard (key repeat is handled by Android
directly in this mode).
This only works for the default mouse mode (`--mouse=sdk`).


## Right-click and middle-click
Expand Down Expand Up @@ -147,7 +108,3 @@ The target directory can be changed on start:
```bash
scrcpy --push-target=/sdcard/Movies/
```

## Physical keyboard and mouse simulation

See the dedicated [HID/OTG](hid-otg.md) page.
2 changes: 1 addition & 1 deletion doc/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ The video and audio streams are decoded by [FFmpeg].
The client parses the command line arguments, then [runs one of two code
paths][run]:
- scrcpy in "normal" mode ([`scrcpy.c`])
- scrcpy in [OTG mode](hid-otg.md) ([`scrcpy_otg.c`])
- scrcpy in [OTG mode](otg.md) ([`scrcpy_otg.c`])

[run]: https://github.com/Genymobile/scrcpy/blob/a3cdf1a6b86ea22786e1f7d09b9c202feabc6949/app/src/main.c#L81-L82
[`scrcpy.c`]: https://github.com/Genymobile/scrcpy/blob/a3cdf1a6b86ea22786e1f7d09b9c202feabc6949/app/src/scrcpy.c#L292-L293
Expand Down
112 changes: 0 additions & 112 deletions doc/hid-otg.md

This file was deleted.

Loading

0 comments on commit b9d244b

Please sign in to comment.