Closed Windows81 closed 2 months ago
when I first wrote the code, I tried looking for cases of devices with gadget names besides g1
and couldn't find any, so I hardcoded it. I guess now it's time to write some logic for that.
would appreciate the PR but I could also handle it pretty easily, just been busy lately with stuff in real life and a decent amount of things changes I wanna complete for this project, so it might take a bit until I can make a release.
edit: the technical reason for the issue is that after v1.0.0 I decided to add HID functions to the default Android USB gadget to avoid making users choose between it and HID functions. the reason for the other app working is that it seems to require USB Gadget Tool to create the character devices, which would work fine since it searches and presents all available gadgets on the device to the user, while mine has to handle it automatically.
No problem!
If I were you, I would have the user select which gadget to use upon initial setup.
I'm not yet familiar with the underlying routines behind USB Gadget Tool, but I'd reckon it's easy to look into.
On my device, /dev/hidg0
and /dev/hidg1
are only usable when I use them on g2
.
I'd rather have it be entirely transparent to the user, but yea if the detection logic is too complex I'll just present a dropdown of all discovered gadgets or something.
It might take me a little while to get the fix into the next release, but as long as you're okay with dealing with a debug APK, then this apk should fix it.
Since it's a debug APK (meaning it's not signed with my main signing key) you'll have to uninstall the version of the app you already have installed. You'll also have to uninstall and re-install later on when this gets officially released.
If using a debug APK until I can get the next release ready bothers you, I can build a proper signed version and upload it here.
closing this issue, but if the fix doesn't work for you, then we can definitely reopen this.
Will do. I appreciate the help!
El dom, 7 abr 2024 a las 9:36, Arian Baishya @.***>) escribió:
It might take me a little while to get the fix into the next release, but as long as you're okay with dealing with a debug APK, then this apk https://github.com/Arian04/android-hid-client/actions/runs/8587737192/artifacts/1391780146 should fix it.
Since it's a debug APK (meaning it's not signed with my main signing key) you'll have to uninstall the version of the app you already have installed. You'll also have to uninstall and re-install later on when this gets officially released.
If using a debug APK until I can get the next release ready bothers you, I can build a proper signed version and upload it here.
closing this issue, but if the fix doesn't work for you, then we can definitely reopen this.
— Reply to this email directly, view it on GitHub https://github.com/Arian04/android-hid-client/issues/29#issuecomment-2041388158, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLI4A3UIEDOZPAUB766XPDY4EHQRAVCNFSM6AAAAABF24Y6U2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGM4DQMJVHA . You are receiving this because you authored the thread.Message ID: @.***>
Touchpad: works. Manual input: works. Direct input: works (though not the backspace or modifier keys; I'll use other apps for that).
I tried the last two mostly on the app using its respective functions.
https://github.com/Arian04/android-hid-client/files/14896693/apk.zip
I'll leave the .apk
file as an attachment for posterity.
backspace and modifier keys not working is strange. Did you add HID functions using USB gadget tool? because my app uses a different report descriptor to enable extra features like multimedia keys, so weird things like that will happen if the functions are added using a different app.
My bad. I use Swiftkey, so the backspace input might be different. I didn't find the modifier keys myself, but there's a chace that I didn't look well enough.
not sure if you meant you couldn't find it in the app or in Swiftkey, but the app doesn't provide modifier key buttons, it just uses your normal keyboard. that's why I recommend Hackers Keyboard to give users access to way more keys.
and I'll see if I can start testing out a variety of keyboards automatically in my instrumented tests. Thanks!
Actually, for each character I type with direct input, I need to type that many backspaces before it begins to work.
For example, when I type 'AB' in direct input, I tap backspace three times and then the string becomes 'A'. When I type 'abcd', I must hit the backspace key five times before it becomes 'abc', then one time after that before it becomes 'ab'.
This buffering behaviour doesn't apply when the characters I've typed are not from direct input.
It also doesn't apply when I type numbers.
Likely a Swiftkey bug. Other than that, the app works perfectly.
that's incredibly strange. I should definitely test on a wider variety of keyboards. I just haven't because I only recently began setting up automated testing.
thanks for the info!!
No problem. I really think that hid.keyboard
and hid.mouse
should be added to .../g2/
. Otherwise, some other USB functions on .../g1/
won't work at all.
Having a toggle would help as well.
wait are you saying you have a g1 AND g2?
edit: okay I think I've been misunderstanding your situation here. so you have a g1 and g2 and your default Android gadget stuff is in g1, but you want to use g2 for HID functions?
Yes. I have a g1
and a g2
. Each time I boot, the contents of g2
are empty, but g1
is exactly as shown.
Oddly enough, every app except for this one works with the configuration I've got set up above.
edit: okay I think I've been misunderstanding your situation here. so you have a g1 and g2 and your default Android gadget stuff is in g1, but you want to use g2 for HID functions?
Precisely. To clarify:
Does it work? | This app | Other keyboard apps | ADB | USB tethering & file transfer |
---|---|---|---|---|
hid.* is in g1 |
Yes | No | Maybe | No |
hid.* is in g2 , where g1 is toggled |
No | No | Yes | Yes |
hid.* is in g2 , where g2 is toggled |
No | Yes | No | No |
With USB Gadget Tool, it's trivial to toggle between g1
and g2
. It is also trivial to create the hid.*
functions after boot. But it's not possible to remove them (on USB Gadget Tool) until you boot again.
this is incredibly weird. so while g2 is shown as "active" you can use all your standard Android gadget functions (listed under g1) but if HID functions are added to g1 and g1 is activated, you can no longer use the standard Android gadget functions? unless I'm misunderstanding, this sounds backwards.
Let me fix the table.
Done.
Not quite. g2
has the keyboard stuff. ADB won't work when I have g2
active. It also didn't work when I add the HID functions to g1
.
USB internet tethering only works when I have g1
active. The other keyboard apps only work when I add the functions to g2
and then have g2
active. Your app only works when the functions are tethered to g1
. However, this also breaks the other USB functions.
To clarify: only one gadget can be active at a time.
that's so strange. the reason I changed the app to modify the default Android gadget rather than creating a custom one is because on my device, all features work simultaneously that way.
now that I know what your situation is, I see why you wanted me to offer a choice of which gadget to modify. I'll put that on the list.
also, regarding your removal note, there is a way to remove the gadgets or functions but USB gadget tool doesn't expose it. it also causes a kernel panic on my device ever since updating to android 14, so heads up on that. if you don't mind going in a terminal youd just have to use a script like this but with the path at the top changed to the correct one.
It's a good thing that Android kept that bit of the kernel intact.
Weird. I tried the whole process again and saw dfferent stuff. I previously stated that ADB shell is also affected, which I didn't find this time around.
When hid.*
is supplied to g1
, ADB works, but USB file transfer and tethering are broken until I reboot.
I'll revise the previous posts.
interesting! this time around, did you let my app add the HID functions or did you do it through USB gadget tool?
I used your app.
this issue seems like it comes down to weird differences in kernels between devices. so I guess the only real solution is to re-implement my old method of handling HID functions as an optional fallback.
I did this:
hid.*
to g2
.g2
.g1
.yea I'll just eventually add an option to add the functions to a specific gadget if there are multiple. thanks again for all the details!
accidentally closed while i did some extremely messy merging because that old message was from when I didn't fully understand this issue
closing this issue in favor of #38, so the title can be more descriptive and I don't forget to add this.
Describe the bug I use a Surface Duo 1. The last working version for me is 1.0.0.
To Reproduce Steps to reproduce the behavior:
Before I launch the app, I use USB Gadget Tool and create
hid.keyboard
andhid.mouse
functions on Gadget path/config/usb_gadget/g2/
./config/usb_gadget/g2/
points to a Gadget with no functions pre-defined and is second on the list when you launch USB Gadget Tool.I open your USB HID Client and continue past initial setup.
I receive a popup saying that
/dev/hidg0
doesn't exist and accept the program's suggested fixes.I refresh USB Gadget Tools and discover that there are new functions in the wrong Gadget
.../g1/
. I still need to clarify this point.I receiving a popup which says that my character permissions might not be set up properly.
I tap 'FIX'; trace to previous step.
Device details (please complete the following information):
Additional context Incidentally, there is another simpler program currently in development (Android HID Keyboard). That one works perfectly fine.