How to remap Android buttons to Pandora Controls (Guide)

Mr_Loon

Can't Remember
Joined
Aug 30, 2010
Messages
2,326
Problem solved, how to here :D


Thought that this might be worth a post here as it seems to have been lost in the megathread.


Android devices have 4 main buttons, these are Home, Menu, Back & Search.


Currently they are mapped as follows :


Home : Pandora Button or F1


Back : Esc, Right nub to the right.


Menu : F2, Right nub down.


Search : Unknown


Volume Up / Down : F12 / F11


What I'd like to do is remap Back to left shoulder button, Menu to Start (Alt), Search to Select (Ctrl)


When asking about this in the other thread Notaz kindly replied with : 'You can edit /system/usr/keylayout/gpio-keys.kl, but that may break games that support hard keys'


To find out what values to use when editing the file I used keytest.apk


This gave me :


Left shoulder : Scancode=54


Start : Scancode=56


Select : Scancode=29


However being a bit of a noob I seem to have fallen at the first hurdle, I edited gpio-keys.kl using the text editor supplied with ES file explorer and upon trying to save it tells me : 'Error occurred when trying to save the file. It will not be saved'


I suspect that this is because you require root privileges to save changes to such a file.


So here are my questions :


1) How do you save an edit of /system/usr/keylayout/gpio-keys.kl?


2) In /system/usr/keylayout/ there are the following additional files : AVRCP.kl, keypad.kl & qwerty.kl Do they also need to be edited to ensure user customisation works, for instance in qwerty.kl key 54 (left shoulder) is mapped to SHIFT_RIGHT (which is of course correct for normal Pandora use) could I just change SHIFT_RIGHT to BACK WAKE_DROPPED in qwerty.kl to remap the left shoulder to the back button?


____________________________


In the other thread Milkshake replied with :

It could be because your trying to edit a file that is mounted over the appdata folder and they are non writeable, try to copy the file from the root of the android system to your app data folder but mapping the place it will be i.e. appdata//system/usr/keylayout/gpio-keys.kl then edit and save this :) that might work.
However my noobness strikes again :


Could anyone clearly explain what has to be done in Android & what has to be done in XFCE? From my limited understanding Android has no 'knowledge' of the appdata folder or its contents.


Where should I copy the .kl file to in the app data folder?


How do I map the place it will be?
 
Last edited by a moderator:

milkshake

Advanced Member
Joined
May 18, 2009
Messages
3,735
Age
35
Location
Rotherham, UK
basically when you launch a pnd most of the files needed are in the PND and they are mounted into a temp folder and over-layed over the appdata folder, this means while the app is running if you were to visit the app data folder you would see all the files, but when you close the app they all disappear.


The magic happens when you add a file into the add data folder in the same directory it would appear when the PND is run and over-layed on top of the app data folder, what will happen is it will use your file rather than the one in the appdata folder (as long as the file names are the same).


What I was trying to say before is get a copy of the file from the PND, can probably do this from within android just use a file manager and copy the file to your sd, make the necessary edits on and place into the appdata folder in the same place it would be when the PND overlays the same files, that way it will use your file instead, you will of course not see the changes until you next start the app from when you added the file to the appropriate place.
 
Last edited by a moderator:

Fworg64

Who knows?
Joined
Apr 27, 2011
Messages
196
Location
Fargo, ND
Now im confused... I always thought that Appdata was used over the files contained in the .pnd. Is it really the other way around? I fail to see the usefullness behind this...
 

milkshake

Advanced Member
Joined
May 18, 2009
Messages
3,735
Age
35
Location
Rotherham, UK
lol did you read correctly what I wrote? the files in the PND get overlaid into the appdata folder, but any file in the appdata folder beforehand takes Presidence over any file that may be in the pnd.


I did not say that the file in the PND gets used instead of any files in the appdata folder and I did not say the PND version gets priority over any file already in the appdata folder.


if I did I appologise.
 

Neelix

Insecticidal Maniac
Joined
Jan 8, 2011
Messages
3,230
Location
Melbourne, Australia
Actually I'm with fworg - that was a very confusing and I'd go so far as inaccurate way of putting it.


The filesystem contained in the PND is mounted to /mnt/utmp/appname as read-only


The appdata folder is then mounted on top of that as a read/write overlay and overrides any files that also exist in the PND.


