Customize keyboard keys, buttons, and axes actions

Customizing and remapping of the default key, buttons and axis of DroidMote Server for Android, usefull for Android Games with Gamepad Support
User avatar
zulu99
Site Admin
Posts: 2485
Joined: Tue Oct 09, 2012 6:42 am

Customize keyboard keys, buttons, and axes actions

Post by zulu99 »

How to customize keyboard keys, buttons, and axes actions in DroidMote Server:

The folder location of droidmote.kl is /data/system/devices/keylayout ------> this file is for customization

The folder location of droidmote.kcm is /data/system/devices/keychars

This two files by default, in android version > 3.0, are automatically installed at first installation on the device with the server inside.

To know which scan codes send the client you can install in the server part the free tool (Keyevent Dispaly in the android Market).

Then follow these simple steps:

1) connect the client to the server
2) make sure everything works
3) on the server start the tool Keyevent Dispaly
4) click a button on the client
5) read the scan code on the Keyevent Dispaly
6) open the file /data/system/devices/keylayout/droidmote.kl
7) put the scan code on the left and on the right the new custom action
8) reboot the device with the server installed.

You can find the list of custom action to this android developer page:
http://developer.android.com/reference/ ... Event.html

The default scan codes for droidmote buttons are:
Arrow up is key 314
Arrow down is key 316
Arrow left is key 317
Arrow right is key 318
Arrow up-left is key 312
Arrow up-right is key 313
Arrow down-left is key 288
Arrow down-right is key 306

A button is key 304
B button is key 305
X button is key 307
Y button is key 308
Z button is key 309
square button is key 310
circle button is key 311
triangle button is key 315


Only honeycomb and later versions of Android include the use of buttons and axes:

key 304 BUTTON_A
key 305 BUTTON_B
key 306 BUTTON_C
key 307 BUTTON_X
key 308 BUTTON_Y
key 309 BUTTON_Z
key 310 BUTTON_L1
key 311 BUTTON_R1
key 312 BUTTON_L2
key 313 BUTTON_R2
key 314 BUTTON_SELECT
key 315 BUTTON_START
key 316 BUTTON_MODE
key 317 BUTTON_THUMBL
key 318 BUTTON_THUMBR


You can customize also the axes from honeycomb and later version of Android:

left stick x is 0x00
left stick y is 0x01

right stick x is 0x02
right stick y is 0x05

Ltrigger is 0x04
Rtrigger is 0x04

accelerometer x is 0x10
accelerometer y is 0x11

In the default configuration you have:
axis 0x00 X
axis 0x01 Y
axis 0x02 Z
axis 0x05 RZ
axis 0x03 LTRIGGER
axis 0x04 RTRIGGER
axis 0x10 HAT_X
axis 0x11 HAT_Y
in this configuration you use the left stick to move the avatar --> X and Y and the right stick to change view of the avatar --> Z and RZ

If you want you can change this in:
axis 0x00 Z
axis 0x01 RZ
axis 0x02 X
axis 0x05 Y
axis 0x03 LTRIGGER
axis 0x04 RTRIGGER
axis 0x10 HAT_X
axis 0x11 HAT_Y
in this configuration you use the left stick to change view of the avatar --> Z and RZ and the right stick to move the avatar --> X and Y

To understand better Android keylayout read this link: https://source.android.com/devices/inpu ... files.html


ATTENTION: With the last version of DroidMote Server, you can load your custom keylayout directly in DroidMote Server -> Settings -> Chenge keylayout without copy it manually in the /data/system/devices/keylayout folder.

1) Get the original droidmote.kl
2) Edit it where you want and rename it with a different name but with extension .kl
3) Copy your new keylayout file in the internal sdcard of the device with DroidMote Server installed
4) Go in DroidMote Server -> Settings -> Change keylayout and select your new keylayout



Base keylayout can change with future version of the app, but the main concept is this. Look the file droidmote.kl in /data/system/devices/keylayout to know your actual base keylayout, as start for your customizations.
Developer of DroidMote Server and DroidMote Client. Read the Quick Start Guides and then I'll be happy to help.
Donate with Paypal or Donate with Crypto
elios115
Posts: 8
Joined: Mon Nov 19, 2012 9:56 am

Re: thunder II and PES2012

Post by elios115 »

i dont know how to tell! if i try thunder II, i push the left arrow it goes extremely left, right extremly right and of course with no acceleromoter.
is there any way to generate a log for u to know what is happening? i cant just play anygame with gamepad at all.
now im asking if somebody have the touch profile for PES2012 maybe i ll be able to play it.
thanks zulu for ur support


zulu99 wrote:Be sure to have the two configurations files installed the first time that droidote started:

/system/usr/keylayout/droidmote.kl
/system/usr/keychar/droidmote.kcm

The stick of the gamepad work ?

I not have MK808, but i have a Minix Neo G4 with the same RK3066 CPU.

The first difference for all this cloned devices is the quality of the Android ROM, the second the build / assembly quality. (on Minix Neo G4 all work).
If you run the stock rom, is possible that this is a modified ROM that add same stuff but breaks other. For example on MK802, only on the first stock firmware and on all cyanogenmod droidmote is full working in all parts. I not tested the MK808, but for sure with a cyanogenmod inside you can have all working. This is not a problem of DroidMote, DroidMote is full compatible with all genuine android roms. The problem is that same of the ROMs inside this chinese devices are modified, for example to support the phisical remote control or are cloned from other device with the same hardware.

Apart DroidMote, my sugestion for all is:
When you buy a chinese mini pc, first of all read many forums and reviews. If you have same problem with stock firmware, i not speacking of DroidMote, find and install a CyanogenMod. With CyanogenMod the developers can see the source code and we can understand of what we are speacking.

Never buy a device for which there isn't the source code of the kernel online. (not putting the kernel source code online is illegal)

For now the only two good mini pc are the MK802 first version and the Minix Neo G4. The Ug802 have a defective wifi module, The MK808 have a negative stock rom. (solvable with a cyanogenmod inside). The MK802 III is under my attention, but for all complain that you can see in this forum http://www.rikomagic.co.uk/forum/viewfo ... a4cdc827fb for sure not have a good stock firmware, i hope only that not have the same wifi module of UG802.
User avatar
zulu99
Site Admin
Posts: 2485
Joined: Tue Oct 09, 2012 6:42 am

Re: thunder II and PES2012

Post by zulu99 »

elios115 wrote:i dont know how to tell! if i try thunder II, i push the left arrow it goes extremely left, right extremly right and of course with no acceleromoter.
is there any way to generate a log for u to know what is happening? i cant just play anygame with gamepad at all.
now im asking if somebody have the touch profile for PES2012 maybe i ll be able to play it.
thanks zulu for ur support

thunder II is playable with DroidMote in gamepad mode and also with accelerometer. If you want customize the sensitivity of the steering wheel, the game have this ability in the in-game settings.

To use the accelerometer edit the droidmote.kl with this:

# Joystick and game controller axes.
# Axes that are not mapped will be assigned generic axis numbers by the input subsystem.
axis 0x00 X
axis 0x01 Y
axis 0x02 Z
axis 0x05 RZ
axis 0x10 HAT_X
#axis 0x10 split 0x00 LTRIGGER RTRIGGER
#axis 0x11 HAT_Y

The right plase of speak about android games configurations is: Key layouts / Gamepad customization for DroidMote Server for Android
Developer of DroidMote Server and DroidMote Client. Read the Quick Start Guides and then I'll be happy to help.
Donate with Paypal or Donate with Crypto
pericles
Posts: 1
Joined: Sun Aug 18, 2013 7:45 pm

Re: Customize keyboard keys, buttons, and axes actions

Post by pericles »

hello , i dont know if this is the section for this .
i have a Logitech rumblepad 2 , Works perfectly when connect directly to the tablet and with the keyevent display shows the scan code ok , the ones u have in the droidmote keylayer by default , from 288 to 298 ( 10 buttons)
but the moment i wanna use the pad for play in the device with the droidmoteserver using droidmote client in Tablet ( bq Edison 2 ) , the sticks Works ok , but the buttons , button 1 make scancode 288 , and button 2 to 10 make the same scancode - 232 ( ENTER in the default keylayer ) . so for the moment i just can play with 2 buttons and the 2 sticks , can u make a fix to improve that ? , thanks a lot .
User avatar
zulu99
Site Admin
Posts: 2485
Joined: Tue Oct 09, 2012 6:42 am

Re: Customize keyboard keys, buttons, and axes actions

Post by zulu99 »

pericles wrote:hello , i dont know if this is the section for this .
i have a Logitech rumblepad 2 , Works perfectly when connect directly to the tablet and with the keyevent display shows the scan code ok , the ones u have in the droidmote keylayer by default , from 288 to 298 ( 10 buttons)
but the moment i wanna use the pad for play in the device with the droidmoteserver using droidmote client in Tablet ( bq Edison 2 ) , the sticks Works ok , but the buttons , button 1 make scancode 288 , and button 2 to 10 make the same scancode - 232 ( ENTER in the default keylayer ) . so for the moment i just can play with 2 buttons and the 2 sticks , can u make a fix to improve that ? , thanks a lot .
When you attach your pad to your client device, the scan code that send the pad should be the same, with droidmote client active or disactive. Who control how your pad communicate with your tablet is the keylayout of your pad. The droidmote.kl is in the server side and for the moment forget it.

find and open the keylayout of your pad in the system/user/keylayout folder of your tablet and look how scan codes are mapped to android keycode. What droidmote read and re-send to the server are the android keycode buttons.

You can customize also the keylayout of your pad in client part.

It very strange that all buttons of your pad map the same keycode enter for all scancodes. This is not correct and the problem is inside the keylayout of your pad. (If you have this. If you don't have the keylayout of your pad in client device you can find it on internet and download and copy in /system/usr/keylayout of your client device)

http://forum.xda-developers.com/showthr ... ?t=1623298
Developer of DroidMote Server and DroidMote Client. Read the Quick Start Guides and then I'll be happy to help.
Donate with Paypal or Donate with Crypto
Vioner
Posts: 7
Joined: Fri Feb 17, 2017 11:47 am

Re: Customize keyboard keys, buttons, and axes actions

Post by Vioner »

zulu99 wrote:zulu99
Hello,
Should this work fine for the software keyboard on client device?

I just bought your Droidmote Server app and it's great, but I have one major problem - the Polish diacritics won't work.

My environment info:
Droidmote Server - Jide Remix Mini (Lollipop)
Droidmote Client - Xiaomi Redmi 3 Pro. (Lollipop)
Client software keyboards tried: Touchpal, Google default

The problem:
When I use the software keyboard on the phone and longpress a -> ą to get the diacritic letter I need, the text entered on the serverside is "q".
It's the same for all diacritic characters I use in my language: Ą ą Ć ć Ę ę Ł ł Ń ń Ś ś Ź ź Ż ż
For letters "Ó ó" there is no text entered at all.

What I tried:
The FAQ says:
"28) What Soft Keyboard are supported from DroidMote Client ?
To write with the software keyboard of DroidMote Client, you must use the US/English keyboard on the Client and on the Server. Only latin character are supported. But you have an alternative to write not latin character and other language specific symbol, infact you can use the software keyboard of the remote device. When DroidMote is connected, by default you can't use the remote device software keyboard, but if you want this, you can set "phisical keyboard off" on the little keyboard icon that show on the notification bar when you are on a text edit. Alternatively you can enable the software keyboard in the "Settings / Language and input / Default" general settings when DroidMote is connected.

Volume Down + Keys simulate Ctrl + Keys"
I've used the built-in google keyboard or Touchpal - it didn't matter, the results were the same.
On both devices I've set English (US) language and keyboard language. I don't remember if this enabled the "ó" letter, but I think it's not that important.

Using the guide from OP, I could successfully change the keylayout, but not the keycharacter map. Maybe I don't understand something about this?

KeyEventDisplay app shows the following when I press any of the diacritic buttons (a -> ą, e - ę):

Code: Select all

^ KeyDown: action=0 code=45 repeat=0 meta=0 scancode=16 mFlags=8 label='Q' chars=`null` number=``
^ KeyUp: action=1 code=45 repeat=0 meta=0 scancode=16 mFlags=8 label='Q' chars=`null` number=``
For "ó" it shows:

Code: Select all

^ KeyDown: action=0 code=57 repeat=0 meta=18 scancode=56 mFlags=8 label='' chars=`null` number=``
^ KeyDown: action=0 code=113 repeat=0 meta=12306 scancode=29 mFlags=8 label='' chars=`null` number=``
^ KeyDown: action=0 code=34 repeat=0 meta=12306 scancode=33 mFlags=8 label='F' chars=`null` number=``
^ KeyUp: action=1 code=34 repeat=0 meta=12306 scancode=33 mFlags=8 label='F' chars=`null` number=``
^ KeyUp: action=1 code=113 repeat=0 meta=18 scancode=29 mFlags=8 label='' chars=`null` number=``
^ KeyUp: action=1 code=57 repeat=0 meta=0 scancode=56 mFlags=8 label='' chars=`null` number=``
Just to find out, I tried to modify the droidmote.kcm letter "A" - no modifiers, just pressing the bare "a" button. I replaced "a" with something else, but the change didn't "stick". It still shows "a".

By default, native Android has no support for Polish diacritics on physical keyboards and I understand that Droidmode receives scancodes as if the client device was an input device. Maybe that's one of the reasons?

What should I do to adjust your app to work well with Polish?
Please help me out.
Thanks
User avatar
zulu99
Site Admin
Posts: 2485
Joined: Tue Oct 09, 2012 6:42 am

Re: Customize keyboard keys, buttons, and axes actions

Post by zulu99 »

Vioner wrote:
zulu99 wrote:zulu99
Hello,
Should this work fine for the software keyboard on client device?

I just bought your Droidmote Server app and it's great, but I have one major problem - the Polish diacritics won't work.

My environment info:
Droidmote Server - Jide Remix Mini (Lollipop)
Droidmote Client - Xiaomi Redmi 3 Pro. (Lollipop)
Client software keyboards tried: Touchpal, Google default

The problem:
When I use the software keyboard on the phone and longpress a -> ą to get the diacritic letter I need, the text entered on the serverside is "q".
It's the same for all diacritic characters I use in my language: Ą ą Ć ć Ę ę Ł ł Ń ń Ś ś Ź ź Ż ż
For letters "Ó ó" there is no text entered at all.

What I tried:
The FAQ says:
"28) What Soft Keyboard are supported from DroidMote Client ?
To write with the software keyboard of DroidMote Client, you must use the US/English keyboard on the Client and on the Server. Only latin character are supported. But you have an alternative to write not latin character and other language specific symbol, infact you can use the software keyboard of the remote device. When DroidMote is connected, by default you can't use the remote device software keyboard, but if you want this, you can set "phisical keyboard off" on the little keyboard icon that show on the notification bar when you are on a text edit. Alternatively you can enable the software keyboard in the "Settings / Language and input / Default" general settings when DroidMote is connected.

Volume Down + Keys simulate Ctrl + Keys"
I've used the built-in google keyboard or Touchpal - it didn't matter, the results were the same.
On both devices I've set English (US) language and keyboard language. I don't remember if this enabled the "ó" letter, but I think it's not that important.

Using the guide from OP, I could successfully change the keylayout, but not the keycharacter map. Maybe I don't understand something about this?

KeyEventDisplay app shows the following when I press any of the diacritic buttons (a -> ą, e - ę):

Code: Select all

^ KeyDown: action=0 code=45 repeat=0 meta=0 scancode=16 mFlags=8 label='Q' chars=`null` number=``
^ KeyUp: action=1 code=45 repeat=0 meta=0 scancode=16 mFlags=8 label='Q' chars=`null` number=``
For "ó" it shows:

Code: Select all

^ KeyDown: action=0 code=57 repeat=0 meta=18 scancode=56 mFlags=8 label='' chars=`null` number=``
^ KeyDown: action=0 code=113 repeat=0 meta=12306 scancode=29 mFlags=8 label='' chars=`null` number=``
^ KeyDown: action=0 code=34 repeat=0 meta=12306 scancode=33 mFlags=8 label='F' chars=`null` number=``
^ KeyUp: action=1 code=34 repeat=0 meta=12306 scancode=33 mFlags=8 label='F' chars=`null` number=``
^ KeyUp: action=1 code=113 repeat=0 meta=18 scancode=29 mFlags=8 label='' chars=`null` number=``
^ KeyUp: action=1 code=57 repeat=0 meta=0 scancode=56 mFlags=8 label='' chars=`null` number=``
Just to find out, I tried to modify the droidmote.kcm letter "A" - no modifiers, just pressing the bare "a" button. I replaced "a" with something else, but the change didn't "stick". It still shows "a".

By default, native Android has no support for Polish diacritics on physical keyboards and I understand that Droidmode receives scancodes as if the client device was an input device. Maybe that's one of the reasons?

What should I do to adjust your app to work well with Polish?
Please help me out.
Thanks
I must made an update of the Client to support also Ą ą Ć ć Ę ę Ł ł Ń ń Ś ś Ź ź Ż ż

After you can create also a custom droidmote.kcm that map the scan codes produced by this characters in unicode format.

for example the character Ą is u104
https://unicode-table.com/en/search/?q=%C4%84

before i made the update in the client, you can't create a custom kcm that contain this characters because the Client don't know at all this characters , therefore don't send nothing to the Server.


But for all tests, try before on a real Android device. Remix OS is not a standard Android OS, many parts of Remix are modified compared to regular Android firmwares.
Developer of DroidMote Server and DroidMote Client. Read the Quick Start Guides and then I'll be happy to help.
Donate with Paypal or Donate with Crypto
Vioner
Posts: 7
Joined: Fri Feb 17, 2017 11:47 am

Re: Customize keyboard keys, buttons, and axes actions

Post by Vioner »

Thanks for the quick reply. I'll send you the proper .kcm file by tomorrow.
I've tried on different Android too - same result.
I'm a Remix OS Ambassador and code contributor, these things are same as in native Android.
User avatar
zulu99
Site Admin
Posts: 2485
Joined: Tue Oct 09, 2012 6:42 am

Re: Customize keyboard keys, buttons, and axes actions

Post by zulu99 »

Vioner wrote:Thanks for the quick reply. I'll send you the proper .kcm file by tomorrow.
I've tried on different Android too - same result.
I'm a Remix OS Ambassador and code contributor, these things are same as in native Android.
Well, but apart the specific characters that i should add in the Client, the generic customization of kcm and kl works because i tested on many Android devices.

In the server settings you can also load custom keylayout files. The kcm only manually, in the folder /data/system/devices/keychars

You must be sure that the kcm or kl not have error inside, also a single error the OS discard the file and must have right permissions like others kcm or kl files.

There are also Android tools to validate kcm and kl files, but if there are errors, you can read it from logcat.
Developer of DroidMote Server and DroidMote Client. Read the Quick Start Guides and then I'll be happy to help.
Donate with Paypal or Donate with Crypto
Vioner
Posts: 7
Joined: Fri Feb 17, 2017 11:47 am

Re: Customize keyboard keys, buttons, and axes actions

Post by Vioner »

I've attached a proper Polish .kcm file. I've tested in on my smartphone with a keyboard attached and it works well.

You said .kcm editing should have effect. To make things clear - I only need to edit the droidmote.kcm is /data/system/devices/keychars or should I create a custom.kcm file?
Editing the droidmote.kcm file makes no effect for me.

I'm a 100% sure I'm properly preparing the files.

How soon can you add a Polish character map to the client? :)

Thanks
You do not have the required permissions to view the files attached to this post.