How to add Xperia™ device support for the DUALSHOCK™3 wireless controller in your Android™ game [video]

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.

By adding support for the DUALSHOCK™3 wireless controller in your Android game, you’re adding a number of benefits for the end user:

  • 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.

If you’ve already designed your game with generic controller support, such as for a virtual game pad, it’ll be easy to add support for the DUALSHOCK™ 3 wireless controller. You just need to:

  1. 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.
  2. 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.
DUALSHOCK™3 wireless controller (top view).
DUALSHOCK™3 wireless controller (top view).

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 0x124
Down KEYCODE_DPAD_DOWN 0x126
Left KEYCODE_DPAD_LEFT 0x127
Right KEYCODE_DPAD_RIGHT 0x125
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 0x0128
R2 KEYCODE_DPAD_R2 0x0129
L3 KEYCODE_DPAD_THUMBL 0x0121
R3 KEYCODE_DPAD_THUMBR 0x0122
SELECT KEYCODE_DPAD_BUTTON_SELECT 0x0120
START KEYCODE_DPAD_BUTTON_START 0x0123
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:

*DUALSHOCK®3 wireless controller can be used when the software is updated to Android 4.2.

DUALSHOCK setup

DUALSHOCK™3 wireless controller setup menu on an Xperia™ tablet.

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.

***

If you have any questions on how to add DUALSHOCK™3 wireless controller support in your game, feel free to leave us a comment below and we’ll get back to you with an answer as soon as we can!

PlayStation is a registered trademark of Sony Computer Entertainment Inc. SIXAXIS is a trademark of Sony Computer Entertainment Inc.

More information

Comments 116

Sort by: Newest | Oldest | Most popular

  1. By francis Guinto

    #1

    Hi joe padre i have a xperia z ultra and im planning to buy dualshock 3 or ps4 controller, i also have the latest os 4.4.4 kitkat will i able to conect the device wirelessly? Ive seen the issue you have listed and the issue comes only for 4.3 version, im also playing modern combat 4, ashpalt 8, kritika, the gate, will they be supported? Thanks

  2. By Syamsul anuar jaafar

    #2

    I got the latest android 4.4.4 built number 14.4.A.0.108 for my Xperia Z1. i have try to connect to my Dualshock PS3 (CECHZC2U). my Z1 can recognize via USB cable but cannot connect via bluetooth.

  3. By Abdulshakur Abubakar

    #3

    help i have xperia v android 4.3,how can i ps3 controller

  4. By Gino Tayag

    #4

    Joe padre,
    Update us please regarding on wireless connection problem of dualshock and xperia phones. Mine is z1.

    • By Joe Padre

      #5

      Hi Gino,
      If you have Xperia Z1 C6902/C6903/C6906, a defect was found with the Bluetooth connection when using certain models of DUALSHOCK(R)3 wireless controller with Android 4.3. We don’t have any details of when PlayStation will fix this issue.
      Best regards,
      Joe from Developer World

  5. By Αντώνης Τσαγκάρης

    #6

    I’ve a Xperia Z1 and I can connect the controller without any issues , the thing is i can’t get the right analog stick to work while playing modern compat 4

  6. By venky babu

    #7

    Hi I have Xperia tablet Z2 and it has Android version 4.4.2 and DUALSHOCK 3 controller doesen’t work wireless any help..? As the proceedure as state in the manual did not work i called the helpline and they asked me to try with SIXAXIS but when i did it still i get below error
    “Could not start driver check that your device is rooted”

    • By Joe Padre

      #8

      Hi Venky,
      Could you please post your question on StackOverflow? This way, our Sony support engineers can properly track your issue and share the solution publicly.
      Thanks,
      Joe from Developer World

  7. By Maxime FLAHOU

    #9

    I connected my Xperia Z1, and it’s work. But when i cut off the cable the DUALSHOCK™3 controller dosen’t work anymore. Anyone have any ideas to help me ? My Android version is 4.4.2
    Thanks a lot !

    • By Ken Tot

      #10

      same prob bro . i dont know if we need to root the phone .. but since its supported why it doesnt work wirelessly

      please help us …

  8. By Giancarlo Berardi

    #11

    i connected my xperia sp , it works but when cut off the cable, its not connected anymore with wifi or bluetooth. anyone can help? sp has 4.3 android version

  9. By Paul Vergance

    #12

    HI! I’ve problem with my Xperia Z1, when I want to connect my DUALSHOCK 3 to my xperia Z1 with the OTG cable nothing happens…The software of my phone is the latest version (4.4.2). I don’t understand…

    • By Gino Tayag

      #13

      Hi joe padre,
      Update please regarding the issue on wireless of xperia z1 to dualshock. Thanks..

    • By Gino Tayag

      #14

      When i remove the usb cable. Nothing happens. Wireless is not working..

  10. By Gum Ball

    #15

    I have the sony xperia l which is android 4.2 but I can’t get the option to connect a ps3 controller

    • By Yus Andres

      #16

      Not compatible

  11. By celestial nadal

    #17

    My dualshock 3 only works with cable in my xperia sp c5303 android 4.3 but it did not pair and i cant use it wirelessly even i follow the instructions could you please help me?

  12. By Tamás Birkás

    #18

    Hi! :)
    Can I somehow connect my DUALSHOCK 3 controller to my Xperia ST23i? I want to make my android game compatible with it. I know ST23i is not compatible but this is my only one android device. Or can I somehow emulate a DS3 compatible device?

  13. By Oliver Salas

    #19

    Sir can you helf me…how can i solve my problem regarding the connection on ps3 controller..at z xperia ultra..when i connect the controller using otg cable..usb phone disabled alarm occured and cannot rrcognize it…there is be solution for this or no?

  14. By Shameel Shahid

    #20

    Hi I have Sony Xperia v version 4.1 how to update it to 4.2

  15. By Ken Tot

    #21

    hi joe

    i have xperia Z1 4.4.2 android version
    tried connecting the DS3 SIXAXIS controller
    when i connect it via USB thru OTG the controller says connected and i was able to play or use it as wired connection

    my problem is that when i remove the Usb connection , it wont work wirelessly

    i used the Xperia™ Connectivity and then go to DUALSHOCK™3 wireless controller
    How to connect a controller option

    step 1 to 3 and it will says finished
    and it was working via USB connection but it wont work after i remove the usb

    the lights on the DS3 will flashed for like 3 seconds and stopped

    and i cant connect wirelessly or it doesnt detect the controller after removing the cable

    DS3 controller works wirelessly on PS3
    tried to reset as well the controller still wont connect

    tried all the forums and t/s that’s possible but still wont connect ..

    please help :)

    • By Ken Tot

      #22

      up

Show more comments

1-22 of 116 comments. Show all comments