Skip to content

Commit

Permalink
Add gamepad user documentation
Browse files Browse the repository at this point in the history
Mainly copied and adapted from HID keyboard and mouse documentation.

PR #5270 <#5270>
  • Loading branch information
rom1v committed Sep 13, 2024
1 parent ef6f944 commit 3d6293c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 9 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Its features include:
- [camera mirroring](doc/camera.md) (Android 12+)
- [mirroring as a webcam (V4L2)](doc/v4l2.md) (Linux-only)
- physical [keyboard][hid-keyboard] and [mouse][hid-mouse] simulation (HID)
- [gamepad](doc/gamepad.md) support
- [OTG mode](doc/otg.md)
- and more…

Expand Down Expand Up @@ -111,6 +112,13 @@ Here are just some common examples.
scrcpy --otg
```

- Control the device using gamepad controllers plugged into the computer:

```bash
scrcpy --gamepad=uhid
scrcpy -G # short version
```

## User documentation

The application provides a lot of features and configuration options. They are
Expand All @@ -122,6 +130,7 @@ documented in the following pages:
- [Control](doc/control.md)
- [Keyboard](doc/keyboard.md)
- [Mouse](doc/mouse.md)
- [Gamepad](doc/gamepad.md)
- [Device](doc/device.md)
- [Window](doc/window.md)
- [Recording](doc/recording.md)
Expand Down
53 changes: 53 additions & 0 deletions doc/gamepad.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Gamepad

Several gamepad input modes are available:

- `--gamepad=disabled` (default)
- `--gamepad=uhid` (or `-G`): simulates physical HID gamepads using the UHID
kernel module on the device
- `--gamepad=aoa`: simulates physical HID gamepads using the AOAv2 protocol


## Physical gamepad simulation

Two modes allow to simulate physical HID gamepads on the device, one for each
physical gamepad plugged into the computer.


### UHID

This mode simulates physical HID gamepads using the [UHID] kernel module on the
device.

[UHID]: https://kernel.org/doc/Documentation/hid/uhid.txt

To enable UHID gamepads, use:

```bash
scrcpy --gamepad=uhid
scrcpy -G # short version
```


### AOA

This mode simulates physical HID gamepads using the [AOAv2] protocol.

[AOAv2]: https://source.android.com/devices/accessories/aoa2#hid-support

To enable AOA gamepads, use:

```bash
scrcpy --gamepad=aoa
```

Contrary to the other mode, it works at the USB level directly (so it only works
over USB).

It does not use the scrcpy server, and does not require `adb` (USB debugging).
Therefore, it is possible to control the device (but not mirror) even with USB
debugging disabled (see [OTG](otg.md)).

Note: On Windows, it may only work in [OTG mode](otg.md), not while mirroring
(it is not possible to open a USB device if it is already open by another
process like the _adb daemon_).
27 changes: 18 additions & 9 deletions doc/otg.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ device (see [keyboard](keyboard.md) and [mouse](mouse.md)).
[physical mouse]: mouse.md#physical-mouse-simulation

A special mode (OTG) allows to control the device using AOA
[keyboard](keyboard.md#aoa) and [mouse](mouse.md#aoa), without using _adb_ at
all (so USB debugging is not necessary). In this mode, video and audio are
disabled, and `--keyboard=aoa and `--mouse=aoa` are implicitly set.
[keyboard](keyboard.md#aoa), [mouse](mouse.md#aoa) and
[gamepad](gamepad.md#aoa), without using _adb_ at all (so USB debugging is not
necessary). In this mode, video and audio are disabled, and `--keyboard=aoa` and
`--mouse=aoa` are implicitly set. However, gamepads are disabled by default, so
`--gamepad=aoa` (or `-G` in OTG mode) must be explicitly set.

Therefore, it is possible to run _scrcpy_ with only physical keyboard and mouse
simulation, as if the computer keyboard and mouse were plugged directly to the
device via an OTG cable.
Therefore, it is possible to run _scrcpy_ with only physical keyboard, mouse and
gamepad simulation, as if the computer keyboard, mouse and gamepads were plugged
directly to the device via an OTG cable.

To enable OTG mode:

Expand All @@ -32,6 +34,13 @@ scrcpy --otg --keyboard=disabled
scrcpy --otg --mouse=disabled
```

and to enable gamepads:

```bash
scrcpy --otg --gamepad=aoa
scrcpy --otg -G # short version
```

It only works if the device is connected over USB.

## OTG issues on Windows
Expand All @@ -50,9 +59,9 @@ is enabled, then OTG mode is not necessary.
Instead, disable video and audio, and select UHID (or AOA):

```bash
scrcpy --no-video --no-audio --keyboard=uhid --mouse=uhid
scrcpy --no-video --no-audio -KM # short version
scrcpy --no-video --no-audio --keyboard=aoa --mouse=aoa
scrcpy --no-video --no-audio --keyboard=uhid --mouse=uhid --gamepad=uhid
scrcpy --no-video --no-audio -KMG # short version
scrcpy --no-video --no-audio --keyboard=aoa --mouse=aoa --gamepad=aoa
```

One benefit of UHID is that it also works wirelessly.

0 comments on commit 3d6293c

Please sign in to comment.