rajan72 / imame4all

Automatically exported from code.google.com/p/imame4all
0 stars 0 forks source link

Xperia Play - Differentiating between the Circle button and Back key #203

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Xperia Play - Differentiating between the Circle button and Back key

What steps will reproduce the problem?
1. Open application, press device's Menu button, navigate 
"Options>Settings>Define Keys";
2. Select "Player 1";
3. Click on "EXIT", and, while window labeled "Press button for EXIT" is 
displayed, press device's Back key
  (at this point, "EXIT" is mapped to "BACK" key)
4. Click on "STICK B", and while window labeled "Press button for STICK B" is 
displayed, press device's Circle button.
  (at this point, function "STICK B" is mapped to "BACK" button, and function "EXIT" is not mapped to anything)

What is the expected output? What do you see instead?
I was expecting to have "EXIT" mapped to Back key, and "STICK B" mapped to 
circle button, 
but the application detects Circle button and Back key as the same.
("STICK B" is just an example, this behavior occurs for any other function 
being mapped to Circle button)

What version of the product are you using? On what operating system?
MAME4droid-1.5.2.apk - Android 2.3.3

Please provide any additional information below.
Please, refer to instructions in 
http://developer.sonymobile.com/2011/02/13/xperia-play-game-keys/
for hints about how differentiate between the Circle button and Back key on 
Xperia Play.
Not sure if that can be directly applied to MAME4droid, but I'll copy the main 
idea below:

In order to differentiate between the Circle button and the Back key, which use 
the same key code, 
the developer needs to check whether or not the ALT button is enabled or 
disabled. 
When the Circle button is pressed, ALT is enabled; when the Back key is 
pressed, ALT is disabled.

Here is the code snippet:

public boolean onKeyDown(int keyCode, KeyEvent event) {if (keyCode == 
KeyEvent.KEYCODE_BACK) { // Remember both circle and back key provide same 
keycode
if(!event.isAltPressed()) { //check alt to differentiate between BACK and CIRCLE

//Do something (May be quit the game)
Log.i(“Back Key pressed”, “You pressed BACK key”);

}else {

//Do something else in the game
Log.i(“Circle Key pressed”, “You pressed CIRCLE key”);

}

return false;

}

return super.onKeyDown(keyCode, event);

}

Original issue reported on code.google.com by fabio.pa...@gmail.com on 12 Dec 2012 at 9:05