PS Move API Cleanups

Fri, 13 Jan 2023 12:00:00 +0000

The open source motion controller tracking library has its code spring-cleaned. New camera support as well as better/faster color calibration is also available now.

I spent some of my free time over the holidays to fix up some long-standing annoyances with the PS Move API.

As part of that, I also ripped out many things (e.g. most language bindings) that weren't used but also modernised the codebase and added a few new features.

All the changes are listed in the ChangeLog, but here are some highlights:

Support for PS4 and PS5 cameras (including firmware upload) on Linux, macOS and (partially) Windows -- they act as UVC devices once the firmware is loaded

New fast hue-based color calibration as alternative to blinking calibration

Many internal fixes to the tracker, including per-controller dimming and less mis-detections

Move from Travis CI and AppVeyor to Github Actions (and removed MinGW in favor of MSVC, to simplify the build matrix and reduce #ifdefs)

Migrate to OpenCV 4, glm 0.9.9.8, C++14 and C99 `stdbool.h

Improved camera control on Linux using V4L2 APIs (PS3, PS4, PS5 cameras)

Fancy logging macros

Refactored after 10 years

Some of the original design decisions and code style decisions were quite bad in retrospect, but a few things got cleaned up, and the whole project started around a time where C++11 wasn't all that well supported or even a thing yet, and I didn't have as many years of professional C/C++ development experience as I have today ;) Not everything has been touched, and there's always room for improvement, but at least the newly added code (e.g. camera support and camera control driver) should be reasonably easy-to-read-and-maintain, although we still haven't fully removed the OpenCV C API usage, so there's that.

OpenCV binary size

One thing that would have been a fun project but that I haven't gotten around to do would be to do the CV parts in a custom GPU (compute) shader, as it would not be too complicated and could reduce the binary size which right now drags in lots of OpenCV things that we don't use (alternatively, looking at which parts of OpenCV need building could of course also help).

TODOs

There are still some things that would be nice-to-have, but have not been implemented yet:

More robust 3D sphere tracking (#465)

macOS Ventura Bluetooth pairing (#457)

API/ABI stability

Obviously the changes will affect the API and ABI of the library, so the next release would definitely be a new major version. As I don't know of any active API users that would benefit from a new release with stable API/ABI, it's very likely that there just won't (ever?) be a new official major release, and things will just move on in the development branch without any API/ABI stability guarantees (which makes it easier to clean things up and improve things, no need to pretend the API needs to be stable). For stability, version 4.0.12 from December 2020 ist still available and not going away, although practically speaking I'd recommend upgrading to the latest development version, as it has seen many improvements, and porting should be relatively straightforward.

Next up

There probably won't be much more work on this in the near future, but it was a fun exercise while I happened to have all the devices (PS3 camera, PS4 camera with adapter, PS5 camera and lots of controllers) in one place over the holidays. If you do want to sponsor development of additional features in PS Move API or have related projects where you could need consultant help, feel free to get in touch.