Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux support for PS4 Move controllers #361

Merged
merged 14 commits into from
Jul 27, 2018
Merged

Conversation

nitsch
Copy link
Collaborator

@nitsch nitsch commented Jul 8, 2018

There are a couple of things left to clean up (especially moved-related). But this should get us started with proper PS4 Move support.

Bluetooth setup was only implemented for Linux. Mac and Windows still need to be done.

Both seem to do the same thing (setting LED color and rumble), but 0x06
also works with the CECH-ZCM2 models.
This agent simply answers any HCI PIN Code Request with the PIN code
'0000'.
Those values are stored in the HID report as two's complement. Also,
there are no longer values from two different half-frames.
This model does not have any magnetometers.
There are no half-frames in the HID input report anymore. Instead, the
second value reported for the trigger button seems to be a heavily
low-pass filtered version of the first one. We simply return the first
value for this new controller model.
src/psmove.c Outdated

// free HID device enumerations
for (i = 0; i < NUM_PSMOVE_PIDS; i++) {
devs = hid_enumerate(PSMOVE_VID, PSMOVE_PIDS[i]);
Copy link
Owner

Choose a reason for hiding this comment

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

This shouldn't do a hid_enumerate() again, but just a hid_free_enumeration(move_hid_devices[i]);, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was only a silly copy & paste error. Fixed.

include/psmove.h Outdated
**/
ADDAPI enum PSMove_Bool
ADDCALL psmove_host_pair_custom(const char *addr);
ADDCALL psmove_host_pair_custom(const char *addr, enum PSMove_Model_Type model);
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, this changes kind of the public API. Should we add a new method psmove_host_pair_custom_model(); and have the old function just call that with Model_ZCM1 as the first parameter? This way, existing library users can still use the old function psmove_host_pair_custom() without breakage, while new code can take advantage of the model selection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair enough. Fixed.

src/psmove.c Outdated
if (gz != NULL) {
*gz = (int16_t) (move->input.gZlow + (move->input.gZhigh << 8));
}
} else {
Copy link
Owner

Choose a reason for hiding this comment

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

Something is wrong with the indentation here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converted tabs to spaces. Fixed.

move->input.mXlow);
}
if (move->model == Model_ZCM2) {
// NOTE: This model does not have magnetometers
Copy link
Owner

Choose a reason for hiding this comment

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

Should we disable/disallow magnetometer calibration in that case then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, probably. But this touches on the whole calibration data topic that I did not (yet) want to get into since there are also changes in the associated HID report for the new PS4 Move controller (and probably in the actual calibration data itself).

Copy link
Owner

Choose a reason for hiding this comment

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

ok

@@ -38,20 +38,30 @@
#include "../psmove_private.h"
#include "../psmove_port.h"

#define OPT_PS4 "--ps4"
Copy link
Owner

Choose a reason for hiding this comment

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

static const char *OPT_PS4 = "--ps4";

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Owner

@thp thp left a comment

Choose a reason for hiding this comment

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

Added some comments. For a first version, it's already quite good.

@s1xx1s
Copy link

s1xx1s commented Jul 21, 2018

First of all,
Thank You for the 'Ps-Move API'.
Great work!!!
I would also very much appreciate the addition of the PS4 Six-Axis Touchpad Contrthe oller API being added!
Many beneficial applications will be introduced!

Instead, introduce a new function psmove_host_pair_custom_model() that
accepts the controller hardware model as additional argument. This keeps
the public API stable.
@thp thp merged commit b58c98d into thp:cech-zcm2j Jul 27, 2018
@nitsch nitsch deleted the cech-zcm2j branch July 30, 2018 22:02
@nitsch nitsch mentioned this pull request May 14, 2020
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.

None yet

3 participants