-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Conversation
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.
Weird, GCC on Linux did not even issue a warning ...
src/psmove.c
Outdated
|
||
// free HID device enumerations | ||
for (i = 0; i < NUM_PSMOVE_PIDS; i++) { | ||
devs = hid_enumerate(PSMOVE_VID, PSMOVE_PIDS[i]); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/utils/psmoveregister.c
Outdated
@@ -38,20 +38,30 @@ | |||
#include "../psmove_private.h" | |||
#include "../psmove_port.h" | |||
|
|||
#define OPT_PS4 "--ps4" |
There was a problem hiding this comment.
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";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this 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.
First of all, |
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.
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.