pelya / android-keyboard-gadget

Convert your Android device into USB keyboard/mouse, control your PC from your Android device remotely, including BIOS/bootloader.
Apache License 2.0
1.25k stars 314 forks source link

Keyboard/mouse event #35

Open miniME89 opened 9 years ago

miniME89 commented 9 years ago

Hey,

i am currently using your patch for developing an android app where I had a problem with your definition of the keyboard event structure:

You are saying that the keyboard event is an array of 8 bytes. So I though the following command should also work for writing the letter "a" to the device:

echo -n -e "\x00\x04\x00\x00\x00\x00\x00\x00" > /dev/hidg0

This didn't work for me, so after some hours (!) of searching for any problems in my Java code, which executes this command, I used your (precompiled) example program hid-gadget-test to verify the actual output by directing the output into some file:

echo a | ./hid-gadget-test /mnt/sdcard/test.txt keyboard

which actually writes the following byte sequence into the file (hexdump):

0000 0400 0000 0000 0000 0000 0000 0000

So these are 16 bytes instead of the expected 8. If I change my echo command to output 16 bytes instead of 8 it works perfectly.

Tested on Nexus 7 2012 with self compiled kernel. I didn't use the mouse events, but I would assume the same problem there.

feynman-x commented 6 years ago

Have you try control your pc by send mouse event ?

Mis012 commented 5 years ago

wtf? 0000 0400 0000 0000 <-- key down

0000 0000 0000 0000 <-- key up

2*8 = 16