Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/daemon/moved.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,12 @@ static void
on_monitor_update_moved(enum MonitorEvent event,
enum MonitorEventDeviceType device_type,
const char *path, const wchar_t *serial,
void *user_data)
unsigned short pid, void *user_data)
{
move_daemon *moved = static_cast<move_daemon *>(user_data);

if (event == EVENT_DEVICE_ADDED) {
if (device_type == EVENT_DEVICE_TYPE_USB) {
// TODO: FIXME: This should use the device's actual USB product ID.
// HACK: We rely on this invalid PID being translated to a
// valid controller model (the old ZCM1, by default).
unsigned short pid = 0;
PSMove *move = psmove_connect_internal(serial, path, -1, pid);
if (psmove_pair(move)) {
// Indicate to the user that pairing was successful
Expand Down
3 changes: 2 additions & 1 deletion src/daemon/moved_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ enum MonitorEventDeviceType {
EVENT_DEVICE_TYPE_UNKNOWN,
};

// pid is the product ID on connect, it may be 0 on disconnect
typedef void (*moved_event_callback)(enum MonitorEvent event,
enum MonitorEventDeviceType device_type, const char *path,
const wchar_t *serial, void *user_data);
const wchar_t *serial, unsigned short pid, void *user_data);

typedef struct _moved_monitor moved_monitor;

Expand Down
4 changes: 2 additions & 2 deletions src/daemon/moved_monitor_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ _moved_monitor_handle_device(moved_monitor *monitor, struct udev_device *dev)
}

monitor->event_callback(EVENT_DEVICE_ADDED, device_type, path,
serial_number, monitor->event_callback_user_data);
serial_number, product_id, monitor->event_callback_user_data);
}

free(serial_number);
Expand All @@ -170,7 +170,7 @@ _moved_monitor_handle_device(moved_monitor *monitor, struct udev_device *dev)
free(uevent);
} else if (strcmp(action, "remove") == 0) {
monitor->event_callback(EVENT_DEVICE_REMOVED, device_type, path,
NULL, monitor->event_callback_user_data);
NULL, 0, monitor->event_callback_user_data);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/daemon/moved_monitor_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
enum MonitorEventDeviceType device_type;
char path[256];
wchar_t serial_number[256];
unsigned short pid;
};

struct _moved_monitor {
Expand Down Expand Up @@ -85,7 +86,7 @@ void pump_loop()
auto event = events.front();
event_callback(event.event, event.device_type,
event.path, event.serial_number,
event_callback_user_data);
event.pid, event_callback_user_data);
events.pop();
}
}
Expand All @@ -94,10 +95,12 @@ void pump_loop()
void
make_event(enum MonitorEvent event, IOHIDDeviceRef device)
{
if (get_vendor_id(device) == PSMOVE_VID && (get_product_id(device) == PSMOVE_PID || get_product_id(device) == PSMOVE_PS4_PID)) {
unsigned short pid = get_product_id(device);
if (get_vendor_id(device) == PSMOVE_VID && (pid == PSMOVE_PID || pid == PSMOVE_PS4_PID)) {
ASyncDeviceEvent ade;
ade.event = event;
ade.device_type = EVENT_DEVICE_TYPE_UNKNOWN;
ade.pid = pid;

// Example paths:
// e.g. "USB_054c_03d5_14100000"
Expand Down
8 changes: 2 additions & 6 deletions src/psmoveapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct PSMoveAPI {

void update();

static void on_monitor_event(enum MonitorEvent event, enum MonitorEventDeviceType device_type, const char *path, const wchar_t *serial, void *user_data);
static void on_monitor_event(enum MonitorEvent event, enum MonitorEventDeviceType device_type, const char *path, const wchar_t *serial, unsigned short pid, void *user_data);

EventReceiver *receiver;
void *user_data;
Expand Down Expand Up @@ -290,7 +290,7 @@ PSMoveAPI::update()
}

void
PSMoveAPI::on_monitor_event(enum MonitorEvent event, enum MonitorEventDeviceType device_type, const char *path, const wchar_t *serial, void *user_data)
PSMoveAPI::on_monitor_event(enum MonitorEvent event, enum MonitorEventDeviceType device_type, const char *path, const wchar_t *serial, unsigned short pid, void *user_data)
{
auto self = static_cast<PSMoveAPI *>(user_data);

Expand All @@ -308,10 +308,6 @@ PSMoveAPI::on_monitor_event(enum MonitorEvent event, enum MonitorEventDeviceType
}
}

// TODO: FIXME: This should use the device's actual USB product ID.
// HACK: We rely on this invalid PID being translated to a
// valid controller model (the old ZCM1, by default).
unsigned short pid = 0;
PSMove *move = psmove_connect_internal(serial, path, -1, pid);
if (move == nullptr) {
PSMOVE_ERROR("Cannot open move for retrieving serial!");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/psmovepair.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void
on_monitor_update_pair(enum MonitorEvent event,
enum MonitorEventDeviceType device_type,
const char *path, const wchar_t *serial,
void *user_data)
unsigned short pid, void *user_data)
{
if (event == EVENT_DEVICE_ADDED) {
if (device_type == EVENT_DEVICE_TYPE_USB) {
Expand Down
Loading