scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

UHID does not work the same as OTG

Open shiumano opened this issue 11 months ago • 5 comments

  • [x] I have read the FAQ.
  • [x] I have searched in existing issues.

Environment

  • OS: Windows, Android (Termux)
  • scrcpy version: 2.4
  • installation method: Windows Release, Termux pkg
  • device model: XQ-DQ44
  • Android version: 14

Describe the bug

If you try to enter in UHID, you will not be able to use it as a replacement for OTG.

In UHID mode, all mouse buttons except left mouse click are treated as special keys (right click is BACK, middle click is HOME).

Also, if there is no video/audio playback, the program will be forced to exit.

~ $ scrcpy --mouse=uhid --keyboard=uhid --no-video --no-audio
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
ERROR: No video, no audio, no OTG: nothing to do

shiumano avatar Mar 05 '24 07:03 shiumano

In UHID mode, all mouse buttons except left mouse click are treated as special keys (right click is BACK, middle click is HOME).

Add --forward-all-clicks.

Also, if there is no video/audio playback, the program will be forced to exit.

Yes, the reason why OTG exists is to control the device without using USB debugging (adb) and a server on the device. UHID mode requires all that, so in a sense it behaves like the "normal mode".

But it is true that a mode without mirroring could be added, since in UHID mode the mouse is relative (this is not possible with the default mouse mode, because the mouse is absolute, this would be unusable).

It would require quite a lot of changes to support a control-only mode with UHID though.

EDIT: maybe not so much, I will think about it.

rom1v avatar Mar 05 '24 07:03 rom1v

Please test #4868.

rom1v avatar Apr 20 '24 16:04 rom1v

Excellent performance! Tried it with Termux, very low CPU usage, practical enough.

However, the other issue, the mouse click specification, I still think that all clicks should be forwarded automatically in UHID mode.

shiumano avatar Apr 22 '24 15:04 shiumano

Thank you for your test :+1: :tada:

However, the other issue, the mouse click specification, I still think that all clicks should be forwarded automatically in UHID mode.

In many cases, it turns out that pressing BACK with the mouse is more useful than a real right click on an Android device.

In the very first public version of scrcpy (2018), all clicks were forwarded. A few days later, in v1.1, I added this commit: 675704c71c0d105af2242d9bbeee83127097fa0d (suggested by a user and independently by a colleague). In practice, I always use BACK with the mouse. So in my opinion, this is a good default.

I understand that there are cases where it is better not to capture right-click for a shortcut, but at least there is an option to disable it (--forward-all-clicks).

EDIT: maybe I missed the most important part: in UHID mode (and AOA)

I agree it makes sense, but then we would need a new option to disable it (it's still useful to press BACK or HOME with the mouse).

rom1v avatar Apr 22 '24 15:04 rom1v

@shiumano

I agree it makes sense, but then we would need a new option to disable it

Or we can adapt the --forward-all-clicks option: see PR #4877

rom1v avatar Apr 23 '24 07:04 rom1v