ShareKM keyboard-layout workaround

-> German version

UPDATE 3:  Florian Draschbacher just released his new app DeskDock. If you are using USB check it out:

DeskDock Free: https://play.google.com/store/apps/details?id=com.floriandraschbacher.deskdock.free
DeskDock Pro:   https://play.google.com/store/apps/details?id=com.floriandraschbacher.deskdock.pro

UPDATE 2:
On devices running Android 5.x the mentioned version by ChtuluTheOne doesn’t work anymore. A fix is described by Fenny at the respective xda-forum-thread.

UPDATE:
Since approximately March 2014, ShareKM won’t start anymore. The developer has integrated an expiration date and abandoned his app.

The hacked version of ChtuluTheOne breaks the hardware-keyboard-option this workaround depends on, but the expiration date is gone.

There are two possibilities to get it working again:

  • The xposed-method by snapcity (root, but reliable and easy -> preferable)
  • The Tasker-method by me (potentially works on some unrooted devices but unlikely; not as reliable as the xposed-method, sometimes the date doesn’t get set back)

For problems with root detection, quack3d has a solution.

Index
-> Alternative: “External Keyboard Helper”
-> Known bugs
-> Changelog
-> Download
-> Troubleshooting

I like to use the app ShareKM for Android, which makes it highly comfortable to use the PCs keyboard and mouse with your android-phone. The switching works the same as with multiple monitors – you just have to move your mouse to the border of your monitor – or you can use a keyboard-shortcut.

The only drawback however, which rendered this app useless for me, is the wrong key-mapping – at least with the combination of my keyboard an phone (both German). The special characters are not where they should be.

Fortunately it’s easy to fix since Android 3.x. You only have to create a fixed key layout file and a suitable key character map for your desired language for the emulated hardware-keyboard used by shareKM and copy it to

/system/usr/keylayout/HID_compliant_kbd.kl (layout)
/system/usr/kechars/HID_compliant_kbd.kcm (character-map)

The name of these files is important because it has to match the name of the emulated keyboard.

ShareKM Keyboard-Layout

ShareKM Keyboard-Layout

You can either do this yourself or you can simply flash my .zip-file (see below, German layout UPDATE: NO & CH available), which puts the files for you in the right place.
Note: a custom recovery has to be installed on your phone in order to flash .zip-files (like 4EXT or clockworkmod).
The .kcm used in my .zip is from android-hilfe.de.

Need another language?

If you need another language than German, you have to edit the key-character-map with a decent text-editor (like notepad++;  _not_ MS Word/OpenOffice/Wordpad/…) and copy it to the right directory on your phone.
To make a flashable .zip just replace the files in my german (DE) zip with yours. It’s best to never unzip the .zip file but just open the file with 7-zip/winrar and drag&drop directly to it.

To make ShareKM use those new files, you have to make sure the “use hw-keyboard” option is checked in ShareKM-settings. Afterwards there should be an entry in the Android-settings for “language & input” saying “HID compliant kbd”. The layout of this keyboard has to be set to “default”! (just tap on it to change).
UPDATE: apparently this entry doesn’t show on all roms (such as Galax S4 stock-rom) but it should work just the same.

 

Alternative: “External Keyboard Helper”

As an alternative to the method above, you can use the app External Keyboard Helper.
However in its Pro -Version, it costs a few bucks.
With this approach you also need root, since the hardware-keyboard-option in ShareKM hast to be enabled.
Further the inbuilt layouts have to be adapted.
This is due to the fact, that ShareKM sends the wrong scancodes for some keys.
This could only be fixed by the developer of ShareKM, which sadly didn’t answer to any of my mails.

Many thanks to Pere (from the comments) for this tip!

 

By the way (known bugs):

  • instead of “AltGr” (right to the space bar, if you have one) you have to press “ctrl+shift” in shareKM
    -> Fixed with version 0.2!
  • the key between the left shift-key and z or y  does not work (if you have one). Perhaps it’s fixable – I don’t know.
    -> moved to Y with version 0.3
  • if you copied the files yourself and have problems, make sure the files have the right permissions set (chmod 644)! (Thanks Frank!)
  • With “Swiftkey” as active input method, shift has no effect when capslock is enabled.
    -> Workaround: set the standard android-keyboard (AOSP) as “standard” in shareKM. The old input method will be restored on disconnect.

 

Changelog

[14.12.13] DE Version 0.3:

  • Capslock now works with all keys (including special characters)
  • If Capslock is activated, shift now enables the lower case letters (as it should)
  • The function of the <>|-key (next to the left Shift) is now on Y, because the former isn’t available on Android
    •  <  :  Alt+Y
    •  >  :  Shift+Alt+Y
    •  |   :  Ctrl+Alt+Y or AltGr+Y

[03.08.13] DE Version 0.2:

  • Fixed Alt-Strg/AltGr (Thanks to Frank!)
  • Fixed the €

 

Latest downloads [14.12.13]

old downloads:

 

Troubleshooting

P: “mount: permission denied” when hardware-keyboard-option is enabled in ShareKM
S: In the Android developer options set “root-access” to “apps & ADB”
A screenshot (german) from Nik (from German comments):
http://s17.postimg.org/6nm6pkmkv/Screenshot_2013_12_13_02_52_54.png

There are no developer options?
Got to “Settings” -> “About this phone” (normally at the bottom).
Tap on the entry  “build-number” repeatedly till a message appears, which notifies you, that the developer options are now enabled (I’m serious!).
Now you’ll find them in the Android settings under “system”.

P: The entry “HID compliant kbd” doesn’t appear in the settings, although I enabled the hardware-keyboard in ShareKM and I’m connected.
S: That appears to happen on some samsung devices with stock-rom. It should work nevertheless.

