Skip to content

Unified moved_monitor_wait() for moved - #520

Open
thp wants to merge 2 commits into
masterfrom
moved-polling
Open

Unified moved_monitor_wait() for moved#520
thp wants to merge 2 commits into
masterfrom
moved-polling

Conversation

@thp

@thp thp commented Jul 30, 2026

Copy link
Copy Markdown
Owner

A cleanup on top of #519 for unifying monitor waiting between macOS, Linux and Windows.

Tested:

  • Building on Linux locally
  • (+ CI will test building on other OSes)

Not tested:

  • Building on macOS
  • psmove pair -d on any OS
  • psmove daemon on any OS

cc @adangert if you could check if this works for you, that'd be great :)

pfd.fd = monitor_fd;
pfd.events = POLLIN;

return (poll(&pfd, 1, blocking ? -1 : 0) > 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

moved_monitor_get_fd() returns -1, so poll() ignores it. Blocking waits forever and nonblocking always returns false, preventing the CFRunLoop from processing controller events. Could this wait through the CFRunLoop instead?

Comment thread src/daemon/moved.cpp
moved_monitor_free(monitor);
#else
while (true) {
moved.handle_request();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

handle_request() blocks in recvfrom(), so a controller notification alone cannot reach moved_monitor_wait(). Potentially the socket and monitor event could be multiplexed, or the socket made nonblocking, so monitor wakes the daemon without a UDP request?

static_cast<unsigned long>(GetLastError()));
}

return true;

@adangert adangert Jul 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This returns true even when a nonblocking wait returns WAIT_TIMEOUT. Could this return true only for WAIT_OBJECT_0 or a fallback rescan, and false for a nonblocking timeout?

@adangert

Copy link
Copy Markdown
Contributor

Thanks for getting this out, when I boot the pi up again, I can test out with the newest Joustmania on linux (we've upgraded to the newest psmoveapi), and will report back

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.

2 participants