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

    • That’s great! I’ll give it a try, and eventually add it as an alternative in my post.

      If you make a Spanish .kcm-File, it would be great to share it.
      I could host it here, or include a link in my post.

  1. To all of you, who get notified about this comment:
    I updated the post and added version 0.3 of my German layout.
    The alternative mentioned by Pere and a little troubleshooting section was added, too.

  2. In case you get an error like “sh: can’t create /system/usr/idc/ HID compliant touch.idc: nonexistent directory”, when you try to connect ShareKM after enabling the “HW Keyboard” option, try creating a folder named “idc” in the “/system/usr/” directory”. The error should go away.

    Thanks for the helpful article.

    • Cool! Thanks for sharing this! I’ll add it to the troubleshooting-section when I have the time.
      Oh and if you made a working keymap for any language i could add it here (if you want). It’ll probably save some other guys some time.

  3. Pingback: ShareKM keyboard-layout workaround | fotodio.de

  4. Hi,
    I just release DeskDock, an app that works very similar to how ShareKM worked, plus has some additional features (such as multi-platform server and drag and drop). It automatically detects and uses your keyboard layout, so all the configuration is no longer necessary.

    Play Store:
    Free: https://play.google.com/store/apps/details?id=com.floriandraschbacher.deskdock.free
    PRO: https://play.google.com/store/apps/details?id=com.floriandraschbacher.deskdock.pro

1 2

Leave a Reply

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