KEY LAYOUT

Android 4.4.4 key layout is stored inside /system/usr/keylayout/ folder.

/system/usr/keylayout/Generic.kl supports a variety of keyboards, do not play with it !

The layout of the wireless joypads of the MD Flashback system are set by a file called /system/usr/keylayout/gpio-ctrl-keypad.kl which contains a full keyboard linux key code set.

If you open the file with a note editor you see something like that:
where “key xxx” is the assigned linux key code number and the following part is the Android key code name (keeping things simple: we will not cover the “axis declaration” part about joysticks, we will talk about keyboards/jopy buttons only); those function can be:

KEYBOARD

Each linux key code will represent a real keyboard button, ex:
key 1 ESCAPE
key 2 1
key 3 2
…..
key 12 MINUS
etc…


SYSTEM CONTROLS

Those are usually GPIO pins inside the device translated into key presses, ex:
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER
etc…


CAPACITIVE BUTTONS

Those simulates a capacitive touch button, ex:
key 139 MENU VIRTUAL
key 102 HOME VIRTUAL
etc…


HEADSET JACK MEDIA CONTROLS

Those are special control wires or resistive sensors translated into key presses, ex:
key 163 MEDIA_NEXT
key 165 MEDIA_PREVIOUS
etc…


JOYSTICK

Joystick buttons represented as keys, ex:
key 304 BUTTON_A
key 305 BUTTON_B
…..
key 314 BUTTON_SELECT
key 315 BUTTON_START
etc…

A line beginning with “ # ” is a comment line and is ignored by the system.

Obviously this gpio-ctrl-keypad.kl has all the keyboard available keys but each joypad has 13 + 13 buttons (13 for player 1 and 13 for player 2, selectable via a switch located in front of the joypad plastic case) which can be defined with another file, not present in the original stock firmware, called as the input device VID and PID which, in our specific case, are VID: 0001 and PID: 0001 so that the file name will be:
/system/usr/keylayout/Vendor_0001_Product_0001.kl .
This file can contain only a part of the linux keyboard codes and the ones it contains will be used instead of the ones inside gpio-ctrl-keypad.kl.

The following one is the file created looking at gpio-ctrl-keypad considering the 13+13 buttons of the gamepads only (you can copy/paste it and rename it Vendor_0001_Product_0001.kl):


#player 1
key 103 DPAD_UP
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 108 DPAD_DOWN
#zyx
key 59 F1
key 60 F2
key 61 F3
#abc
key 62 F4
key 64 F6
key 65 F7
#rewind
key 168 MEDIA_REWIND
#start
key 161 MEDIA_EJECT

#player 2
key 104 PAGE_UP
key 107 MOVE_END
key 159 FORWARD
key 109 PAGE_DOWN
#start
key 88 F12
#rewind
key 126 META_RIGHT
#abc
key 87 F11
key 166 MEDIA_STOP
key 125 META_LEFT
#xyz
key 68 F10
key 67 F9
key 66 F8

#both
#menu
key 139 MENU WAKE_DROPPED


(in the comment lines you can read which code corresponds to which gamepad button - as you can notice the MENU keys has the same linux code in both P1 and P2 joypads).

You can change this layout in the way you prefere, for example if you change line:

key 61 F3

to

key 61 ENTER

when you press the “61” key (which corresponds to the X button on the Player 1 joypad) the ENTER keyboard button will be sent to the system.

The name of all the available linux key code names can be read here (remove the “ KEY_ ” part): https://source.android.com/devices/input/keyboard-devices

After you copy the Vendor_0001_Product_0001.kl file into /system/usr/keylayout / you need to reboot the system in order for the changes to be affective !

REMEMBER THAT EACH APP BUILT TO SUPPORT THE ORIGINAL KEY LAYOUT (ex. the original atgames menu) WILL STOP WORKING CORRECTLY BECAUSE YOU ARE CHANGING THE WAY IT EXPECTS GAMEPAD BUTTON'S FUNCTIONS !

In any case, to restore back the original functions, just delete “Vendor_0001_Product_0001.kl” and reboot !