Skip to content

Fix: Implement device polling for late-connecting multitouch devices …#109

Merged
NullPointerDepressiveDisorder merged 4 commits intomainfrom
bug/bluetooth-support
Feb 16, 2026
Merged

Fix: Implement device polling for late-connecting multitouch devices …#109
NullPointerDepressiveDisorder merged 4 commits intomainfrom
bug/bluetooth-support

Conversation

@NullPointerDepressiveDisorder
Copy link
Owner

This pull request adds robust support for polling and connecting to multitouch devices (such as Bluetooth trackpads) that may not be present at app launch, improving reliability on systems where devices connect after boot or wake. It introduces a device polling mechanism with exponential backoff, user feedback, and comprehensive tests to ensure correct behavior. Additionally, it refines logging and improves safety annotations in the codebase.

Device polling and connection improvements:

  • Added a device polling mechanism in MultitouchManager that periodically checks for newly connected multitouch devices when none are found at launch, using exponential backoff and a maximum timeout. The polling state is exposed via isPollingForDevices, and user actions (such as toggling enabled state) now interact correctly with polling. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Updated AppDelegate to log when the app is polling for device connections, providing clearer feedback to users.

Testing enhancements:

  • Added comprehensive tests in MultitouchManagerTests to verify polling behavior, including starting, stopping, double-start prevention, toggling, and constant values. [1] [2] [3]

Logging and code safety:

  • Improved logging messages for device connection and polling events, and removed unnecessary use of the unsafe string interpolation in logging calls. [1] [2]
  • Applied unsafe annotations to certain Core Graphics function calls and variable accesses in MouseEventGenerator to clarify thread-safety and code intent. [1] [2] [3]…and update UI notifications

Copilot AI review requested due to automatic review settings February 15, 2026 08:59
@NullPointerDepressiveDisorder NullPointerDepressiveDisorder added bug Something isn't working enhancement New feature or request labels Feb 15, 2026
Repository owner deleted a comment from cursor bot Feb 15, 2026
@sentry
Copy link
Contributor

sentry bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
MiddleDrag/Managers/MultitouchManager.swift 92.40% 12 Missing ⚠️
MiddleDrag/UI/MenuBarController.swift 70.58% 10 Missing ⚠️
MiddleDrag/Core/MouseEventGenerator.swift 62.50% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves MiddleDrag’s reliability when multitouch hardware (e.g., Bluetooth trackpads) connects after app launch by adding a device polling/backoff mechanism in MultitouchManager, updating the menu UI to reflect late connections/timeouts, and extending test coverage for the new polling behavior.

Changes:

  • Add device polling with exponential backoff + timeout when no multitouch hardware is available at start/restart, exposing isPollingForDevices and posting UI notifications.
  • Update menu/status messaging and app logging to reflect polling/late connections/timeouts.
  • Add new unit tests for polling state transitions and constants; refine some logging/concurrency annotations.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
MiddleDrag/UI/MenuBarController.swift Observes new device/polling notifications and shows “Waiting for Trackpad…” state in the status menu.
MiddleDrag/MiddleDragTests/MultitouchManagerTests.swift Adds polling-focused unit tests (start/stop/double-start/toggle/constants).
MiddleDrag/Managers/MultitouchManager.swift Implements polling/backoff/timeout flow, exposes polling state, integrates with start/stop/restart/toggle.
MiddleDrag/Core/MouseEventGenerator.swift Adjusts logging calls and adds unsafe annotations for some CoreGraphics interactions/global state.
MiddleDrag/AppDelegate.swift Logs when the app starts in polling mode (no device at launch).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NullPointerDepressiveDisorder NullPointerDepressiveDisorder merged commit 61ff99e into main Feb 16, 2026
6 checks passed
@NullPointerDepressiveDisorder NullPointerDepressiveDisorder deleted the bug/bluetooth-support branch February 16, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MiddleDrag starts disabled after every Mac reboot (likely because I am using a Bluetooth Magic Trackpad)

1 participant

Comments