{"id":25039530,"url":"https://github.com/fernandorpardo/playstation-3-controller-for-raspberry","last_synced_at":"2025-05-05T14:40:29.284Z","repository":{"id":191339999,"uuid":"284204239","full_name":"fernandorpardo/PlayStation-3-Controller-for-Raspberry","owner":"fernandorpardo","description":"PlayStation 3 Controller for Raspberry Pi","archived":false,"fork":false,"pushed_at":"2020-08-07T16:07:57.000Z","size":17,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T21:45:26.330Z","etag":null,"topics":["ps3-controller","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fernandorpardo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-08-01T06:44:04.000Z","updated_at":"2025-02-24T09:46:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b942cd0-b76d-4bb2-ab1b-5d101866bfa1","html_url":"https://github.com/fernandorpardo/PlayStation-3-Controller-for-Raspberry","commit_stats":null,"previous_names":["fernandorpardo/playstation-3-controller-for-raspberry"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandorpardo%2FPlayStation-3-Controller-for-Raspberry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandorpardo%2FPlayStation-3-Controller-for-Raspberry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandorpardo%2FPlayStation-3-Controller-for-Raspberry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandorpardo%2FPlayStation-3-Controller-for-Raspberry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fernandorpardo","download_url":"https://codeload.github.com/fernandorpardo/PlayStation-3-Controller-for-Raspberry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252516021,"owners_count":21760704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ps3-controller","raspberry-pi"],"created_at":"2025-02-06T02:52:20.095Z","updated_at":"2025-05-05T14:40:29.260Z","avatar_url":"https://github.com/fernandorpardo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PlayStation 3 Controller\nAlthough the procedure in this chapter is written for [the Wilson project](https://www.iambobot.com/en/articles/article_wilson_010_ps3.php) it is actually a generic way for integrating the PlayStation 3 Controller with a Raspberry.\n\nAfter this setup you will be able to steer the Wilson’s vehicle using any of the 3 joysticks on the PS3 controller: left, right, or gyroscopic (by tilting the controller). Or you can modify the code here to do something different with the joystick information in your own project.\n\nYou need to do the following:\n1. Tell the controller that the Raspberry is the new master\n2. Connect the PS3 Controller to the Raspberry via Bluetooth\n3. Install the PS3 Controller driver (sixad)\n4. Download and compile the joystick C++ code\n\nA more detailed explanation of the procedure can be found at [the Wilson project](https://www.iambobot.com/en/articles/article_wilson_010_ps3.php) web site.\n\n### 1. Set the Raspberry as the master\nDownload  `sixad`\n```console\n$ wget http://www.pabr.org/sixlinux/sixpair.c\n```\nInstall the USB lib\n```console\n$ sudo apt-get install libusb-dev\n```\nCompile `sixad`\n```console\n$ gcc -o sixpair sixpair.c -lusb\n```\nWith sixpair now compiled, plug the PS3 Controller to the Raspberry using the USB mini cable and execute sixpair\n```console\n$ sudo /home/pi/bin/sixpair\nCurrent Bluetooth master: b8:27:eb:ce:2b:38\nSetting master bd_addr to b8:27:eb:ce:2b:38\n```\n\n### 2. Connect via Bluetooth\nRun bluetoothctl\n```console\n$ sudo bluetoothctl\nAgent registered\n[bluetooth]#\n```\nEnable and configure the the agent\n```ApacheConf\n[bluetooth]# agent on\n[bluetooth]# default-agent\n[bluetooth]# power on\n[bluetooth]# discoverable on\n[bluetooth]# pairable on\n```\nConnect the controller to the system using a USB cable and press the PlayStation button\n```ApacheConf\n[CHG] Device 00:06:F7:41:75:2E UUIDs: 00001124-0000-1000-8000-00805f9b34fb\n[CHG] Device 00:06:F7:41:75:2E UUIDs: 00001200-0000-1000-8000-00805f9b34fb\n```\nAllow the service authorization request\n```ApacheConf\n[agent] Authorize service service_uuid (yes/no): yes\n```\nDiscover the controller's MAC address\n```ApacheConf\n[bluetooth]# devices\nDevice 00:06:F7:41:75:2E Sony PLAYSTATION(R)3 Controller\n```\nTrust the controller\n```ApacheConf\n[bluetooth]# trust 00:06:F7:41:75:2E\nChanging 00:06:F7:41:75:2E trust succeeded. push the central PS button.\n```\nQuit bluetoothctl and disconnect the USB cable. The PS3 Controller is now paired.\n\n### 3. Install the driver\nQtSixA is the Sixaxis Joystick Manager used to connect a PS3 Controller to a Linux machine. QtSixA is the GUI (interface), while sixad is the backend C++ code. Out of the QtSixA package we take just the C++ interface.\nFollow this intallation procedure:\n\nDownload QtSixA and decompress the tar file\n```console\n$ wget http://sourceforge.net/projects/qtsixa/files/QtSixA%201.5.1/QtSixA-1.5.1-src.tar.gz\n$ tar xfvz QtSixA-1.5.1-src.tar.gz\n```\nThe source code requires a patch to compile correctly. Download and compile the patch\n```console\n$ wget https://bugs.launchpad.net/qtsixa/+bug/1036744/+attachment/3260906/+files/compilation_sid.patch\n$ patch ~/QtSixA-1.5.1/sixad/shared.h \u003c compilation_sid.patch\n```\nBuild and install sixad\n```console\n$ cd QtSixA-1.5.1/sixad\n$ make\n$ sudo mkdir -p /var/lib/sixad/profiles\n$ sudo checkinstall\n```\nNow sixad is ready. Run sixad as command line ...\n```console\n$ sudo sixad --start\nsixad-bin[507]: started\nsixad-bin[507]: sixad started, press the PS button now\n```\n... and press the PS button. The controller rumbles while these messages appear\n```ApacheConf\nsixad-sixaxis[511]: started\nsixad-sixaxis[511]: Connected 'PLAYSTATION(R)3 Controller (00:06:F7:41:75:2E)' [Battery 02]\n```\n\n### 4. C++ code\nThe Wilson project provides the C++ code to capture events from js0, translate those events into (x, y) coordinates, and communicate through linux sockets with the vehicles' process that generates the PWM signals to power the motors. This code is also able to trigger rumble effects into the controller.\n\nTo install this SW proceed as follows:\n\nDownload the tarball with the source code, decompress and compile\n```console\n$ wget http://www.iambobot.com/downloads/wilson_ps3.tar.gz -O ~/downloads/wilson_ps3.tar.gz\n$ tar -C / -xvf ~/downloads/wilson_ps3.tar.gz\n$ winstall\n```\nTo run the sw:\n\nStart sixad\n```console\n$ sudo sixad –start\n```\nSwitch on the Controller by pressing the PS button\n\nOnce connected execute the SW selecting the axis: 0 for left joystick, 1 for (default) right joystick, or 2 for gyroscope.\n```console\n$ ps3 -a 1\n```\nPS3 captures the events from the driver to generates the (x,y) coordinates of the position of the joystick, and sends these coordinates to the wilson process through a linux socket (or to a processs of your own project if it opens a sockect listening to port 4096).\nPress the triangle button to \"release the breaks\" (note the front light turns on) and play with the joystick to move the vehicle.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandorpardo%2Fplaystation-3-controller-for-raspberry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernandorpardo%2Fplaystation-3-controller-for-raspberry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandorpardo%2Fplaystation-3-controller-for-raspberry/lists"}