Skip to content

Add gesture button feature (similar to Logitech MX Master's Gesture button) - #1046

Merged
lujjjh merged 6 commits into
linearmouse:mainfrom
sakai-kenji:feature/gesture-button
Dec 27, 2025
Merged

lujjjh merged 6 commits into
linearmouse:mainfrom
sakai-kenji:feature/gesture-button

Conversation

@sakai-kenji

Copy link
Copy Markdown

Adds a gesture button feature similar to Logitech MX Master 3's gesture button. Users can hold a mouse button (only scroll wheel implemented) while dragging to trigger macOS gestures like Mission Control, space switching, etc.

Changes

  • New gesture button configuration UI in Buttons settings
  • Configurable threshold and swipe actions for four directions
  • Auto-hides for trackpads (mouse-only)
  • Supports: Mission Control, App Exposé, Show Desktop, Launchpad, space navigation

Testing

  1. Enable gesture button in settings and select a button (middle button)
  2. Configure actions for each swipe direction
  3. Hold the button and drag to trigger gestures
  4. Adjust threshold if needed

Thanks for maintaining this project!

Sakai Kenji added 5 commits December 16, 2025 12:28
Implement a configurable gesture button that allows users to press and hold a button (default: middle/scroll wheel) and drag the mouse to trigger macOS gestures. This provides MX Master-like gesture functionality.
@lujjjh

lujjjh commented Dec 27, 2025

Copy link
Copy Markdown
Collaborator

Thanks for the PR! Just saw it — I’ll pull and test soon.

@lujjjh lujjjh added the enhancement New feature or request label Dec 27, 2025
@lujjjh
lujjjh requested a review from Copilot December 27, 2025 12:49

Copilot AI left a comment

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.

Pull request overview

This PR adds a gesture button feature similar to Logitech MX Master 3's gesture button, allowing users to hold a mouse button (currently middle button/scroll wheel) while dragging to trigger macOS gestures like Mission Control, space switching, and more.

Key Changes

  • New gesture button UI in ButtonsSettings with configurable threshold and directional swipe actions
  • State machine-based event transformer to track button press, drag, and gesture detection
  • Auto-hides for trackpad devices (mouse-only feature)

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
GestureButtonSection.swift New UI component for gesture button configuration with toggle, button picker, threshold slider, and action pickers
GestureActionPicker.swift Reusable picker component for selecting gesture actions (Mission Control, App Exposé, etc.)
ButtonsSettingsState.swift Adds computed properties for gesture configuration state management with defaults
Gesture.swift New data model defining gesture configuration structure and available actions
Buttons.swift Integrates gesture configuration into buttons schema with merge logic
GestureButtonTransformer.swift Core event transformer with state machine for gesture detection and execution
EventTransformerManager.swift Integrates GestureButtonTransformer into the event transformation pipeline
Configuration.d.ts TypeScript documentation for gesture configuration schema
Localizable.xcstrings Localization entries for new UI strings

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

Comment on lines +133 to +135
// Check for timeout (3 seconds)
let elapsed = DispatchTime.now().uptimeNanoseconds - startTime
if elapsed > 3_000_000_000 {

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

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

Magic number for timeout. The timeout value of 3_000_000_000 nanoseconds (3 seconds) is hardcoded in the gesture tracking logic. Consider extracting this as a named constant (e.g., private let gestureTimeoutNanos: UInt64 = 3_000_000_000) or making it configurable through the Gesture configuration to improve maintainability and allow users to adjust the timeout if needed.

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +152
state = .triggered

// Enter cooldown
let cooldownNanos = UInt64(cooldownMs) * 1_000_000
state = .cooldown(until: DispatchTime.now().uptimeNanoseconds + cooldownNanos)

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

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

The state is being set twice in the gesture trigger flow. Line 148 sets the state to .triggered, then immediately on line 152, it's overwritten to .cooldown. The .triggered state assignment is redundant and should be removed since the cooldown state should be set directly after executing the gesture.

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +171
deadZone: Double(gesture.deadZone ?? 40),
cooldownMs: gesture.cooldownMs ?? 500,

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

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

The deadZone and cooldownMs parameters are hardcoded in the EventTransformerManager (lines 170, 171) with default values of 40 and 500 respectively, but these configuration options are defined in the Gesture model and documented in Configuration.d.ts. Consider adding UI controls for these parameters in GestureButtonSection, or if they're intentionally hidden from the UI, add a comment explaining why these advanced parameters are not exposed to users.

Copilot uses AI. Check for mistakes.
@lujjjh
lujjjh merged commit 0a1f387 into linearmouse:main Dec 27, 2025
@lujjjh

lujjjh commented Dec 27, 2025

Copy link
Copy Markdown
Collaborator

Thanks!

@lujjjh lujjjh linked an issue Apr 16, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hold middle mouse button and drag for spaces swap

3 participants