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

Regarding the necessity of killing the adb service in the otg mode on Windows platform #4028

Open
HWZen opened this issue May 23, 2023 · 14 comments

Comments

@HWZen
Copy link

HWZen commented May 23, 2023

  • [ yes ] I have checked that a similar feature request does not already exist.

Regarding the necessity of killing the adb service in the otg mode on Windows platform
We can not use HID and mirror mode on Windows platform beacuse Windows not possible to open a USB device by more than one process, and mirror mode will invoke adb server to connect device. Adb will open our Android USB device.

But really ?

In fact, I managed to use the HID at the same time with the mirroring screen turned on successfully, on Windows platform, used scrcpy.

The key to the way is to use the remote debugging feature of adb, so that adb does not need to use USB to connect the device

First, we open a scrcpy

script.exe --otg -K

I will kill adb server and conncet to device, simulate HID input.

Then, we open another scrcpy, use TCP/IP to connect the device

script.exe --tcpip=192.168.12.34:5678

If all goes well, you can now have HID input while mirroring is enabled

20230523202813

My soluction: try connect to device by usb first?
My mind is, on OTG mode, try to make a connection to the device first instead of killing adb first, If the connection fails, it is not too late to try to kill adb.

On mirror mode, if user use tcpip to connect to device, maybe we can allow simultaneous HID input from the user.

I am proud to contribute code
If you think what I'm saying makes sense, I'd be happy to contribute code to complete this functionality. <( ̄︶ ̄)↗[GO!]

@WuDi-ZhanShen
Copy link

I think there is a better way to solve this problem, see #4034

@HWZen
Copy link
Author

HWZen commented May 25, 2023

I think there is a better way to solve this problem, see #4034

eh~This does seem like a more elegant solution. But are you sure this can be done via ADB without installing any app on the device? Sorry I don't know much about how to call Linux Api on Android devices

@WuDi-ZhanShen
Copy link

我有个安卓项目,测试了确实可以这么做的

@WuDi-ZhanShen
Copy link

I think there is a better way to solve this problem, see #4034

eh~This does seem like a more elegant solution. But are you sure this can be done via ADB without installing any app on the device? Sorry I don't know much about how to call Linux Api on Android devices

是的,亲测是没问题的,我写了个虚拟HID手柄的程序,用adb就可以成功创建HID手柄

@rom1v
Copy link
Collaborator

rom1v commented May 25, 2023

Hi,

Please keep talking in English ;)

My mind is, on OTG mode, try to make a connection to the device first instead of killing adb first, If the connection fails, it is not too late to try to kill adb.

Maybe adding an option (--no-kill-adb-before-hid, specific to Windows), as suggested in #4032, would be simpler. What do you think?

This can be done regardless of what is done about #4034.

@HWZen
Copy link
Author

HWZen commented May 25, 2023

Hi,

Please keep talking in English ;)

My mind is, on OTG mode, try to make a connection to the device first instead of killing adb first, If the connection fails, it is not too late to try to kill adb.

Maybe adding an option (--no-kill-adb-before-hid, specific to Windows), as suggested in #4032, would be simpler. What do you think?

This can be done regardless of what is done about #4034.

Adding an option is certainly simpler, but the method mentioned by #4034 can use USB connection to mirroring device and use HID emulation at the same time, without requiring adb use tcp connection. Both functions are done through adb.

I think #4034 method is better when we are capable enough.

Maybe we can do #4032 first, and then consider whether #4034 is easy to complete.

What do you think?

And I am happey to contribute code for #4032.
But about #4034, @WuDi-ZhanShen , would you like to contribute code?

@WuDi-ZhanShen
Copy link

I have already done the native code and it can be ported and built at any time. I will upload it within a few minutes.

@HWZen
Copy link
Author

HWZen commented May 25, 2023

Sorry, I didn't notice @wh201906 already made a pr for #4032
#4035
Maybe I will try to do #4034

@HWZen
Copy link
Author

HWZen commented May 25, 2023

I have already done the native code and it can be ported and built at any time. I will upload it within a few minutes.

Ok, little embarrassed. Looking forward to your submission,I will study it.

@WuDi-ZhanShen
Copy link

I have already done the native code and it can be ported and built at any time. I will upload it within a few minutes.

Ok, little embarrassed. Looking forward to your submission,I will study it.

https://github.com/WuDi-ZhanShen/uhid-demo

rom1v pushed a commit that referenced this issue Jun 1, 2023
Add an option not to kill the adb daemon on Windows if --otg is
specified.

Refs #4028 <#4028>
PR #4035 <#4035>

Signed-off-by: Romain Vimont <[email protected]>
@shirooo39
Copy link

shirooo39 commented Feb 10, 2024

so is it now possible to use OTG HID and mirror on Windows at the same time?

@WuDi-ZhanShen
Copy link

so is it now possible to use OTG HID and mirror on Windows at the same time?

Yes it is possible

@rom1v
Copy link
Collaborator

rom1v commented Feb 28, 2024

Also see #4473.

@shirooo39
Copy link

shirooo39 commented Mar 24, 2024

Also see #4473.

When --otg is not specified, all values are accepted, except aoa doesn't work on Windows

aaaww, that's sad news for me.
I'd love to be able to use the AOAv2 because this specific app I want to use (which is a keyboard and mouse mapper for games), seems to only work when I use AOAv2. and the way to use AOAv2 on Windows, is only through the --otg mode.

I tried using the UHID and SDK, it just doesn't work. the app won't capture the mouse and keyboard. but for normal mirroring, UHID and SDK does work normally.

will it be possible if I fire up a Ubuntu VM and use scrcpy inside it? I mean, will I be able to mirror and use OAOv2 mouse and keyboard?

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

4 participants