P: I copied the files manually and it won’t work.
S: Make sure, the user rights of the files are set to rw-r–r– (644) and change them, if necessary, with a root-explorer or adb:

>> adb root
>> adb remount
>> adb shell
  # cd /system/usr/keylayout/&&chmod 644 "HID_compliant_kbd.kl"&&ls -l
  # cd /system/usr/keychars/&&chmod 644 "HID_compliant_kbd.kcm"&&ls -l

P: My recovery won’t flash the zip.
S:
Method 1: Manually
Extract the zip, copy both the files from the sub-dir “system” to your device and move them with a root-explorer in the following folders:

/system/usr/keylayout/HID_compliant_kbd.kl  (Layout)
/system/usr/kechars/HID_compliant_kbd.kcm   (Character-Map)

Check/change the user-rights with the root-explorer. They have to be set to rw-r–r– (644).

Method 2: With ADB
For the basics of ADB please use google and/or read this tutorial. Extract the zip, copy both the files from the sub-dir “system” to the adb directory.
Open the command line, cd into the adb-directory und enter the following commands:
(stolen from Sebastian from the German comments) :-)

>> adb root
>> adb remount
>> adb push "HID_compliant_kbd.kl" "/system/usr/keylayout/"
>> adb push "HID_compliant_kbd.kcm" "/system/usr/keychars/"
>> adb shell
  # cd /system/usr/keylayout/&&chmod 644 "HID_compliant_kbd.kl"&&ls -l
  # cd /system/usr/keychars/&&chmod 644 "HID_compliant_kbd.kcm"&&ls -l

Method 3: make new .zip
Download a .zip which your recovery flashes without error (e.g the GApps).
Please never unpack this .zip – instead do everything with 7zip or winrar an drag&drop.
Remove everything from the .zip except the “META-INF”-folder.
Unpack my .zip-file and move the “system”-folder to the new .zip.
Happy flashing!

Still doesn’t work?
Try to replace my update-script with the one from the new .zip.
You’ll find it each in \META-INF\com\google\android\

Doesn’t work either?
Try another .zip or another method.
Here is a tutorial to create a .zip  http://forum.xda-developers.com/showthread.php?t=2163974

19 thoughts on “ShareKM keyboard-layout workaround

  1. Hi. I tried this, but HID compliant kbd never shows up in the settings. I have a Galaxy S4 on stock Norwegian ROM (rooted). I have tried with both USB connection and WiFi. I put the .kl and .kcm into the right folders, ticked off “use hw-keyboard” but still no go. Any ideas?

    • Hey,
      you have to switch it to ON (not off) and reopen ShareKM afterwards! It’s the emulated “hardware-keyboard”.
      If it won’t work with it switched to ON, you could connect ShareKM-> it will hide automaticly -> reopen it -> tap on the keyboard-icon on the bottom-left-corner. Make sure there’s a switch “Hardware” switched to “ON”.

      Please let me know if it works for you, since I haven’t had the chance to test it with another keyboard-rom-kombination yet.

  2. Yeah, with “tick off” I meant switching it on. But still no cigar. After I’ve connected, opened the app again, hit the keyboard icon, there is no hardware keyboard to select either. Just the normal samsung keyboard, swiftkey, swype, etc.

    • Thats bad. But the hw-keyboard-settings should also show without the layout-files. So it appears to be a ShareKM-related issue. You could try to contact the developer of sharekm.

      Some thoughts of mine:
      -I use android v.4.2.2 also, so basically it should work with this version.
      -Make sure ShareKM gets root-rights. Perhaps you accidentally denied them once? Check it in your supersu or whatever you are using for root.
      -Reinstall sharekm.
      -Perhaps samsung hides / moved the physical-keyboard-settings.
      -Try to connect a normal hardware-keyboard with usb-otg or bluetooth, see whether it works.
      -Perhaps only the settings are hidden, and it just works? Don’t forget to adjust the .kcm file for your Dutch layout.

      I’m sorry I couldn’t help you properly!

  3. Found the problem. Permissions were wrong when I copied the files. Found out while modifying Generic.kcm instead of creating a separate HID_compliant_kbd.kcm. I didn’t bother with .kl at all. Still don’t have that hw-keyboard-settings option, but it works anyways.

    Thanks for finding this out. I can now enjoy ShareKm. You should post this guide to the various ShareKM threads at XDA. 🙂

    • Okay great! Thanks for sharing your solution!
      I already considered posting it on XDA, but haven’t found a proper thread.

    • I have made a few tweaks. As two buttons are not available in android 4.2 (the ‘less than’ key right to the left shift key and the $ key to the left of the enter button, I have moved those characters to the § button (top left). the § is now accessible by using the alt key. and the {} keys are somewhere one row below using alt as well. furthermore the dead keys might not be working as expected.
      furthermore I paid attention that everything is accessible by both alt keys and not just randomly the left or the right one as is with the german keyboard.
      another improvement compared to the german keyboard is that when caps lock is down, some characters will come up capitalized. the german keyboard required you to press the shift button.
      maybe you guys want to backport all those features.

      another thing I figured out: when your phone is rooted and you installed a terminal, you can do this directly on the phone:
      # su –
      to gain root
      # mount -o remount /system
      to make system writable
      # cd /system/usr/keychars
      # cd /system/usr/keylayout
      # mv /sdcard/HID_compliant_kbd.kl /system/usr/keylayout/
      # mv /sdcard/HID_compliant_kbd.kcm /system/usr/keychars/
      # chmod 644 [files from above in their target dir]

      this way, you can live test or modify your keyboards. no need to use zip files or reboots. in order to have your modified keyboard applied, just unplug and reinsert your usb cable if you are using the sharekms usb version.

      EDIT by Jonas: edited typo in path

1 2

Leave a Reply

Your email address will not be published. Required fields are marked *