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

OTG on Windows 10/11 (libusb error: Operation not supported or unimplemented on this platform) #3654

Open
2 tasks done
geekaz01d opened this issue Jan 2, 2023 · 25 comments
Open
2 tasks done

Comments

@geekaz01d
Copy link

geekaz01d commented Jan 2, 2023

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Windows 10 Pro & Windows 11 Pro
  • scrcpy version:
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
    - SDL: 2.0.22 / 2.0.22
    - libavcodec: 59.18.100 / 59.18.100
    - libavformat: 59.16.100 / 59.16.100
    - libavutil: 57.17.100 / 57.17.100
    - libusb: - / 1.0.26
  • installation method: choco install scrcpy
  • device model: Samsung Galaxy Tab S7+ (SM-T970)
  • Android version: 13
  • More details:
    - USB cable from PC to Tablet
    - problem recreated with two systems (Win10 vs Win11) and two tablets (both same model/release) with and without adb installed

Describe the bug
While screen remoting works great (impressively clean implementation!), I am unable to get --otg mode to work. It appears like an incompatibility or limitation in Windows? There are a number of issues that smell similar but have cryptic titles and slightly different output, so I've made this as a new issue.

My aim is to get a clear answer as to whether otg support for windows is confirmed a no-go or not.

PS ~> scrcpy --otg
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
INFO: Killing adb daemon (if any)...
INFO: USB device: 0D6F385C3731 (046d:c08b) Logitech G502 HERO SE
WARN: On this platform, libusb does not have hotplug capability; device disconnection will not be detected properly
ERROR: REGISTER_HID: libusb error: Entity not found
WARN: Register HID keyboard failed

PS (admin) ~>  scrcpy --otg -M
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
INFO: Killing adb daemon (if any)...
INFO: USB device: 0D6F385C3731 (046d:c08b) Logitech G502 HERO SE
WARN: On this platform, libusb does not have hotplug capability; device disconnection will not be detected properly
ERROR: REGISTER_HID: libusb error: Entity not found
WARN: Register HID mouse failed

PS (admin) ~>  scrcpy --otg -Vdebug
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
INFO: Killing adb daemon (if any)...
DEBUG: Open USB device 04e8:6860: libusb error: Operation not supported or unimplemented on this platform
DEBUG: USB device found:
DEBUG:     -->       0D6F385C3731 (046d:c08b)  Logitech G502 HERO SE
INFO: USB device: 0D6F385C3731 (046d:c08b) Logitech G502 HERO SE
WARN: On this platform, libusb does not have hotplug capability; device disconnection will not be detected properly
ERROR: REGISTER_HID: libusb error: Entity not found
WARN: Register HID keyboard failed

PS (admin) ~>  scrcpy --otg -s 0D6F385C3731 -Vdebug
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
INFO: Killing adb daemon (if any)...
DEBUG: Open USB device 04e8:6860: libusb error: Operation not supported or unimplemented on this platform
DEBUG: USB device found:
DEBUG:     -->       0D6F385C3731 (046d:c08b)  Logitech G502 HERO SE
INFO: USB device: 0D6F385C3731 (046d:c08b) Logitech G502 HERO SE
WARN: On this platform, libusb does not have hotplug capability; device disconnection will not be detected properly
ERROR: REGISTER_HID: libusb error: Entity not found
WARN: Register HID keyboard failed
@rom1v
Copy link
Collaborator

rom1v commented Jan 2, 2023

It seems it does not detect your device over USB (but it happens to detect a mouse, so of course it does not work).

My aim is to get a clear answer as to whether otg support for windows is confirmed a no-go or not.

On Windows, it works, except when it does not. 😉

Try without USB debugging enabled (#3050), or try on Linux.

@geekaz01d
Copy link
Author

Let's begin with USB debugging off, default mode:

PS ~ > scrcpy -Vdebug
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
* daemon not running; starting now at tcp:5037
* daemon started successfully
ERROR: Could not find any ADB device
ERROR: Server connection failed

Well that's no good. Let's enable USB debugging.

PS ~ > scrcpy -Vdebug
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
DEBUG: ADB device found:
DEBUG:     -->   (usb)           R52RA02S2VT            device  SM_T970
DEBUG: Device serial: R52RA02S2VT
DEBUG: Using server (portable): C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-server
C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-server: 1 file pushed, 0 skipped. 29.7 MB/s (41159 bytes in 0.001s)
[server] INFO: Device: samsung SM-T970 (Android 13)
[server] DEBUG: Using encoder: 'OMX.qcom.video.encoder.avc'
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Renderer: direct3d
DEBUG: Trilinear filtering disabled (not an OpenGL renderer)
DEBUG: Using icon (portable): C:\ProgramData\chocolatey\lib\scrcpy\tools\icon.png
INFO: Initial texture: 2800x1752
DEBUG: Starting demuxer thread
DEBUG: User requested to quit
DEBUG: quit...
DEBUG: End of frames
DEBUG: Receiver stopped
[server] DEBUG: Controller stopped
WARN: Killing the server...
DEBUG: Server disconnected
DEBUG: Server terminated

Cool. But not the problem.

Let's try again, to remember where we began:

PS ~ > scrcpy --otg -Vdebug
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
INFO: Killing adb daemon (if any)...
DEBUG: Open USB device 04e8:6860: libusb error: Operation not supported or unimplemented on this platform
DEBUG: USB device found:
DEBUG:     -->       0D6F385C3731 (046d:c08b)  Logitech G502 HERO SE
INFO: USB device: 0D6F385C3731 (046d:c08b) Logitech G502 HERO SE
WARN: On this platform, libusb does not have hotplug capability; device disconnection will not be detected properly
ERROR: REGISTER_HID: libusb error: Entity not found
WARN: Register HID keyboard failed

Right.

disables USB debugging again

PS ~ > scrcpy --otg -Vdebug
scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
INFO: Killing adb daemon (if any)...
DEBUG: Open USB device 04e8:6860: libusb error: Operation not supported or unimplemented on this platform
DEBUG: USB device found:
DEBUG:     -->       0D6F385C3731 (046d:c08b)  Logitech G502 HERO SE
INFO: USB device: 0D6F385C3731 (046d:c08b) Logitech G502 HERO SE
WARN: On this platform, libusb does not have hotplug capability; device disconnection will not be detected properly
ERROR: REGISTER_HID: libusb error: Entity not found
WARN: Register HID keyboard failed

The exact same behavior? So the problem is still with scrcpy.

What benefit would trying on linux offer?

@micku7zu
Copy link

micku7zu commented Jan 3, 2023

I just tried this on my Windows 11 and Galaxy S22 Ultra. It didn't worked at first, but reading the other issues I saw users complaining about different ADB/Device drivers for their devices.

With the official Samsung Android USB drivers installed it didn't work. I uninstalled this package from Control panel, then I uninstalled the drivers from Windows Device Manager.

After uninstalling all drivers, it works:
2023-01-03_01-46-23

Windows 11 + S22 Ultra Android 13 + without official Samsung Android drivers - it works excellent.

With the official Samsung drivers I get the following error:
image

@geekaz01d I recommend you to try different ADB drivers for your device and see if it works. Some documentation about USB drivers from Google: https://developer.android.com/studio/run/oem-usb#Drivers. Maybe you find something there

Offtopic: @rom1v I appreciate all your work, excellent application and blog posts about the app development. I learned a lot from you! Thank you a lot for your hard work!

@micku7zu
Copy link

micku7zu commented Jan 3, 2023

Ok, I've played a little bit more with the drivers, and at least for me, with the Google USB Driver everything works (ADB, scrcpy, scrcpy --otg), but you need to do some extra steps to install them.

  1. Uninstall all Android USB drivers from Windows Control panel.
  2. Open Device Manager and uninstall all drivers for your Android device
  3. Download and unzip the Google USB Driver ZIP file from here: https://developer.android.com/studio/run/win-usb
  4. Open Device manager -> Right click your device -> Update driver -> Browse for drivers on your computer -> Browse the unzipped folder -> Let me pick from a list of available drivers -> Show all devices -> Have disk -> Browse for android_winusb.inf from unzipped folder -> Choose Android ADB Interface
scrcpy_google_adb_driver.mp4

@geekaz01d
Copy link
Author

Try without USB debugging enabled (#3050), or try on Linux.

I installed Ubuntu 22.04 on my laptop and tested scrcpy...

ubuntu_laptop:~$ scrcpy --otg
scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
scrcpy: unrecognized option '--otg'

ubuntu_laptop:~$ scrcpy --version
scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
scrcpy 1.21

dependencies:
 - SDL 2.0.16
 - libavcodec 58.134.100
 - libavformat 58.76.100
 - libavutil 56.70.100
 - libavdevice 58.13.100
ubuntu_laptop:~$ scrcpy --Vdebug
scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
scrcpy: unrecognized option '--Vdebug'

ubuntu_laptop:~$ scrcpy -Vdebug
scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
DEBUG: Device serial: R52RA02S2VT
DEBUG: Using server: /usr/share/scrcpy/scrcpy-server
/usr/share/scrcpy/scrcpy-server: 1 file pushed. 1.6 MB/s (39473 bytes in 0.023s)
DEBUG: Screensaver enabled
[server] INFO: Device: samsung SM-T970 (Android 13)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 22.0.5
INFO: Trilinear filtering enabled
DEBUG: Using icon: /usr/share/icons/hicolor/256x256/apps/scrcpy.png
INFO: Initial texture: 2800x1752
DEBUG: Starting stream thread
[server] DEBUG: Using encoder: 'OMX.qcom.video.encoder.avc'
DEBUG: User requested to quit
DEBUG: quit...
WARN: Killing the server...
DEBUG: Server disconnected
DEBUG: Server terminated
DEBUG: End of frames
DEBUG: Receiver stopped

@rom1v
Copy link
Collaborator

rom1v commented Jan 3, 2023

Thank you for the details 👍

I installed Ubuntu 22.04 on my laptop and tested scrcpy...

In Ubuntu 22.04, the packaged scrcpy version (1.21) is too old (it's 1.24 in Ubuntu 22.10). Uninstall the package and install the latest version manually: https://github.com/Genymobile/scrcpy/blob/master/BUILD.md#simple

@geekaz01d
Copy link
Author

geekaz01d commented Jan 3, 2023

Ok, I've played a little bit more with the drivers, and at least for me, with the Google USB Driver everything works (ADB, scrcpy, scrcpy --otg), but you need to do some extra steps to install them.

This is definitely the key to the issue. USB Debugging has to be on, because it is using the adb device to connect. Once I found that device and forced it to use the downloaded google version, I was able to get it to work. A window pops up with an android icon and I have mouse control of the tablet.

Importantly, the devices in my devmgr are totally different than your screencap. I had to unhide stuff and go deep.

So the challenge for scrcpy on windows is to either implement the known good driver or test around the more commonly installed one. This brute force method you found is a fairly heavy handed workaround.

Great work!

@rom1v
Copy link
Collaborator

rom1v commented Jan 3, 2023

USB Debugging has to be on, because it is using the adb device to connect.

(not in OTG mode)

(or maybe you're saying that this is necessary for the driver to work?)

rom1v added a commit that referenced this issue Jan 3, 2023
rom1v added a commit that referenced this issue Jan 3, 2023
@rom1v
Copy link
Collaborator

rom1v commented Jan 3, 2023

I just added a FAQ entry: https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#hidotg-issues-on-windows

@kliffi01
Copy link

Hey guys,
i'm using a workbased laptop (HP EliteBook Win10) and a workbased tablet (Panasonic FZ-A3) and i would love to use the keyboard / mouse HID configuration, since i can't root my tablet or make USB Debugging work.

Here's what i get:
image

What do i choose in the tablet for the USB: File Transfer / PTP / Nothing ? Thanks.

@Ext-00 Ext-00 mentioned this issue May 26, 2023
@mdell-seradex
Copy link

If scrcpy can't be made to work with those samsung drivers, it would be nice if it could detect them to identify the issue.
Thanks

@Missingpng
Copy link

Okay, I am having the same issue as the original poster, but downloading the Google Driver did nothing. I just want to get a HID mouse to work.

I am currently using scrcpy v2.1.1, I am on Windows 10 and I am connecting to a Samsung 23
Untitled(1)

@yume-chan
Copy link
Contributor

With the official Samsung Android USB drivers installed it didn't work.

This is true. Because Windows USB API is bad, programs have to use an allowlist to determine which device is accessible. Usually, they only include the Windows built-in composite device driver (usbccgp), so they ignore devices with Samsung's custom driver.

I had previously filed a bug for Chrome at https://crbug.com/1127206, and I have created a PR for libusb (libusb/libusb#1331) to fix that.

@rom1v
Copy link
Collaborator

rom1v commented Mar 2, 2024

Could you please retry with scrcpy v2.4? Refs #4713 (comment)

@colo-natanael
Copy link

Hi! Good evening, I am addressing this post because I have been reading and reading posts related to this topic about this problem for approximately 4 hours. I am going to clarify that this took a lot of time for me because I don't know English, I only speak Spanish and therefore I use Google Translate to better understand everything they say. Having said that, I want to say that my problem is the following, when I want to use the OTG mode, when typing that command in the CMD it gives me the same error as several of those who commented and I tried many things and I still can't solve it, I want to use the OTG mode on my Xiaomi redmi note 11 cell phone and I can't do it yet, I have only been able to use the normal mode.
I'll probably have to make a separate post because I don't know if this comment will have enough attention to my problem because it's been more than 3 weeks, but I'm going to try. From already thank you very much!.

@rom1v
imagen_2024-03-21_213944590

@rom1v
Copy link
Collaborator

rom1v commented Mar 22, 2024

It detected your logitech gaming mouse as USB device.

Pass the serial of your Xiaomi phone:

scrcpy --otg -s 371b85e0

@mdell-seradex
Copy link

It'd be nice if it could detect these HID type of devices and ignore them, or have a config file where it could be manually listed to eliminate requiring a special command line each time.
That said, I do use a batch file for this to automate connecting my device via IP debugging. I kind of wish it'd be incorporated. I might just create something for this myself one day... 🙂

@rom1v
Copy link
Collaborator

rom1v commented Mar 22, 2024

It'd be nice if it could detect these HID type of devices and ignore them

Yes, it should only list adb devices. It's not that straightforward to detect unambiguously IIRC). PR welcome.

There is an environment variable ANDROID_SERIAL which can replace the -s. Unfortunately, it's not used for OTG mode (PR welcome too 😉).

@cachius
Copy link

cachius commented Oct 30, 2024

For reference, since this is linked from the FAQ: The Tracking Bug is #3050.
Maybe that one should (also) be linked in the FAQ?

@jgodwinWX
Copy link

I followed all the steps above for a Google Pixel 6a and it didn't work. I installed the Google Driver as shown above. I also tried this on Ubuntu and while it ran, I just got a blank black box. Here's the Windows output:

image

@rom1v
Copy link
Collaborator

rom1v commented Nov 5, 2024

I also tried this on Ubuntu and while it ran, I just got a blank black box
What do you mean "a blank black box"?

@Abdollah0011
Copy link

hello friends I downloaded and ran the scrcpy software in Windows 7, but the program gives an error. (I have also turned on debugging on the mobile phone).
rth

@rom1v
Copy link
Collaborator

rom1v commented Nov 9, 2024

@Abdollah0011 #4391

@Abdollah0011
Copy link

Hello, I want to have the image of the phone screen and control the phone with the otg function with the mouse and keyboard, is this possible?

@rom1v
Copy link
Collaborator

rom1v commented Nov 10, 2024

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