Playstation 2 Controller PS2x

A somewhat capable device.  I was surprised to discover that all the play buttons are pressure sensed with and ADC output of 0 - 255 and a vibration motor that could provide useful feedback from the device under remote control. 

The current state of all the buttons and joystick positions are read out with the help of the PS2X_lib producing a 20 byte block. 

The first 3 bytes returned for my controller is FF795A, followed by 2 bytes that holds the button status, then 4 bytes for joystick position with the remaining bytes representing the ADC button pressure values.
There are cheaply available clones on Ebay and some slightly more expensive Sony branded.  They can be had for $5 - $20AUD.


This WEMOS is configured as both a wifi client and websocks client running a modified version of PS2X_lib (PS2X_esp_lib).
The author experimented with using UDP as a lightweight protocol between the xClient and the xServer but was unable to achieve the desired performance.
websockets however is remarkably robust and fast. 

The PS2x to xClient wiring is reasonably straight forward with only 1 pullup resistor.

The xClient attempts to connect to the a second WEMOS (aka xServer) that is acting as an wifi access point and websockets server.

Once wifi is up and the websocket session is established, xClient begins sending the 20 byte blocks of GamePad data to the xServer.  
The xServer then outputs this to the serial port.  The xServer sends heart beat packets that is used to flash a LED on the xClient to provide
quick status on connection state.  If its falshing slowly there is a good chance that all is ok.
The PS2x Gamepad Plug is connected to a WEMOS D1 via a carrier board that has pins (extracted from a female D25 connector) aligned with the PS2x Plug. See Image)
Power consuption for the xClient with the PS2x connected was measured at 5v @ 80mA.  The xClient continued to function standalone with 3.8v applied to the 5v input. 
3 x AA Energiser or Varta in series batteries may last approx 8 hours.

I suspect this power consumption is poor compared with commercial wireless controllers as the PS2X would not have been optimised and wifi provides
good range at the cost of battery life.  (Tests seem to indicate that the controller draws about 10mA which I thought was surprising low)

Future update will include a 20x2 LCD module to provide useful data sent back from the server.  It could provide battery levels, temperature level
or other useful diagnostic information.

If desired, the code for the xClient can be modified to send the 20byte blocks to the Serial port that can be processed and sent to a virual joystick driver allowing
the PS2x to be used as a wired PC game controller.


The xServer is a second WEMOS D1 configured as a wifi Access Point.  The default ip addr is   

The xServer has several I/O pins which can be configured for PWM etc and controlled as needed from the PS2x.  In this example pin D1 is configured as
PWM out which is determined by the pressure applied to the Blue 'X' buuton

Other unused IO can be configured to respond to PS2x button presses.

The xServer also prints the 20byte blocks to the Serial port which can be used for debugging or processed with the python script to send commands to a
virtual joystick.  This will allow PSX2 controller to be used as a wireless PC game controller.

The author used Mame running galaga to test the viability and proved to be quite playable.

PS2x as a PC Game Controller

To be used as a PC game controller a Virtual Joystick driver needs to be installed and mechanism to process the raw PS2x 20byte block. 
See vJoy and pyvjoy_serial_mapper below.

vJoy Virtual Joystick Driver

vJoy is a virtual joystick driver that comes with a python library and associated dll file to allow joystick data to be easily sent to virtual joystick.
This could be used...

Read more »