arian04 / android-hid-client Goto Github PK
View Code? Open in Web Editor NEWAndroid app that allows you to use your phone as a keyboard and mouse WITHOUT any software on the other end (Requires root)
License: GNU General Public License v3.0
Android app that allows you to use your phone as a keyboard and mouse WITHOUT any software on the other end (Requires root)
License: GNU General Public License v3.0
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
and hid.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.
Create activity that runs on first startup with 2 buttons
and a checkbox for whether or not to automatically recreate the character device on every reboot
Situation:
Character device doesn't exist
Current fix:
User is shown a prompt on app startup if its missing (yes = create it, no = ignore)
Proposed fix:
Same prompt, but add a checkbox to the side that let's the user allow the app to just handle the issue silently after being prompted for the first time
Current process:
too many steps. It SHOULD be automatic. my hunch is that the creation of the device takes a second or something, causing my automatic permission fixes to not apply, since they'll run before the devices exist, but I should confirm that sometime.
simple change, will implement this once I refactor the UI code, since the main thing blocking this is that I'm realizing more and more over time that character device handling might justify having its own screen.
details about one use-case for this option can be found in #29
I don't think there's an issue with performance to be honest, but I took some time to check, so I thought I should document what I found in case I ever need to reference the information later.
App version: b7d3c5f in "profileable" mode (baseline profiles enabled, debugging disabled, but I don't think it has all the extra release optimizations enabled)
keyboard - this website and just copy pasting a big string into manual input. it reports every "key up, key down" as 1 keystroke.
mouse - evhz
keyboard - after a few tests with different long strings, it seems to send around 250-280 keystrokes per second, so roughly twice as many reports per second.
mouse - consistently 90Hz. I wonder if this is tied to the screen refresh rate somehow, or just coincidentally the same as my phone screen's refresh rate.
The current implementation uses su -c
with echo
to send the report, however, su
causes a significant performance hit, and when sending many keys back to back, it really shows.
Possible solutions:
/dev/hidg0
, then I won't be restricted to shell commands using su
(Not sure how to achieve this, spent some time looking into it and got nowhere)su
process and use that elevated shell to send all echo
commands (only issue is that it feels a little messy and gracefully handling key timeouts may be impossible, feels like a bad solution, but the most likely for me to be able to get working)I think it may be a problem with my HID gadget descriptor, because even raw echo
commands sent through a root shell aren't working to increase the volume of the connected device. Media keys aren't working either.
Is your feature request related to a problem? Please describe.
If I want to input a set of series of keys at once (including key combos with CTRL or WIN), I cannot use the Manual Input field as it does not support special keyboard characters like SHIFT or CTRL. I can do it via Direct Input with a keyboard like Unexpected Keyboard, but then my input is in real-time and everything is not executed at once.
Describe the solution you'd like
A simple scripting language would both solve the issue I mentioned above and also allow you to use characters that are not present even on keyboards,, like Unexpeected or Hacker.
The scripting language could let you use character codes as well as plain text to specify exactly what you would like to input. On top of that, additional functions like delay() could be implemented. What I had in mind was similar to DuckyScript but obviously more superficial.
Describe the bug
I try to open the application, but it doesn't open :/
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The application is expected to open normally
Screenshots
I believe there is no need to add screenshots, But if you need it I'll add it later
Device details:
Additional context
Version V1.1.0 works normally on my device.
So far the app has been wonderful for me, it saved me a lot of trouble with my PC! I can't wait to get started on these new updates with the addition of the Mouse function
If you need help translating, I can help by translating into Brazilian Portuguese(pt-br)
Thanks for the app so far
Enter key closes keyboard
Tab key moves focus to next EditText (Manual Input)
Workaround for enter key: send a line break in manual input
It would be great if the code in this app could be easily extended to not send mouse movements out from the USB, but instead register to the local Android system as a connected emulated external mouse and that way the primary phone display could be used as a trackpad for an attached external display. When there's an external display, a USB mouse automatically shows a cursor only on the external display (when using Force Desktop mode from developer settings), but for example KDE Connect mouse receiver only shows a cursor on the primary phone display.
imo this is more of a bug in Android than my app, but I might as well try and work around it eventually.
Is your feature request related to a problem? Please describe.
So. A lot of people are going to use this on non-english keyboards, myself included. Maybe, it would be a good idea to add some kind of character→keycode handler for non-QWERTY layouts? Perhaps, files from Linux's keyboard layouts folder (/usr/share/kbd/keymaps/i386/
)?
Describe the solution you'd like
Ideally, this should be something like a setting that allows you to pick your used keyboard layouts, a quick switcher in the input activity to pick which layout you are currently using, and maybe an option to handle all layouts simultaneously for when they do not conflict with each other (say, english qwerty and russian йцукен)? So, pressing Л
would send the k
keyevent, as that is the key that corresponds to Л on the Russian layout.
Describe alternatives you've considered
I've tried using Hackers Keyboard with explicitly drawn russian chars. It was a pain to handle.
Describe the bug
Hello, the app always says "device not connected" (even tho it is) and when exporting debug log it says "error getting logs". The app didn't manage to make the phone a HID device so I used "USB gadget tool" (which I like to use more). No keys are being sent to the pc
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The app should work as intended; be a keyboard app
Screenshots
It's only showing the built in error messages
Device details (please complete the following information):
Additional context
Keyboard emulation works on "Rucky" (a app for running ducky scripts)
I love the idea and I'm so happy someone did it because the old app "USB keyboard" doesn't work (Pixel 8 Pro has no 32bit support)
From @404LiverNotFound in this comment
Describe the bug
v1.0.0-beta.4 works well, but every key is sent with l_ctrl key pressed in v1.0.0.
Device details (please complete the following information):
Logs (from wev)
Input: A
Logs:
[14: wl_keyboard] key: serial: 5965; time: 2827541; key: 37; state: 1 (pressed)
sym: Control_L (65507), utf8: ''
[14: wl_keyboard] modifiers: serial: 0; group: 16
depressed: 00000004: Control
latched: 00000000
locked: 00000010: Mod2
[14: wl_keyboard] key: serial: 5967; time: 2827541; key: 38; state: 1 (pressed)
sym: a (97), utf8: ''
[14: wl_keyboard] key: serial: 5968; time: 2827541; key: 37; state: 0 (released)
sym: Control_L (65507), utf8: ''
[14: wl_keyboard] modifiers: serial: 0; group: 16
depressed: 00000000
latched: 00000000
locked: 00000010: Mod2
[14: wl_keyboard] key: serial: 5970; time: 2827541; key: 38; state: 0 (released)
sym: a (97), utf8: ''
[14: wl_keyboard] key: serial: 5971; time: 2827542; key: 37; state: 1 (pressed)
sym: Control_L (65507), utf8: ''
[14: wl_keyboard] modifiers: serial: 0; group: 16
depressed: 00000004: Control
latched: 00000000
locked: 00000010: Mod2
[14: wl_keyboard] key: serial: 5973; time: 2827544; key: 37; state: 0 (released)
sym: Control_L (65507), utf8: ''
[14: wl_keyboard] modifiers: serial: 0; group: 16
depressed: 00000000
latched: 00000000
locked: 00000010: Mod2
just wanted to let anyone who checks on the repo know that I've been busy lately, but will have time to continue working on this in a bit.
Right now clicking the help or info menu buttons just show a little toast. I should finish them.
Describe the bug
The addition of the character device either crashes the application (during first setup and superuser request), or causes a system reboot.
To Reproduce
Steps to reproduce the behavior:
Enable the character device
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Device details (please complete the following information):
Additional context
Add any other context about the problem here.
they're old and don't reflect the current UI
Hi! I always dreamed of an app like this, but sadly can't root my phone.
Is this app able to function with ADB permissions? If so, it'd be amazing to see shizuku support implemented.
Is your feature request related to a problem? Please describe.
Currently, I don't seem to have a way to right click and I'd like to be able to click and drag things.
Discrete left and right click buttons would fix these issues.
Something like this. (Separate scrollable area would be nice in addition to the two finger scroll that's planned)
Describe the bug
ERROR: failed to create character device
Device details (please complete the following information):
Additional context (From #26)
I installed USB gadget tool and took the screenshot
I also copied the log, in case it can help
ROOT (stdout) - GADGET_PATH=/config/usb_gadget//
CONFIG_PATH=/config/usb_gadget///configs/acct/
Error - not able to change dir to /config/usb_gadget/*/... exit
ROOT (stderr) - : [1]: cd: /config/usb_gadget//configs: No such file or directory
: [1]: cd: /config/usb_gadget/: No such file or directory
root - length=1; index=1
ROOT - Execute command: echo KERNEL_VERSION=(uname -r |cut -d '-' -f1 )
&& (gunzip -c /proc/config.gz | grep -i configfs | sed 's/# //; s/ is not set/=NOT_SET/')
ROOT (stdout) - KERNEL_VERSION=3.18.71
ROOT (stderr) - : [1]: gunzip: not found
ROOT - Execute command: for dir in /config/usb_gadget//; do echo GADGET_PATH=$dir; cd $dir/configs/; echo CONFIG_PATH="$dir/configs/ls -1 | head -1
/"; cd $dir; if [ "$?" -ne "0" ]; then echo "Error - not able to change dir to $dir... exit"; exit 1; fi; echo UDC=$(cat UDC); find ./configs/ -type l -exec sh -c 'echo FUNCTIONS_ACTIVE=$(basename $(readlink "$@"))' _ {} ;; for f in ./functions//; do echo FUNCTIONS=$(basename
ROOT (stdout) - GADGET_PATH=/config/usb_gadget//
CONFIG_PATH=/config/usb_gadget///configs/acct/
Error - not able to change dir to /config/usb_gadget/*/... exit
ROOT (stderr) - : [1]: cd: /config/usb_gadget//configs: No such file or directory
: [1]: cd: /config/usb_gadget/: No such file or directory
root - length=1; index=1
ROOT - Execute command: for dir in /config/usb_gadget//; do echo GADGET_PATH=$dir; cd $dir/configs/; echo CONFIG_PATH="$dir/configs/ls -1 | head -1
/"; cd $dir; if [ "$?" -ne "0" ]; then echo "Error - not able to change dir to $dir... exit"; exit 1; fi; echo UDC=$(cat UDC); find ./configs/ -type l -exec sh -c 'echo FUNCTIONS_ACTIVE=$(basename $(readlink "$@"))' _ {} ;; for f in ./functions//; do echo FUNCTIONS=$(basename
ROOT (stdout) - GADGET_PATH=/config/usb_gadget/g2/
CONFIG_PATH=/config/usb_gadget/g2//configs//
UDC=
FUNCTIONS=*
UDC=
bDeviceClass=0x00
bDeviceProtocol=0x00
bDeviceSubClass=0x00
bMaxPacketSize0=0x00
bcdDevice=0x0318
bcdUSB=0x0000
configs=
functions=
idProduct=0x0000
idVendor=0x0000
os_desc=
strings=
=============
ROOT (stderr) - : [1]: cd: /config/usb_gadget/g2/strings/0x409: No such file or directory
cat: configs: Is a directory
cat: functions: Is a directory
cat: os_desc: Is a directory
cat: strings: Is a directory
Originally posted by @wokawoka in #26 (comment)
onKeyDown listener doesn't register ctrl when paired with backspace.
I've stopped maintaining this because I just started working on other projects but I noticed a few stars so if anyone is actually using this, let me know.
If people are using this, I'll try to do some actual testing and iron out some kinks that I'm sure I left in the project before I forgot about it.
update (10/06/2023): just to add an update for anyone who reads this. I haven't forgot about this, I still plan to do some cleanup and maintenance. I've just been a bit busy w classes. if anyone else reads this feel free to let me know about more bugs or feature requests!
update (3/24/2024): definitely took longer than I meant to for me to get back to this but I've been making improvements during the past week and have just committed some significant improvements. Will release them once it's more polished
Similar to the bar Termux puts on top of your keyboard for ctrl, alt, tab, etc.
I want to make it optional and modular, so users are able to choose which keys they want to show, if any.
It would be really cool to have an option to have just a touchpad on the screen - you could put your phone under the keyboard, for example, and have a basically laptop experience. Right now, in horizontal position touchpad area only takes the bottom half of the screen, so it's not really usable.
Well it's my personal immediate wish, I don't know if anyone else would find it a good idea.
because why not, some people might use it. Low priority since it's not that important and nobody has asked for it, but it would be interesting if it's not too much additional code.
The APK at the latest release (v1.1.0) identifies as
package: name='me.arianb.usb_hid_client' versionCode='1' versionName='1.0'
Looks like you forgot to update that in build.gradle
. Hard to tell the versions apart then 😉 Can you please keep them "in sync"? versionCode
should simply be increased with each new release (Android uses that internally to tell versions apart and to decide whether an APK is an update for the installed app), versionName
should ideally match the tag/release name.
Thanks in advance!
Describe the bug
The send button next to the multiline input disappears unless the field itself is two lines high or more.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The send button is there anytime I might need it.
Device details (please complete the following information):
Additional context
wm size
: 1080x2400
wm density
: 378
WIP on a branch that isn't pushed yet. Still learning Compose, so I want the code to at least not be horrible and have to be entirely re-written later after I push it.
My goal in doing this is to improve UI consistency, maintainability, and prettiness. I'll make sure Material You is an optional setting since not everyone likes it (depending on the app, sometimes I don't either).
currently, if the HID gadget is enabled on app start, the switch will still be in the "off" position.
Gboard doesn't send a shift KeyEvent with each key, and KeyEvent.isCapsLockOn() returns false even when caps lock is on, so I can't detect caps lock being on.
Hacker's keyboard works fine though, since it sends a distinct shift KeyEvent with each key when caps lock is enabled.
Current situation:
The user focuses an EditText (Labeled "Direct Input") and types into it. A textwatcher compares changes between the contents of the EditText after each change in the text and sends it. The intended use is for the user to keep typing characters without ever tapping on the EditText to move their cursor, as that would mess up the output.
Current issues with this:
Proposed solutions:
Make a little square in the app that the user can use like a touchpad
I've been working on this since d756e27, but I'm creating an issue to track this because It's probably more organized this way. Plus if people want, they can keep an eye on this.
Progress so far:
There is a "Troubleshooting" screen that provides some info to the user about detected problems. The "export logs" button is also present on that screen (same as the one in the "Settings" screen).
TODO:
I'm rooted with magisk and when I'm going to create character device functions it doesn't work
"ERROR: Failed to create character device"
Would it be possible for this to run on a non-rooted device using Shizuku?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.