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.22k stars 308 forks source link

Configuring hid-gadget-test for different keyboard layouts #36

Open zeratoss opened 8 years ago

zeratoss commented 8 years ago

Hey man great job! I would love to use this with my Qwertz computer. I saw https://github.com/pelya/android-keyboard-gadget/issues/29 and know that you have to recompile hid-gadget-test but how would you do that for different keyboard layouts?

pelya commented 8 years ago

Will you be using hid-gadget-test utility or the GUI app? You can reconfigure all keys inside GUI app.

On Thu, Sep 10, 2015 at 2:29 PM, zeratoss notifications@github.com wrote:

Hey man great job! I would love to use this with my Qwertz computer. I saw #29 https://github.com/pelya/android-keyboard-gadget/issues/29 and know that you have to recompile hid-gadget-test but how would you do that for different keyboard layouts?

— Reply to this email directly or view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/36.

zeratoss commented 8 years ago

The hid gadget utility with the duvky script bash interpreter from http://zx.rs/6/DroidDucky---Can-an-Android-quack-like-a-duck/

pelya commented 8 years ago

Thanks for the link, I've added it to readme.

On Thu, Sep 17, 2015 at 4:04 AM, zeratoss notifications@github.com wrote:

The hid gadget utility with the duvky script bash interpreter from http://zx.rs/6/DroidDucky---Can-an-Android-quack-like-a-duck/

— Reply to this email directly or view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/36#issuecomment-140936370 .

pelya commented 8 years ago

Well you just put QWERTY keyboard near your QWERTZ, and note all keys that are swapped from QWERTY layout. Then you swap the appropriate keys inside hid-gadget-test sources, and recompile it.

On Fri, Sep 18, 2015 at 1:00 PM, Sergii Pylypenko x.pelya.x@gmail.com wrote:

Thanks for the link, I've added it to readme.

On Thu, Sep 17, 2015 at 4:04 AM, zeratoss notifications@github.com wrote:

The hid gadget utility with the duvky script bash interpreter from http://zx.rs/6/DroidDucky---Can-an-Android-quack-like-a-duck/

— Reply to this email directly or view it on GitHub https://github.com/pelya/android-keyboard-gadget/issues/36#issuecomment-140936370 .

zeratoss commented 8 years ago

The problem is that some keys like "\" have no direct equivalent. On Qwertz it is "Alt Gr" + the key right of 0, but on Qwerty that combination does nothing, so i can't switch them.

tejado commented 8 years ago

Check https://github.com/tejado/Authorizer/blob/master/app/src/main/java/net/tjado/authorizer/UsbHidKbd_de_DE.java for a german scancode mapping.

zeratoss commented 8 years ago

@tejado thank you that looks really useful. Can i just add missing keys like {.opt = "ß" .val =0x2d}, ?

Is it different for values longer than four like kbdVal.put("€", new byte[] {0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00} );?

tejado commented 8 years ago

With the ß you can. Maybe for € there is no adjustment necessary as it should be just "echo right-alt e | ./hid-gadget-test /dev/hidg0 keyboard" or? (not tested)

winscripting commented 7 years ago

@zeratoss @tejado

I have the same problem as zeratoss has. I tried to add the \ (german keyboard) but i didn't get it working. Did you manage it? Can i change: {.opt = "backslash", .val = 0x31},? But which value? @tejado I've found this line in your repository for german layout: {0x02, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00} But i think, this is a too long.

Any ideas?

tejado commented 7 years ago

@VirtualThin it isn't too long, it is the complete 8 byte scancode like explained here: https://github.com/pelya/android-keyboard-gadget#how-it-works So my table is a complete mapping table as the mapping like in https://github.com/pelya/android-keyboard-gadget/blob/a41e6e2511cd5d76bc7aa2c9aa6ea45e98f0b78c/hid-gadget-test/jni/hid-gadget-test.c is done dynamic but is difficult to change to support other keyboard layouts.

The line for the backslash on a german layout is this: kbdVal.put("\", new byte[] {0x40, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00} );

You can change your backslash value to "0x2d" but the problem is, that the modifier key (Right-Alt key in this case, which is 0x40) is missing, to type this on a german keyboard. As you can see in my line, the first byte is representing this modifier key. I'm not so sure how to map this correctly in the dynamic mapping code of pelya. Due to this I created these complete 8 byte scancode mapping tables.