Implement controller monitoring on Windows and fix Windows CI - #519
Implement controller monitoring on Windows and fix Windows CI#519adangert wants to merge 3 commits into
Conversation
| const bool sony = normalized.find(L"vid_054c") != std::wstring::npos || | ||
| normalized.find(L"vid&0002054c") != std::wstring::npos; | ||
| const bool move = normalized.find(L"pid_03d5") != std::wstring::npos || | ||
| normalized.find(L"pid&03d5") != std::wstring::npos || | ||
| normalized.find(L"pid_0c5e") != std::wstring::npos || | ||
| normalized.find(L"pid&0c5e") != std::wstring::npos; |
There was a problem hiding this comment.
Nice to have: Use PSMOVE_VID / PSMOVE_PID / PSMOVE_PS4_PID here to build wide strings instead of hardcoding those values, e.g. by formatting into a wide string "vid_%04x", etc..
There was a problem hiding this comment.
Thanks! will try to get to these all (and retest) soon!
| continue; | ||
| } | ||
|
|
||
| candidates.push_back({ |
There was a problem hiding this comment.
Could be emplace_back to potentially avoid extra copies.
| if ((action == CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL || | ||
| action == CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL) && | ||
| is_move_interface_path(event_data->u.DeviceInterface.SymbolicLink)) { | ||
| monitor->rescan_requested.store(true); |
There was a problem hiding this comment.
Style nitpick: assignment (monitor->rescan_requested = true;) probably also works, but it's maybe more obvious to use .store(true) here that we're dealing with an atomic.
| monitor->notification = nullptr; | ||
| monitor->unregister_notification = nullptr; | ||
|
|
||
| if (monitor->cfgmgr32 != nullptr) { |
There was a problem hiding this comment.
If monitor->cfgmgr32 == null, should we delete the monitor object again and return nullptr, to make it obvious to the caller that monitoring is not supported? Or if nothing else, log a warning?
| if (register_notification != nullptr && | ||
| monitor->unregister_notification != nullptr) { |
There was a problem hiding this comment.
Same as above if any of the two function pointers happen to be nullptr, should we then free the object (and at this stage, also the library handle) and return nullptr to the caller?
| psmove_return_if_fail(monitor != nullptr); | ||
|
|
||
| if (monitor->notification != nullptr && | ||
| monitor->unregister_notification != nullptr) { |
There was a problem hiding this comment.
Assuming the above "return nullptr if the unregister_notification function pointer is nullptr" suggestion is implemented, we can further assume here that monitor->unregister_notification != null (and the same below, we can assume that monitor->cfgmgr32 != nullptr).
| @@ -0,0 +1,317 @@ | |||
| /** | |||
| * PS Move API - An interface for the PS Move Motion Controller | |||
| * Copyright (c) 2012 Thomas Perl <m@thp.io> | |||
There was a problem hiding this comment.
Feel free to add 2026 + Aaron Angert here, as you are the author of this file.
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