Greetings, habra people!
On DR, friends gave me a BT keyboard. Little, white, pretty, Comfortable!
I connected it to my Android 2.3.5 (SGSII), began using it to climb the menu, launch programs, reached Vkontakte and decided to write a message ... but I could not switch to Russian, but as it turned out later, it was only flowers ! But something I managed. I wonder how?
Now I have already understood a lot, and I do not know where to begin my story. Therefore, it will be long and boring, but the game is worth the candle!
We have:
RAPOO E6300 KeyboardAndroid Samsung Galaxy S II')
The first steps
I started by writing a letter to the keyboard tech support, with a question: could you assist with setting up the keyboard for Android? Received, as expected, a gentle rejection: "This keyboard is made specifically for the iPad."
While waiting for an answer from them, I began to “gossip” the topic of interaction between HID devices and Android. And among the mass of trash I found two useful articles:
Studying these articles made it clear that in order for the device to work properly, you need to edit at least the .kl file containing the key assignments.
Who was too lazy to read articles, I will briefly explain:
There is a folder on your Android device
(by the way, it depends on the device, details are in the article above)/system/usr
where are the directories we need
keylayout
and
keychars
They contain files of the type
_.kl
and
_.kcm.bin
respectively.
The first (plain text) is responsible for matching the keyboard signals (Linux key code) with Android (Android key code name) signals and looks like a list of the following commands:
key 30 A WAKE
Explanation:
key [scancode] [Android key] [Flags]
In Russian: if a button with a code of 30 was pressed on the keyboard, the A key will be sent to the system, and the device will wake up.The WAKE flag makes the device wake up and respond to pressing the letter A.
And the WAKE_DROPPED flag only makes you wake up, i.e. to press A, you have to press it again.
The article has a description of other flags.
The second (binary compiled from the source) is responsible for the key combinations along with Shift, Alt, etc. Here is a table from different options that describe the actions on the Android key. In its original form, it looks like:
key A {
label: 'A'
base: 'a'
shift, capslock: 'A'
ctrl, alt, meta: none
}
And it is compiled to speed up the work and load the device.
We decide what to do
I wrote to keyboard tech support again, describing my observations. But no support from them is not achieved. They are not interested. You have to do everything yourself.
What, need root again?
To access the / system folder, you need root rights. So you need to get it and not lose the warranty. I searched for a long time and
found one for myself. Nothing needs to be stitched. Everything can be brought back. USE AT YOUR OWN RISK! ALL ONLY FOR ACQUAINTANCE! NO RESPONSIBILITY! But for me everything worked as it should.
Preparing the file
To put something there, you need to prepare our file
keyboard_name.kl . And it's worth starting with downloading the original sample. The / system / usr / keylayout / folder can be accessed without root by copying the file we need using the file manager. I used
ASTRO . But you can use the console application adb.exe, supplied with
Samsung KIES .
adb pull remote local
command adb pull remote local
- copy file/dir from device
The first rake:
Determining the name of the desired file can be difficult. The general principle of file names, according to the article - Vendor_XXXX_Product_XXXX_Version_XXXX.kl or DEVICE_NAME.kl
Well, we found the file, downloaded it,
made a copy , opened it with a text editor like notepad.
My file was called
Broadcom_Bluetooth_HID.klSoooooo, and what have we got here?
Everything is clear, some codes, some buttons, which is not very clear to what, but we are ready for this, because we carefully read this article from the beginning to here. But how to determine the key codes?
The second rake:
To determine the key codes you need a debugging tool or ...
Just go to the market and
find what you need , not the first attempt of course. I tried 3-4 programs. Not everyone could boast the desired function - many only displayed Android codes that are already registered in our file. And we need scancods!
We get scancods
I “otkseril” my keyboard on a copier and pen began to sign the codes that KeyEvent Display program gave me. So I got a set of codes, it remains to rewrite them into a file and assign them the correct functions.

