Android buttons

Previous topic - Next topic

Gary

I know there are many various specs of android devices but is there any standard button numbering system for which key is which?

I knocked up a quick program to output the button number pressed (Much like the built in util for the SDK but running on any device) which I have attached.

On my Xperia Play the following buttons have the following codes

up 205
down 203
left 200
right 208
x 17
[] no value returned
^ no value returned
O exit program
menu 221 and 47
back and home both quit
magnify glass no value returned
L no value returned
R No value returned
vol up no value returned
vol down no value returned
As you can see a lot of buttons dont return a value. Is there anyway that these could be read?

If you can, could you add your devices buttons to the list to confirm they all match up and if there are any other devices with extra buttons that return different values

Am just going to run the same program on the emulator and see what I get



[attachment deleted by admin]

Gary

just tested on the emulator and found some interesting things out

centre of d pad is 17

Then I went along the keyboard. Every key was dead except

3 = 57
0 = 40
e = 14
f = 15
j = 28
shift = 42
alt l 58
alt r 184
space 51
, 7
. 8

This makes me wonder what a device with a physical keyboard would return. Why are only a small percentage of the keys returning a value? Is it a bug?


Gary

final test I can do is hook a USB keyboard up to my Disgo 6000 android pad. This returned exactly the same as the keyboard on the android simulator.

Kitty, should I be using another command apart from KEY to read the keys on an android device? If not then I do think there is a problem with the reading routine

MrTAToad

I think Gernot would need to get a device that has a physical keyboard before he can test it :)

spacefractal

I guess its one of model that have most buttons, but sadly it not ruturn values, since I would support those buttons too in my program (but I would not except the analog part would works, just buttons). My friend have extractly that phone, which work graphics for me (while I have a iPhone).

Also what do it happens if you add ALLOWESCAPE FALSE top of the program?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

I guess Gernot could also test it on the emulator first, since he did wrote about the keys did not work very well too?

So I think when that got to work there, then I guess most/all keys on other than the emulator should work again.

I do guess ALLOWESCAPE FALSE is important on Android systems (or possible to disable it)?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

ampos

I have just removed on SDLActivity.java the following:

Code (glbasic) Select
if(keyCode==KeyEvent.KEYCODE_BACK && !event.isAltPressed()) // some handle alt+back as "circle"
{
// mActivity.glbasicOnPause(1);   <-this line
mActivity.finish();  <- this line
System.exit(0);  <- this line
return super.onKeyDown(keyCode, event);  <- this line (note)
}


and the back key does not work anymore (android console says "4"), but also is not recognized by GLB. Also the "search" key is not recognized by GLB (console says "84").

Menu key returns on GLB key() 47 & 221 (yes, 2 keys are returned), "82" in console.

If the last line (note...) is not removed, the app os sent to back and not killed. Bringing it back make it crash.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Kitty Hello

yes, it crashes when it tries to resume. I have not found out why, yet.
That's why I made the back button send GLB_ON_QUIT and quit.

spacefractal

Yes have wrote about this too about none working buttons.

here is the last code I actuelly use:
Code (glbasic) Select

    // Key events
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
System.out.println("onKeyDown() : " + keyCode);
if(keyCode==KeyEvent.KEYCODE_BACK && event.isAltPressed()) {
SDLActivity.onNativeKeyDown(189);
return true;
}

SDLActivity.onNativeKeyDown(keyCode);
return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
System.out.println("onKeyDown() : " + keyCode);

if(keyCode==KeyEvent.KEYCODE_BACK) {
SDLActivity.onNativeKeyUp(189);
return true;
}
SDLActivity.onNativeKeyUp(keyCode);
return super.onKeyDown(keyCode, event);
}

@Override
    public boolean onKey(View  v, int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK && event.isAltPressed()) {
if(event.getAction() == KeyEvent.ACTION_DOWN) {
SDLActivity.onNativeKeyDown(189);
return true;
}
else {
SDLActivity.onNativeKeyUp(189);
return true;
}
}

if(keyCode==KeyEvent.KEYCODE_BACK && !event.isAltPressed()) {
// mActivity.glbasicOnPause(1);
mActivity.finish();
System.exit(0);
return super.onKeyDown(keyCode, event);
}     
        return false;
    }


howover the button does not working (treid to rerute circle button to 189, which is gamebutton 2), but did not kill the app, but the app still not like when the phone have been called. Here I guess because I have not checked pause/resume status yet.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/