As such:

  • Any data written to the mount folder is also written to appdata.
  • If you want to override a file in the PND you just create a file with the same name and the same relative path in the appdata folder.



Nothing is written to appdata during the mounting process.


- Neelix
 

Mr_Loon

Can't Remember
Joined
Aug 30, 2010
Messages
2,326
Many thanks Notaz & Milkshake, your suggestions work perfectly. :)


Here's what I did to remap Back to left shoulder button, Menu to Start (Alt), Search to Select (Ctrl):


It is assumed that the SD Card in the left hand slot is SD1, the right hand slot is SD2


In Android :


1) Using the file explorer navigate to /system/usr/keylayout/gpio-keys.kl


2) Copy gpio-keys.kl to the external SD Card (SD2)


3) Kill Android


In Linux :


4) Copy gpio-keys.kl from SD2 Card to SD1/pandora/appdata/android_ginderbread/system/usr/keylayout/


5) Using Mousepad edit gpio-keys.kl so it looks like this :



Code:
# linux   android		   flags


key 108   DPAD_DOWN

key 103   DPAD_UP

key 105   DPAD_LEFT

key 106   DPAD_RIGHT

key 139   HOME			  WAKE		 # pandora

key 29	SEARCH				  WAKE_DROPPED

key 56	MENU			  WAKE_DROPPED

key 102   BUTTON_A

key 107   BUTTON_B

key 109   BUTTON_X

key 104   BUTTON_Y

key 54	BACK			  WAKE_DROPPED

key 97	BUTTON_R1

6) Start Android and enjoy!


___________________________________________


Thoughts & Ramblings :


Lefties should map back to the right shoulder.


A good use of the search key is to launch application keyboard shortcuts, these can be defined in settings/applications/quick launch


To me this layout works well as the right hand can hold the stylus and the left easily press the 4 main Android buttons. When you get used to Android, you'll be surprised how much you use the back button, having this as a single easy keypress makes a lot of difference IMHO.
 
Last edited by a moderator:

milkshake

Advanced Member
Joined
May 18, 2009
Messages
3,735
Age
35
Location
Rotherham, UK
Actually I'm with fworg - that was a very confusing and I'd go so far as inaccurate way of putting it.


The filesystem contained in the PND is mounted to /mnt/utmp/appname as read-only


The appdata folder is then mounted on top of that as a read/write overlay and overrides any files that also exist in the PND.


As such:

  • Any data written to the mount folder is also written to appdata.
  • If you want to override a file in the PND you just create a file with the same name and the same relative path in the appdata folder.


Nothing is written to appdata during the mounting process.


- Neelix
this is indeed much better than my explanation :)
 
Joined
Apr 22, 2011
Messages
38
Wow! This is all unnecessary, what we need to do is to add /usr/keylayout folders to the system one we already had to do to get google play working and put the simple text gpio-keys.kl file as we want to configure it in there, then start Android which won't know what happened, but will act as we want it to. Am I right?
 
Joined
Apr 22, 2011
Messages
38
OK here it goes...

1st copy the following text

# linux android         flags     (I changed it to my liking)

key 108 DPAD_DOWN
key 103 DPAD_UP
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 139 HOME             WAKE         # This is the pandora button
key 29    MENU            #or SEARCH if you rather This is select button
key 56    BACK             #or MENU This is Start button
key 102 BUTTON_A
key 107 BUTTON_B
key 109 BUTTON_X
key 104 BUTTON_Y
key 54    BUTTON_L1 #or BACK
key 97    BUTTON_R1 #WAKE_DROPPED is also used, idk what's for
2 Open gEdit and paste it (configure as desired)

3 Hit save

4 Navigate to /media/yourSDcard/pandora/appdata/android_gingerbread/system

5 Create a folder and name it usr, then another inside it and name it keylayout

6 Name the file gpio-keys.kl and hit Save

7 Boot Android and enjoy
 

LTStone

Active Member
Joined
Feb 19, 2011
Messages
863
Age
45
Is there a way to make it so the nubs can be used for games in android?

I can't seem to get the nubs to configure when playing games.
 
Last edited by a moderator:

EssoAir

Well-Known Member
Joined
Dec 13, 2012
Messages
1,829
Location
Knoxville/Seattle
Last edited by a moderator:
Top