Skip to content

Implement hs.mouse. Closes #129#146

Merged
cmsj merged 2 commits into
mainfrom
hs.mouse
Jul 23, 2026
Merged

Implement hs.mouse. Closes #129#146
cmsj merged 2 commits into
mainfrom
hs.mouse

Conversation

@cmsj

@cmsj cmsj commented Jul 23, 2026

Copy link
Copy Markdown
Owner

No description provided.

@cmsj cmsj self-assigned this Jul 23, 2026
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Implements the new hs.mouse JavaScript module.

  • Registers hs.mouse with the module root and test harness.
  • Adds pointer positioning, screen lookup, device enumeration, tracking-speed, scrolling-direction, and cursor-type APIs.
  • Adds JavaScriptCore integration tests and regenerated API/TypeScript documentation.

Confidence Score: 4/5

The tracking-speed input validation defect should be fixed before merging because user scripts can persist unsupported mouse acceleration values.

The module is wired consistently with existing JavaScriptCore modules, but setTrackingSpeed forwards and persists every bridged Double despite publicly restricting the value to a finite -1.0 through 3.0 range.

Hammerspoon 2/Modules/hs.mouse/HSMouseModule.swift

Important Files Changed

Filename Overview
Hammerspoon 2/Modules/hs.mouse/HSMouseModule.swift Adds the complete native mouse API; setTrackingSpeed fails to enforce its documented range before changing and persisting system settings.
Hammerspoon 2/Engine/ModuleRoot.swift Correctly registers and lazily exposes the new hs.mouse module.
Hammerspoon 2/Bridging-Header.h Adds narrow wrappers around the deprecated IOKit acceleration APIs used by the module.
Hammerspoon 2Tests/Helpers/JSTestHarness.swift Adds hs.mouse to the harness's manually maintained module-loading switch.
Hammerspoon 2Tests/IntegrationTests/HSMouseIntegrationTests.swift Exercises the JavaScript-visible API shape and basic behavior, but does not cover invalid tracking-speed inputs.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
Hammerspoon 2/Modules/hs.mouse/HSMouseModule.swift:325-337
**Invalid tracking speeds are persisted**

When JavaScript passes a value outside the documented -1.0 through 3.0 range, including NaN or Infinity, the setter forwards it unchanged to IOKit and persists it to `com.apple.mouse.scaling`, causing invalid or inconsistent live and persisted mouse settings.

Reviews (1): Last reviewed commit: "Implement hs.mouse. Closes #129" | Re-trigger Greptile

Comment thread Hammerspoon 2/Modules/hs.mouse/HSMouseModule.swift
@cmsj
cmsj merged commit f184dc5 into main Jul 23, 2026
4 checks passed
@cmsj
cmsj deleted the hs.mouse branch July 23, 2026 13:21
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.

1 participant