Skip to content

Commit d890178

Browse files
Merge pull request #16 from StrangeRanger/dev
Fix detection of external HID mice with hidutil
2 parents 4dfd38d + 18b7de7 commit d890178

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1010

1111
### Changed
1212

13-
- Updated `mouse-monitor.scpt` to detect any connected HID mouse instead of matching a single configured USB product ID, allowing LinearMouse to launch for mice from any manufacturer.
13+
- Updated `mouse-monitor.scpt` to detect any connected external HID mouse with `hidutil list` instead of matching a single configured USB product ID, allowing LinearMouse to launch for mice from any manufacturer, including receivers connected through USB hubs or dongles.
1414

1515
### Fixed
1616

agent-scripts/mouse-monitor.scpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
-- Note:
55
-- This checks the HID usage values for a mouse instead of matching a specific vendor or
66
-- product ID, so it works across mouse manufacturers.
7+
-- Built-in pointing devices are ignored so this only reacts to a connected external mouse.
78

89
-- Path to your LaunchAgent.
910
set agentPlist to (do shell script "printf %s \"$HOME\"") & "/Library/LaunchAgents/local.StrangeRanger.MouseMonitor.plist"
1011
-- The shell command and app info.
11-
set mouseDetectionCommand to "ioreg -r -c IOHIDDevice -l | awk '/DeviceUsagePage/ && / = 1/ { page=1 } /DeviceUsage/ && !/DeviceUsagePage/ && / = 2/ { usage=1 } /^[ |]*\\+-o / { if (page && usage) found=1; page=0; usage=0 } END { if (page && usage) found=1; print found ? \"1\" : \"0\" }'"
12+
set mouseDetectionCommand to "hidutil list | awk 'NR > 2 && $4 == 1 && $5 == 2 && $NF == 0 { found=1 } END { print found ? \"1\" : \"0\" }'"
1213
set appName to "LinearMouse"
1314
set appPath to "/Applications/LinearMouse.app"
1415

0 commit comments

Comments
 (0)