By Allen Ng
4th March 2011.
14:48
Hidden due to low comment rating. Click here to see.
Poorly-rated.
3
9
Before developers begin designing mobile games for Xperia™ PLAY, it is important to understand the different hardware keys for the device. The following information provides an overview of the hardware keys, along with a set of high-level gamepad recommendations and guidelines for game developers. This guidance may be help to developers are not familiar with developing mobile games that use hardware keys. This article also includes the key code and scancode mapping for the Xperia™ PLAY, which provides a handy reference for developing games according to standard hardware key functionality. The Xperia™ PLAY brings a new level of smartphone with the ultimate gaming experience, and these guidelines will ensure that developers create hardware-based gamepad functionality that complements soft key functionality, and overall consistent game play for all Xperia PLAY mobile games.
Hardware keys overview
The following illustration shows the different hardware keys for the Xperia™ PLAY. 
Key codes and scancodes
Any key press on a mobile device is described by a sequence of key events. Each key event is generally accompanied by a key code (getKeyCode()) and a scancode (getScanCode()). Key codes are defined in the KeyEvent class. Scancode constants are raw, device-specific codes obtained by the OS.
The following table provides a list of Xperia™ PLAY hardware keys and their corresponding key code values, Android™ key codes, and the recommended action that the key should perform.
Table 1. Xperia PLAY key codes
More information about Android key codes can be found in the description of the android.view.KeyEvent class at http://developer.android.com/reference/android/view/KeyEvent.html.
X and Circle button keycodes swapped in select regions
Depending on your region, the X button and Circle button on your Xperia™ PLAY may be switched. Use the method below to detect whether or not the X button and Circle button have been swapped.
The default behavior (the method below returns false) is for the X button to send KEYCODE_DPAD_CENTER and the Circle button to send ALT + KEYCODE_BACK.
The swapped behavior (the method below returns true) is for the Circle button to send KEYCODE_DPAD_CENTER and the X button to send ALT + KEYCODE_BACK.
Method:
The keycode swap can be detected by checking the Key Character Map for the display label of KEYCODE_DPAD_CENTER. There is a simple method, shown in the code example below, to detect if the display label of the KEYCODE_DPAD_CENTER is the WHITE_CIRCLE (hex 0x25CB) and therefore the change has been made. This check is important so that in the localization text, the correct button can be referenced for instructions and tutorials, and so that the buttons function as designed in gameplay.
private final char DEFAULT_O_BUTTON_LABEL = 0x25CB; //hex for WHITE_CIRCLE
private boolean isXOkeysSwapped() {
boolean flag = false;
int[] ids = InputDevice.getDeviceIds();
for (int i= 0; ids != null && i<ids.length; i++) {
KeyCharacterMap kcm = KeyCharacterMap.load(ids[i]);
if ( kcm != null && DEFAULT_O_BUTTON_LABEL ==
kcm.getDisplayLabel(KeyEvent.KEYCODE_DPAD_CENTER) ) {
flag = true;
break;
}
}
return flag;
}
As you may or may not know, the Playstation’s X and O buttons have opposite actions depending on the region. In Japan for example, O is select and X is back; however, in the United States, X is select and O is back. To adhere to user expectations, the Xperia™ PLAY will follow this trend and swap the keycodes that are reported by the X and O keys in regions where this is appropriate, based on the Playstation’s behavior in that region.
You can download a zip file of the full code example here.
Differentiating between the Circle button and Back key
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);
}
More information
By Allen Ng
4th March 2011.
14:48
Hidden due to low comment rating. Click here to see.
Poorly-rated.
3
9
By Joe Padre
9th March 2011.
02:05
Allen, it is not possible to play exisitng PSP games. It will be up to Sony, our parent company, to decide if there will be PSP titles available in the future. Thanks.
1
0
By Thomas
22nd March 2011.
18:12
Where can you find the latest games available for this phone? Like a list of games.
1
2
By Joe Padre
25th March 2011.
19:09
Hi Thomas, our colleagues from the Product blog are working on a list. Stayed tuned on http://blogs.sonyericsson.com/products/.
1
0
By James Seward
28th March 2011.
03:14
How much expertise would be need to build the game? Would 2-3rd year programming college students have the knowledge to build a game for this platform?
1
0
By Charles
29th March 2011.
18:27
Will games need to go through the Playstation certification program in order to be published?
1
0
By victor
31st March 2011.
06:01
Hidden due to low comment rating. Click here to see.
Poorly-rated.
1
4
By Joe Padre
31st March 2011.
23:26
Hi James. The Xperia PLAY uses the Android NDK and/or SDK, so as long as the programmer is comfortable using either/both, building a game is pretty doable.
1
0
By Joe Padre
31st March 2011.
23:29
Hi Charles, no, games do not need to go through the PlayStation certified program in order to be published.
1
0
By Joe Padre
31st March 2011.
23:30
Hi Victor. The cost of the phone will be determined by the carrier.
1
0
By mouhaabiwankenobi
1st April 2011.
15:29
i thinck that it wont work cause the 3Ds is available in the markets,and the new psp will be soon,…..know what i mean
2
0
By danny
8th April 2011.
21:38
how do u download playstation games on to it
1
3
Sort by