A wide range of Xperia™ devices support the DUALSHOCK 3 wireless controller, bringing a console-like experience to PlayStation® Mobile games. You can also deliver the same functionality to Android™ games. Read on to learn how to optimise your games for the DUALSHOCK™3 wireless controller for Android games – you’ll also find guidelines and recommendations, along with the key code mappings for the supported devices.
Develop & optimise your game for the DUALSHOCK™3 wireless controller for Android games
The DUALSHOCK 3 wireless controller provides an intuitive game play experience with gaming buttons and controls. Inputs include:
- Left and right joysticks.
- Directional buttons.
- Digital buttons: triangle, circle, cross, square, L1, R1, L2, R2, Start, Select.
- An input experience that is more familiar to gamers.
- Freeing up viewing space by removing onscreen controls.
- Allowing the games to be controlled wirelessly and be displayed and played on larger screens.
- Design and convert your existing game interactions to map to the DUALSHOCK™3 wireless controller, keeping in mind the tips mentioned below, and using DUALSHOCK™3 wireless controller keycode mapping table as a reference.
- Implement your controller design (see keycode mapping table below) and fine-tune the controls to make sure that it “feels right”, to give users the best controller experience possible.
Tips when adding DUALSHOCK™ 3 wireless controller support
When incorporating DUALSHOCK™3 wireless controller support into your development, you need to follow and keep the following tips in mind:
Tips to keep in mind | Notes |
A game should be fully playable using only touch screen controls. | Most devices only have a touch screen as an input controller. |
Hardware buttons should be used consistently throughout a game. | Users should be allowed to configure the control settings. |
In any menu, except for the main menu, the CIRCLE button should take the user back to the previous menu. In the main menu, the CIRCLE button should prompt the user with the option to exit out of the game. | In North America and Europe, the CIRCLE button is used as cancel. In Asia, the CIRCLE button is used as confirm. |
In any menu, the X button should be used as the confirmation button. | In North America and Europe, the X button is used as confirm. In Asia, the X button is used as cancel. |
On screen buttons should not appear when the user is using the DUALSHOCK™3 wireless controller. | There should be an option in the options menu to turn the on screen controls off or on. |
Implementing the DUALSHOCK™3 wireless controller buttons and joysticks
The DUALSHOCK™3 wireless controller support can be implemented using standard Android APIs. You’ll also need to know the key code mappings when you’re adding support for the DUALSHOCK™ 3 wireless controller in your game. Any key press on the device is described by a sequence of key events. Each key event is generally accompanied by the keycode getKeyCode() and getScanCode().
Use the table below for the keycode and scancode mappings for Xperia™ devices.
Key code mappings for all Xperia™ devices that support the DUALSHOCK™3 wireless controller.
Button | Keycode | Scancode |
Up | KEYCODE_DPAD_UP | 0×124 |
Down | KEYCODE_DPAD_DOWN | 0×126 |
Left | KEYCODE_DPAD_LEFT | 0×127 |
Right | KEYCODE_DPAD_RIGHT | 0×125 |
Circle: ○ button | KEYCODE_DPAD_BUTTON_Y | 0x12d |
Cross: × button | KEYCODE_DPAD_BUTTON_X | 0x12e |
Triangle: △ button | KEYCODE_DPAD_BUTTON_B | 0x12c |
Square: □ button | KEYCODE_DPAD_BUTTON_A | 0x12f |
L1 | KEYCODE_DPAD_L1 | 0x12a |
R1 | KEYCODE_DPAD_R1 | 0x12b |
L2 | KEYCODE_DPAD_L2 | 0×0128 |
R2 | KEYCODE_DPAD_R2 | 0×0129 |
L3 | KEYCODE_DPAD_THUMBL | 0×0121 |
R3 | KEYCODE_DPAD_THUMBR | 0×0122 |
SELECT | KEYCODE_DPAD_BUTTON_SELECT | 0×0120 |
START | KEYCODE_DPAD_BUTTON_START | 0×0123 |
PS | KEYCODE_DPAD_BUTTON_1 | 0x2d0 |
The following code snippet shows how buttons are detected from a DUALSHOCK™3 wireless controller.
public boolean onKeyDown(int keyCode, KeyEvent event) |
{ |
switch(keyCode) |
{ |
case KeyEvent.KEYCODE_DPAD_BUTTON_X: |
// CROSS button pressed |
break; |
case KeyEvent.KEYCODE_DPAD_BUTTON_Y: |
// CIRCLE button pressed |
break; |
... |
} |
return super.onKeyDown(keyCode, event); |
} |
The left and right analog sticks on the DUALSHOCK™3 wireless controller returns keycodes (UP, DOWN, LEFT, RIGHT for each direction) and can be used as joysticks. Each joystick has two axes (one for vertical and one for horizontal) and the range value can be obtained by calling the getMotionRange(int). Please keep in mind joystick implementation usually takes more effort and iterations to make the control “feel right”.
For more information and references on the Android gamepad APIs, refer to the InputDevice and MotionRange topics on the Android Developer website. You can also check out this Android and game controller video from the Android Developers for more tips on how to make your game controller compatible on Android.
How to setup the DUALSHOCK™ 3 wireless controller on your device
Currently, a number of Sony devices offer a setting that will allow you to connect a DUALSHOCK™3 wireless controller via Bluetooth™ to play games wirelessly, and the initial setup of the DUALSHOCK™3 wireless controller is quite easy.
The following Sony smartphones and tablets support the DUALSHOCK®3 wireless controller:
- Sony Tablet S
- Sony Xperia SP (C5302/C5303/C5306)
- Sony Xperia Z* (C6602/C6603)
- Sony Xperia Z1 (C6902/L39h/C6903/C6906/C6943)
- Sony Xperia Z Ultra (C6806/C6833)
- Sony Xperia ZL* (C6502/C6503)
- Sony Xperia Tablet S
- Sony Xperia Tablet Z (SO-03E/SGP311/SGP312/SGP321/SGP331)
*DUALSHOCK®3 wireless controller can be used when the software is updated to Android 4.2.
In the settings menu of the supported devices, there is an option for “DUALSHOCK™3 wireless controller”. In addition to the DUALSHOCK™3 wireless controller and USB cable, the only other extra item you’ll need to setup your DUALSHOCK™3 wireless controller is a USB on the go adapter. Once the DUALSHOCK™3 wireless controller is connected, it can be used to navigate through menus to select, start and play games.
PlayStation is a registered trademark of Sony Computer Entertainment Inc. SIXAXIS is a trademark of Sony Computer Entertainment Inc.
0 comments:
Post a Comment