Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHID does not work the same as OTG #4727

Closed
2 tasks done
shiumano opened this issue Mar 5, 2024 · 5 comments
Closed
2 tasks done

UHID does not work the same as OTG #4727

shiumano opened this issue Mar 5, 2024 · 5 comments

Comments

@shiumano
Copy link

shiumano commented Mar 5, 2024

  • I have read the FAQ.
  • 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
@rom1v
Copy link
Collaborator

rom1v commented Mar 5, 2024

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 rom1v mentioned this issue Mar 28, 2024
1 task
rom1v added a commit that referenced this issue Apr 20, 2024
Add the possibility to only control the device with any keyboard and
mouse mode without screen mirroring.

This is different from OTG mode, which does not require USB debugging at
all. It is just the standard mode but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <#4727>
Fixes #4793 <#4793>
rom1v added a commit that referenced this issue Apr 20, 2024
Add the possibility to only control the device with any keyboard and
mouse mode without screen mirroring.

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <#4727>
Fixes #4793 <#4793>
rom1v added a commit that referenced this issue Apr 20, 2024
Add the possibility to only control the device with any keyboard and
mouse mode without screen mirroring.

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <#4727>
Fixes #4793 <#4793>
@rom1v
Copy link
Collaborator

rom1v commented Apr 20, 2024

Please test #4868.

@shiumano
Copy link
Author

shiumano commented Apr 22, 2024

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.

@rom1v
Copy link
Collaborator

rom1v commented Apr 22, 2024

Thank you for your test 👍 🎉

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: 675704c (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 added a commit that referenced this issue Apr 23, 2024
Add the possibility to only control the device with any keyboard and
mouse mode without screen mirroring.

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <#4727>
Fixes #4793 <#4793>
PR #4868 <#4868>
rom1v added a commit that referenced this issue Apr 23, 2024
In relative mouse modes (when the cursor appears on the device), it
makes more sense to forward all clicks (disable HOME/BACK shortcuts on
secondary clicks).

Transform the boolean option --forward-all-clicks into a 3-state option:
 - --forward-all-clicks=true or --forward-all-clicks: enable
 - --forward-all-clicks=false: disable
 - --forward-all-clicks=auto (default): enable only for AOA and UHID

That way, by default, all clicks are forwarded with `scrcpy -M`.

Refs <#4727 (comment)>
rom1v added a commit that referenced this issue Apr 23, 2024
In relative mouse modes (when the cursor appears on the device), it
makes more sense to forward all clicks (disable HOME/BACK shortcuts on
secondary clicks).

Transform the boolean option --forward-all-clicks into a 3-state option:
 - --forward-all-clicks=true or --forward-all-clicks: enable
 - --forward-all-clicks=false: disable
 - --forward-all-clicks=auto (default): enable only for UHID and AOA

That way, by default, all clicks are forwarded with `scrcpy -M`.

Refs <#4727 (comment)>
@rom1v
Copy link
Collaborator

rom1v commented Apr 23, 2024

@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 added a commit that referenced this issue Apr 28, 2024
Add the possibility to only control the device with any keyboard and
mouse mode without screen mirroring:

    scrcpy -KM --no-video --no-audio

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <#4727>
Fixes #4793 <#4793>
PR #4868 <#4868>
rom1v added a commit that referenced this issue May 11, 2024
Add the possibility to solely control the device with any keyboard and
mouse mode without screen mirroring:

    scrcpy -KM --no-video --no-audio

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <#4727>
Fixes #4793 <#4793>
PR #4868 <#4868>
rom1v added a commit that referenced this issue Jun 23, 2024
In relative mouse modes (when the cursor appears on the device), it
makes more sense to forward all clicks (disable HOME/BACK shortcuts on
secondary clicks).

Transform the boolean option --forward-all-clicks into a 3-state option:
 - --forward-all-clicks=true or --forward-all-clicks: enable
 - --forward-all-clicks=false: disable
 - --forward-all-clicks=auto (default): enable only for UHID and AOA

That way, by default, all clicks are forwarded with `scrcpy -M`.

Refs <#4727 (comment)>
PR #4877 <#4877>
rom1v added a commit that referenced this issue Jun 24, 2024
By default, only the left click is forwarded to the device, and
secondary clicks trigger shortcuts (the behavior can be configured by
--mouse-bind=xxxx).

But when the mouse mode is relative (AOA and UHID modes), forward all
clicks by default. This makes more sense since the cursor is handled on
the device side, the user expects all mouse buttons to be forwarded.

Refs #4727 <#4727 (comment)>
rom1v added a commit that referenced this issue Jun 24, 2024
By default, only the left click is forwarded to the device, and
secondary clicks trigger shortcuts (the behavior can be configured by
--mouse-bind=xxxx).

But when the mouse mode is relative (AOA and UHID modes), forward all
clicks by default. This makes more sense since the cursor is handled on
the device side, the user expects all mouse buttons to be forwarded.

Refs <#4727 (comment)>
PR #5022 <#5022>
@rom1v rom1v closed this as completed in 45fe6b6 Jun 29, 2024
nanz79 pushed a commit to nanz79/scrcpy that referenced this issue Jul 20, 2024
Add the possibility to only control the device with any keyboard and
mouse mode without screen mirroring:

    scrcpy -KM --no-video --no-audio

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes #4727 <Genymobile/scrcpy#4727>
Fixes #4793 <Genymobile/scrcpy#4793>
PR #4868 <Genymobile/scrcpy#4868>
FreedomBen pushed a commit to FreedomBen/scrcpy that referenced this issue Aug 2, 2024
Add the possibility to solely control the device without screen
mirroring:

    scrcpy --no-video --no-audio

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes Genymobile#4727 <Genymobile#4727>
Fixes Genymobile#4793 <Genymobile#4793>
PR Genymobile#4868 <Genymobile#4868>
FreedomBen pushed a commit to FreedomBen/scrcpy that referenced this issue Aug 2, 2024
By default, only the left click is forwarded to the device, and
secondary clicks trigger shortcuts (the behavior can be configured by
--mouse-bind=xxxx).

But when the mouse mode is relative (AOA and UHID modes), forward all
clicks by default. This makes more sense since the cursor is handled on
the device side, the user expects all mouse buttons to be forwarded.

Refs <Genymobile#4727 (comment)>
PR Genymobile#5022 <Genymobile#5022>
Gottox pushed a commit to Gottox/scrcpy that referenced this issue Sep 29, 2024
Add the possibility to solely control the device without screen
mirroring:

    scrcpy --no-video --no-audio

This is different from OTG mode, which does not require USB debugging at
all. Here, the standard mode is used but with the possibility to disable
video playback.

By default, always open a window (even without video playback), and add
an option --no-window.

Fixes Genymobile#4727 <Genymobile#4727>
Fixes Genymobile#4793 <Genymobile#4793>
PR Genymobile#4868 <Genymobile#4868>
Gottox pushed a commit to Gottox/scrcpy that referenced this issue Sep 29, 2024
By default, only the left click is forwarded to the device, and
secondary clicks trigger shortcuts (the behavior can be configured by
--mouse-bind=xxxx).

But when the mouse mode is relative (AOA and UHID modes), forward all
clicks by default. This makes more sense since the cursor is handled on
the device side, the user expects all mouse buttons to be forwarded.

Refs <Genymobile#4727 (comment)>
PR Genymobile#5022 <Genymobile#5022>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants