android key (re)mapping

928 views
Skip to first unread message

rema

unread,
Jan 28, 2014, 8:10:58 AM1/28/14
to ra...@googlegroups.com
Hi all,

Sorry in advance this is more of a generic Android question but I still want to ask it here to make sure I get it right:

My project is to use the radxa as a retrogaming console.
I found that just installing Retroarch on the pre-installed Android works great and does 90% of the job. Really effortless until this point.

Now, I would like to be able to fully get rid of the USB mouse/keyboard I use. Would like to make it fully usable with just a gamepad.


I found I can "browse" the Android interface with the gamepad, D-pad Up/Down/Right/Left works fine, the only problem is that every other button just behaves like a click, or touchscreen tap.
I need a way to bind one of the gamepad button (or combination of button) to behave like BACK, HOME, and possibly more additional functions.

Doing some research, it seems that it is normally possible to edit the mapping in /system/usr/keylayout/qwerty.kl file, which I have tried.
Unfortunately I can't write in this file (because it is stored into the NAND ?).

Does anyone have an idea of an alternative way for doing this ?
I'm even happy if this is done through an app.. I haven't found any yet.

cheers,
Rema

rema

unread,
Jan 28, 2014, 11:45:00 AM1/28/14
to ra...@googlegroups.com
ok I managed to do what I needed. probably in a really dirty way but well... that works.

In case that's useful to anyone else:

1/ /system is read only so we need to remount it as rw. I used the following method for this: http://www.androidpolice.com/2011/07/25/tip-how-to-enable-writing-to-read-only-partitions-remount-rw-in-total-commander-for-android/

2/ The  /system/usr/keylayout/*.kl files are used for mapping the keys

I used the following tool to read the keys scancodes: http://cloud.github.com/downloads/chrisboyle/keytest/KeyTest.apk

At first I thought I would simply re-map the 'B' button from my gamepad to execute the BACK action, I did it this way:
in /system/usr/keylayout/Generic.kl:
#key 290   BUTTON_3
key 290  BACK  

This method worked, but unfortunately I realized this mapping would also be effective while playing, which pretty much means that instead of seeing Mario jump, it would just exit the emulator... :)
What I needed was then to work with the /system/usr/keychars/Generic.kcm file instead, which defines key combinations (such as shift+k = 'K')

At this point, I decided that the BACK action would be triggered by the following combination on my gamepad: SELECT + R

My gamepad scans:
BUTTON_9 ==> SELECT
BUTTON_6 ==> R trigger

The keychar map files are using standard modifiers such as ctrl, shift, so I have to sacrifice a key to comply with an existing modifier. I chose "ALT_RIGHT" :
- change in /system/usr/keylayout/Generic.kl:
#key 296   BUTTON_9
key 296   ALT_RIGHT

(note: if I plug a keyboard, the right alt key will not have any action. not a problem for me as I don't plan to use a keyboard anymore. and who uses right alt anyway ?)

- change in /system/usr/keychars/Generic.kcm
key BUTTON_6 {
    base:     fallback DPAD_CENTER
    ralt:       fallback BACK
}

After a reboot, the combination of SELECT + R on the gamepad triggers a 'BACK' as desired.

Matt Mason

unread,
Jan 28, 2014, 4:28:20 PM1/28/14
to ra...@googlegroups.com

Tom Cubie

unread,
Jan 28, 2014, 11:03:06 PM1/28/14
to rema, ra...@googlegroups.com
On Wed, Jan 29, 2014 at 12:45 AM, rema <remi....@gmail.com> wrote:
> ok I managed to do what I needed. probably in a really dirty way but well...
> that works.
>
> In case that's useful to anyone else:
>
> 1/ /system is read only so we need to remount it as rw. I used the following
> method for this:
> http://www.androidpolice.com/2011/07/25/tip-how-to-enable-writing-to-read-only-partitions-remount-rw-in-total-commander-for-android/

Yeah, the /system is mounted read only by default. If you run adb, you
can use adb remount to mount it rw

>
> 2/ The /system/usr/keylayout/*.kl files are used for mapping the keys
>
> I used the following tool to read the keys scancodes:
> http://cloud.github.com/downloads/chrisboyle/keytest/KeyTest.apk
>

To get the key code, you can also run the command from android. If you
can go to android shell, run getevent to get the input event.
Add some thing here? :)

http://wiki.radxa.com/Rock/ir#Android_Key_Remapping

>
> On Tuesday, January 28, 2014 9:10:58 PM UTC+8, rema wrote:
>>
>> Hi all,
>>
>> Sorry in advance this is more of a generic Android question but I still
>> want to ask it here to make sure I get it right:
>>
>> My project is to use the radxa as a retrogaming console.
>> I found that just installing Retroarch on the pre-installed Android works
>> great and does 90% of the job. Really effortless until this point.
>>
>> Now, I would like to be able to fully get rid of the USB mouse/keyboard I
>> use. Would like to make it fully usable with just a gamepad.
>>
>>
>> I found I can "browse" the Android interface with the gamepad, D-pad
>> Up/Down/Right/Left works fine, the only problem is that every other button
>> just behaves like a click, or touchscreen tap.
>> I need a way to bind one of the gamepad button (or combination of button)
>> to behave like BACK, HOME, and possibly more additional functions.
>>
>> Doing some research, it seems that it is normally possible to edit the
>> mapping in /system/usr/keylayout/qwerty.kl file, which I have tried.
>> Unfortunately I can't write in this file (because it is stored into the
>> NAND ?).
>>
>> Does anyone have an idea of an alternative way for doing this ?
>> I'm even happy if this is done through an app.. I haven't found any yet.
>>
>> cheers,
>> Rema
>
> --
> You received this message because you are subscribed to the Google Groups
> "radxa" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to radxa+un...@googlegroups.com.
> To post to this group, send email to ra...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
radxa rock - quad core arm computer that rocks

radxa.com

rema

unread,
Jan 29, 2014, 2:48:45 AM1/29/14
to ra...@googlegroups.com
Hi Matt,

I haven't tried that one but I tried an other paid app demo that was caused the radxa to crash :(

So fyi before you buy, try the demo ;)

Matt Mason

unread,
Jan 29, 2014, 11:50:52 AM1/29/14
to ra...@googlegroups.com
I have it installed with no issues. You can also download their trial version to see if it works for you.

xjrcr...@gmail.com

unread,
Nov 11, 2016, 8:12:51 PM11/11/16
to radxa
I been trying to find whats the key number for the right click on the mouse, but I can't, and the keyTest app doesnt recognize it, do you know what number is?

xjrcr...@gmail.com

unread,
Nov 11, 2016, 8:13:41 PM11/11/16
to radxa

Sambhu R

unread,
Dec 6, 2016, 7:13:57 AM12/6/16
to radxa, xjrcr...@gmail.com
can anyone here answer this please?? https://groups.google.com/forum/#!topic/radxa/GfDYbVKtpxU

sorry for posting this offtopic here but we have trying this since last week still no hope of enabling uart1... As of of now only uart 0 and uart 3 are enabled we need uart1 enabled, please help....
Reply all
Reply to author
Forward
0 new messages