Skip to content

Conversation

@Fancy2209
Copy link
Contributor

@Fancy2209 Fancy2209 commented Dec 29, 2025

Us

Description

This adds support for the PlayStation Move Controller.
I have not tested this with the PS4 Revision (CECH-ZCM2), as I only own the ZCM1 Revision for PS3. I have also not had a chance to test this on any platform but Linux.
I have not implemented Gyroscope or Accelerometer support for the Move yet, as I have no idea how to properly convert the values into what SDL expects or how to handle the half-frame approach of the data that's used in the ZCM1 Models, this, and due to a lack of testing outside Linux (if anyone reading this could test on other plats, it would be appreciated!) is why the PR is currently a draft.
I also currently do not have access to Xcode to add SDL_hidapi_psmove.c to the project (No idea why Ci mostly compiles)

The HIDAPI Driver is heavily based on PSMoveAPI, using the psmove cli utility the project provides is required to pair the PSMove to a non PlayStation Device

Existing Issue(s)

@slouken slouken added this to the 3.6.0 milestone Dec 29, 2025
Comment on lines 218 to 220
if(ctx->report_sensors)
{

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(ctx->report_sensors)
{
if (ctx->report_sensors) {

Please use SDL style for this file

if(ctx->report_sensors)
{

float sensor_data[3];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
float sensor_data[3];
float sensor_data[3];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etc.

sensor_data[2] = -(float)(((ctx->input.common.aZ[0] + ctx->input.common.aZ2[0]) +
((ctx->input.common.aZ[1] + ctx->input.common.aZ2[1]) << 8)) / 2 - 0x8000);
} else {
sensor_data[0] = (float)(Sint16)(ctx->input.common.aX[0] + (ctx->input.common.aX[1] << 8));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LOAD16 macro may be helpful here:

#define LOAD16(A, B)       (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed I was parsing these wrong, though looking at PSMoveAPI seems like I need 2 different functions
Pushed something for this

@slouken
Copy link
Collaborator

slouken commented Dec 29, 2025

Usually when I'm trying to puzzle out sensor values, I'll start with the accelerometer and compare the values with a PS4 controller to get the correct axis order and sign, and figure out the scale to match the magnitude of 1G. Then usually the axes will be the same order and sign for the gyro. The gyro scale is harder, but sometimes the spec sheet will help, and then I use testcontroller to validate all the values.

@Fancy2209
Copy link
Contributor Author

Fancy2209 commented Dec 29, 2025

Usually when I'm trying to puzzle out sensor values, I'll start with the accelerometer and compare the values with a PS4 controller to get the correct axis order and sign, and figure out the scale to match the magnitude of 1G. Then usually the axes will be the same order and sign for the gyro. The gyro scale is harder, but sometimes the spec sheet will help, and then I use testcontroller to validate all the values.

Looking at the PS4 HID Driver, I should probably add code to handle the calibration data before looking at conversions
This does help tough, thanks, will try to compare with my DS3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants