All Projects β†’ SukkoPera β†’ PsxNewLib

SukkoPera / PsxNewLib

Licence: GPL-3.0 license
Playstation controller interface library for Arduino

Programming Languages

C++
36643 projects - #6 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to PsxNewLib

sqlite micro logger arduino
Fast and Lean Sqlite database logger for Microcontrollers
Stars: ✭ 128 (+58.02%)
Mutual labels:  arduino-library, arduino-nano, arduino-uno, arduino-mega
Arduino
πŸš€ Proyectos de todo tipo para arduino utilizando sus sensores y actuadores. πŸ€–
Stars: ✭ 27 (-66.67%)
Mutual labels:  arduino-library, arduino-nano, arduino-uno, arduino-mega
CtrlUI
CtrlUI (Controller User Interface) is a Windows application, game and emulator launcher for your game controller, DirectXInput converts your game controller to a Xbox (XInput) controller, Fps Overlayer is a tool that shows the frames per second and the cpu, gpu and memory information.
Stars: ✭ 39 (-51.85%)
Mutual labels:  controller, playstation, dualshock
POPS-binaries
PlayStation One Portable Station binaries for POPStarter
Stars: ✭ 68 (-16.05%)
Mutual labels:  playstation-2, playstation, sony
LibreCO2
Simple CO2 meter using Arduino UNO-Mega board and popular CO2 sensors (SenseAir S8, Sensirion SCD30, Winsen MH-Z14 or 19 and Cubic CM1106). Operation modes: Normal, Calibration 400ppm, Alarm adjust and Altitud compensation adjust
Stars: ✭ 31 (-61.73%)
Mutual labels:  arduino-nano, arduino-uno, arduino-mega
Arduino-BLE-MIDI
MIDI over Bluetooth Low Energy (BLE-MIDI) 1.0 for Arduino
Stars: ✭ 133 (+64.2%)
Mutual labels:  arduino-library, arduino-nano
discord-arduino-bot
Easy to discord control your arduino with commands
Stars: ✭ 13 (-83.95%)
Mutual labels:  arduino-library, arduino-uno
Sim800L-Arduino-Library-revised
HIGH SCHOOL PROJECT - The purpose of this Arduino library is to allow the use of the SIM800L module in a simple and transparent way.
Stars: ✭ 81 (+0%)
Mutual labels:  arduino-library, arduino-uno
scd30
arduino esp8266 ESP8266 SCD30 SCD-30 ESP32
Stars: ✭ 38 (-53.09%)
Mutual labels:  arduino-library, arduino-mega
pctation
PlayStation emulator & debugger in C++17
Stars: ✭ 103 (+27.16%)
Mutual labels:  playstation, sony
DualSenseWindows UE4
Unreal Engine 4 port of the Windows API for the PS5 DualSense controller created at Ohjurot/DualSense-Windows
Stars: ✭ 25 (-69.14%)
Mutual labels:  controller, playstation
NASSCOM-MHRD-IOT-Practical-Module 1-2
Arduino on TinkerCad
Stars: ✭ 26 (-67.9%)
Mutual labels:  arduino-library, arduino-uno
qp-arduino
QP real-time embedded frameworks/RTOS for Arduino (AVR and SAM)
Stars: ✭ 37 (-54.32%)
Mutual labels:  arduino-library, arduino-uno
mpu6050
MPU6050 Arduino Library
Stars: ✭ 141 (+74.07%)
Mutual labels:  arduino-library, arduino-uno
Nintendoextensionctrl
Arduino library for communicating with Nintendo extension controllers
Stars: ✭ 67 (-17.28%)
Mutual labels:  controller, arduino-library
Segacontroller
Arduino library to read Sega Genesis (Mega Drive) and Master System (Mark III) controllers.
Stars: ✭ 55 (-32.1%)
Mutual labels:  controller, arduino-library
kerntroller
No description or website provided.
Stars: ✭ 31 (-61.73%)
Mutual labels:  hardware, controller
Button2
Arduino Library to simplify working with buttons. It allows you to use callback functions to track single, double, triple and long clicks. It also takes care of debouncing.
Stars: ✭ 109 (+34.57%)
Mutual labels:  hardware, arduino-library
GlosSI
Tool for using Steam-Input controller rebinding at a system level alongside a global overlay
Stars: ✭ 1,004 (+1139.51%)
Mutual labels:  controller, dualshock
Node Elgato Stream Deck
A Node.js library for interfacing with the Elgato Stream Deck.
Stars: ✭ 359 (+343.21%)
Mutual labels:  hardware, controller

PsxNewLib - Playstation controller interface library for Arduino

GitHub release (latest by date) GitHub Release Date GitHub commits since latest release (by date) arduino/arduino-lint-action Arduino_CI

PsxNewLib is an Arduino library that allows interfacing controllers designed for the Sony PlayStation and PlayStation 2 with Arduino boards.

When I started developing my PlayStation to Commodore adapter, I originally used the famous library by Bill Porter to interface with the controller. This seemed to work well initially, but then a number of issues surfaced:

  • It does not support non-DualShock controllers, which basically rules out all the excellent arcade sticks made for the PlayStation.
  • It only supports bit-banging the protocol. This means that it can work on any pins, but since the protocol is essentially SPI, we could let the hardware take care of it, making communication more reliable.
  • It just didn't work with some controllers, due to timing issues.
  • It looks more like a quick hack at the code level, rather than a polished and maintainable library.

