Connecting PS3 controller to Xperia Z How can I connect my PS3 controller to my Sony Xperia Z for gaming?
You sure can! Sony introduced this in 4.2.2. for the sony-xperia-z

Sony have introduced native dualshock 3 support


  This software functionality was spied in the upcoming Sony Xperia SP (C530X) settings menu (Settings > Xperia). From here you will find a ‘DUALSHOCK 3 wireless controller’ menu option. You then need to connect the controller to your phone via an USB-OTG cable. Once this is done, you can remove the cable and the phone and controller will now be connected via Bluetooth.


Here is a YouTube guide on just this wirelessly:

3G Uk also have a guide posted on how to do this using USB OTG, and here is an extract:


  How do you connect the DualShock Controller ?
  
  Connecting your controller to your Sony Xperia devices doesn't involve rooting your device or anything complex.
  
  However, there are some things you'll need two things before you can begin:
  
  •USB OTG (On The Go) adapter - An inexpensive cable which enables you to connect USB devices to your Sony Xperia device (£2.68 on Amazon).
  
  •The charging cable that came with your PS3 Dualshock controller
  Then follow the 4 simple steps below:
  
  Step 1 - Connect the "charging cable" to your PS3 DualShock controller and plug the other end into the USB OTG adapter.
  
  Step 2 - Plug the USB OTG cable into the micro-USB port on your Sony Xperia smartphone/tablet.
  
  Step 3 - Open up "Settings" on your Xperia device and navigate to the "Xperia" menu (listed under the Device section)
  
  Step 4 - Select the "DualShock Wireless Controller" app and follow the on-screen prompts.


 

This artilce is for the coders and programmers and has details on how to implement in your own game. Not exactly what you asked, but may be of interest to some!