Implement controller monitoring on Windows and fix Windows CI - #519
Conversation
|
Cleaned up code and addressed comments, thanks for reviewing! Retested on Windows, pairing both controller types. |
thp
left a comment
There was a problem hiding this comment.
See comments. Getting there!
Also update CHANGELOG.md with the new feature :)
|
|
||
|
|
||
| int | ||
| moved_monitor_get_fd(moved_monitor *) |
There was a problem hiding this comment.
Looking at usages of this function, src/utils/psmovepair.c has:
int run_daemon()
{
#if defined(__linux) || defined(__APPLE__)
moved_monitor *monitor = moved_monitor_new(on_monitor_update_pair, NULL);
int monitor_fd = moved_monitor_get_fd(monitor);
struct pollfd pfd;
pfd.fd = monitor_fd;
pfd.events = POLLIN;
while (1) {
if (poll(&pfd, 1, 0) > 0) {
moved_monitor_poll(monitor);
}
}
moved_monitor_free(monitor);
#else
for(;;) {
psmove_port_sleep_ms(5000);
pair(NULL);
}
#endif
return 0;
}Should we adjust this to take advantage of the new monitor code when using psmove pair -d on the command line? Rescanning every 5 seconds is also not bad, but having this work more proactively would be nice. Then again, we would really need this to support a kind of blocking moved_monitor_poll() to take RESCAN_INTERVAL_MS into account.
There was a problem hiding this comment.
I like this idea of being more proactive, I've updated the code, psmove pair -d now blocks in moved_monitor_wait(), waking immediately when the device-notification callback signals a controller change. It still uses RESCAN_INTERVAL_MS as a fallback if Windows misses a notification, without the previous five-second pairing loop or busy polling. More proactive now. I've left out updating this for Linux and macOS until further testing.
Tested successfully on Windows with controller pairing of both move controller types.
thp
left a comment
There was a problem hiding this comment.
Clean and fine now - thanks for working on this!
I'll have a look at the macOS/Linux polling cleanup now and will open a separate PR.
Dynamic controller monitoring was added for Linux and macOS in previous commits. Windows did not have a
moved_monitorimplementation, so this functionality was disabled. This PR adds a Windows monitor using device notifications and periodic HID rescans, and fixes some issues with the Windows CI builds.Implementation
moved_monitor_windows.cppCfgMgr32PSMoveAPIon Windowswindows-2022, the build currently targets Visual Studio 2022, and breaks withwindows-latestwhich pulls in Visual Studio 2026winsock2.h; newer libusb headers no longer supply thetimevaldefinition that PS3EYEDriver relied onThe monitor reports controller additions and removals through the same
moved_monitorinterface already used on Linux and macOS.Testing