Editing the file
Open the first article on keyboards and methodically assign new values ​​to our buttons.
It turns out something like this:
# RAPOO E6300 keylayout file # (c) Nix Pro Soft - Nikita Tratorov, 2012 key 172 HOME WAKE_DROPPED key 217 SEARCH WAKE_DROPPED key 165 MEDIA_PREVIOUS key 164 MEDIA_PLAY_PAUSE key 163 MEDIA_NEXT key 114 VOLUME_DOWN key 115 VOLUME_UP key 1 BACK WAKE_DROPPED # key 183 key 41 GRAVE key 2 1 key 3 2 key 4 3 key 5 4 key 6 5 key 7 6 key 8 7 key 9 8 key 10 9 key 11 0 key 12 MINUS key 14 DEL key 15 TAB key 16 Q key 17 W key 18 E key 19 R key 20 T key 21 Y key 22 U key 23 I key 24 O key 25 P key 13 EQUALS key 43 BACKSLASH key 58 SHIFT_LEFT key 30 A key 31 S key 32 D key 33 F key 34 G key 35 H key 36 J key 37 K key 38 L key 39 SEMICOLON key 28 ENTER WAKE_DROPPED key 42 SHIFT_LEFT key 86 GRAVE key 44 Z key 45 X key 46 C key 47 V key 48 B key 49 N key 50 M key 51 COMMA key 52 PERIOD key 53 SLASH key 103 DPAD_UP key 54 SHIFT_RIGHT key 56 ALT_LEFT # key 125 # key 161 key 57 SPACE WAKE_DROPPED # key 126 key 26 LEFT_BRACKET key 27 RIGHT_BRACKET key 40 APOSTROPHE key 105 DPAD_LEFT key 108 DPAD_DOWN key 106 DPAD_RIGHT # keys for Android >=3.0 key 113 VOLUME_MUTE key 111 FORWARD_DEL key 1 ESCAPE WAKE_DROPPED key 59 F1 key 60 F2 key 61 F3 key 62 F4 key 63 F5 key 64 F6 key 65 F7 key 66 F8 key 67 F9 key 68 F10 key 87 F11 key 88 F12 key 58 CAPS_LOCK key 29 CTRL_LEFT key 104 PAGE_UP key 93 PAGE_DOWN
Third rake:
Not all buttons will work with your version of Android OS! Pay attention to the Version column in the first article about the keyboard. If you use code that is intended for versions greater than yours, then from this point the keyboard will not work.
All buttons listed after the wrong will not function.
Therefore, for future compatibility, I in my file, the keys are not intended for my version of Android OS, moved to the end. As practice has shown, in this case everything works and the file is ready for transfer to other versions of the OS.
Throw the file into the system
It can not do without the console utility. We connect the device via USB in debug mode and execute the following commands in the cmd.exe console:
d: cd D:\android-sdks\platform-tools adb push Broadcom_Bluetooth_HID.kl /data/local/Broadcom_Bluetooth_HID.kl adb shell su mount -o remount,rw -t ext4 /dev/block/mmcblk0p9 /system rm /system/usr/keylayout/Broadcom_Bluetooth_HID.kl cp /data/local/Broadcom_Bluetooth_HID.kl /system/usr/keylayout/Broadcom_Bluetooth_HID.kl chmod 644 /system/usr/keylayout/Broadcom_Bluetooth_HID.kl exit exit
Fourth rake:
The / system folder is on the file system in read-only mode. In order to write there, you need to remount the system in RW mode. But for this, you need to determine the mount point and file system type using a simple mount command.
After rebooting the device, the file system will again become “read only”.
Explanation of the commands:
D: \ android-sdks \ platform-tools is the folder in which I have adb.exe from the SDK (who only have KIES installed - look in Program Files)
adb push Broadcom_Bluetooth_HID.kl ... - this command uploads a file to a folder. The folder / data / local / was not chosen randomly. This is one of the few folders in which you can put something, and from which you can copy the file to another file system.
mount -o remount, rw -t ext4 / dev / block / mmcblk0p9 / system - remount the system. There are plenty of examples on the Internet on how to do this, but for some reason the wrong disks and file system are listed there. I had to adjust.
the rest is to delete the old one, copy our file and assign the correct rights to it. The assignment of rights is very important!
Check
Now you need to disconnect the USB (because it sometimes turns off Bluetooth) and restart the connection to the keyboard:
- If the keyboard does not want to connect, then you forgot to set the rights, incorrectly filled the file or put the file in the wrong folder (I repeat, they differ from each device, read the first article). In general, something with the file.
- If the keyboard is connected, but half the keys do not work, then from the place where it does not work, you have inserted a code that is not supported by your version. Move it to the end of the file.
Earned!
Congratulations! It could not be otherwise! You are well done! Just ... how can I switch to Russian?
Not long google, I found a simple answer - you need a soft keyboard that supports hardware. There are few of them. Ideal, in my opinion, for today -
ruKeybordInstall, customize, in the layouts install the hardware keyboard instead of qwerty, etc.
Now you can switch the layout using
Alt + Shift (UPD: or
Shift + Space ). And the checkbox is shown.
Who else do not know, to quickly switch between keyboards, hold your finger on any input field and select "Input mode" from the pop-up menu.
Results
No matter how hard I tried, but to make all the buttons earn, like a computer, on 2.3.5 it is impossible. But soon I will update to Android OS 4 and the new buttons will work. In the first photo I sit in putty and edit the site. It lacks the Ctrl button. I'm really looking forward to updating the OS. Pleased with the result.
Done!
Thanks for attention!