In order to take of these issues, I started working on a new library, and so PsxNewLib was born.

Features

Currently, PsxNewLib provides access to the status of all digital buttons, analog sticks (on DualShock and later controllers) and analog buttons (on DualShock 2 and later controllers). It also provides functions to enable and disable the analog sticks and buttons.

Since v0.4, it also allows driving the vibration motors available on DualShock and later controllers.

It is compatible with a large number of different controller models, including the GunCon/G-Con light gun by Namco. Please see below for a list of which have been tested so far.

Using the Library

First of all, please note that this library depends on greiman's DigitalIO library, which you need to install as well. Unfortunately, the version that is available in the Library Manager has a bug that might cause an error during compilation. Because of this, I recommend not to install it through the Library Manager, but rather to get the master version and install it manually. You can also do that with my fork, which supports a few more platforms.

Moving on to the code, you need to decide whether you want to use the hardware SPI pins or not. According to this, you either have to instantiate a PsxControllerHwSpi or PsxControllerBitBang object. Then you can just refer to the example sketches to learn how to use this library, as the interface should be quite straightforward.

The API has a few rough edges and is not guaranteed to be stable, but any changes will be to make it easier to use.

Among the examples, there is one which will turn any PlayStation controller into a USB one simply by using an Arduino Leonardo or Micro. It is an excellent way to make a cheap adapter and to test the controller and library.

Wiring the Controller

Follow the pinout in the following picture from the amazing CuriousInventor PS2 Interface Guide:

PS2 Controller Pinout

You are advised not to rely on wire colors, but rather on pin positions. The wires in the image come from an official Sony controller, I expect their colors to be fairly consistent among all Sony controllers, but you shouldn't really trust them.

I recommend using 3.3V power and signal levels. While everything will appear to work fine at 5V, PlayStation controllers are not made to work at that voltage and they will break sooner or later. Many of the tutorials out there ignore this fact, but they really shouldn't. You have been warned.

In order to make things as safe and straightforward as possible, I have also designed an Arduino shield that will work perfectly with this library. Please check it out and use it as your reference for all connections.

Compatibility List

PsxNewLib aims to be compatible with all devices. I expect this to be the case with all the official controllers produced by Sony. Third-party devices should also work anyway. If you find one that doesn't work, please open an issue and I'll do my best to add support for it.

The following table contains the results of my tests, all done at 3.3V voltage level through my OpenPSX2AmigaPadAdapter:

Manufacturer Model Supported Notes
Sony PlayStation Controller (SCPH-1010) Maybe Not tested yet
Sony Revised PlayStation Controller (SCPH-1080) Yes
Sony Analog Joystick (SCPH-1110) Yes Informally known as the Flightstick
Sony Dual Analog Controller (Japan, SCPH-1150) Maybe Not tested yet
Sony Dual Analog Controller (USA, SCPH-1180) Maybe Not tested yet but likely to work, as SCPH-1180e does
Sony Dual Analog Controller (Europe, SCPH-1180e) Yes Controller actually only has SCPH-1180 on it, but I'm assuming it's the European version since it was bought in Italy
Sony DualShock Analog Controller (SCPH-1200) Yes
Sony DualShock 2 Analog Controller (SCPH-10010) Yes
Sony DualShock Controller for PSOne (SCPH-110) Yes
Asciiware Arcade Stick (SCEH-0002) Yes
Logitech Cordless Action (G-X2D11) Yes
Namco Arcade Stick (NPC-102 (SLEH-0004)) Yes
Namco neGcon (NPC-101) Yes Since v0.3
Namco JogCon (NPC-105) Yes Since v0.3
Namco G-Con/GunCon Yes Since v0.4, see the GunconAbsMouse example for details - Tested by @sonik-br
Taito Densha de Go! Two-Handle Controller (SLPH-00051) Yes Tested by @tylau0
Taito Densha de Go! One-Handle Controller (TCPP-20001) Yes Since v0.4 - Tested by @tylau0
EastVita Wireless Controller Yes Chinese knock-off, cheap but with surprising quality, pretty similar to the Lynxmotion controller, probably goes under other names, too

Debugging

If you have problems, uncomment the DUMP_COMMS #define in PsxNewLib.h and watch your serial monitor.

Releases

If you want to use this library, you are recommended to get the latest release rather than the current git version, as the latter might be under development and is not guaranteed to be working.

Every release is accompanied by any relevant notes about it, which you are recommended to read carefully.

License

PsxNewLib is released under the GNU General Public License (GPL) v3. If you make any modifications to the library, you must contribute them back.

PsxNewLib is provided to you β€˜as is’ and without any express or implied warranties whatsoever with respect to its functionality, operability or use, including, without limitation, any implied warranties of merchantability, fitness for a particular purpose or infringement. We expressly disclaim any liability whatsoever for any direct, indirect, consequential, incidental or special damages, including, without limitation, lost revenues, lost profits, losses resulting from business interruption or loss of data, regardless of the form of action or legal theory under which the liability may be asserted, even if advised of the possibility or likelihood of such damages.

Thanks

  • Bill Porter for the original library.
  • CuriousInventor for their excellent interfacing guide.
  • Matheus Fraguas (@sonik-br) for helping getting the G-Con/GunCon supported.
  • Eddie Lau (@tylau0) for helping with the Densha de Go! controllers.
  • Kate (@katemonster33) for contributing Rumble support.
  • All the other guys who helped understand how the PSX controller protocol works.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].