Fix intermittent "Cannot find footswitch" on macOS#106
Merged
Conversation
On macOS the device was opened with hid_open(vid, pid, NULL), which opens whichever HID interface hidapi enumerates first. The pedal is a composite device: interface 0 is the keyboard (which macOS refuses to let an unprivileged process open) and interface 1 carries the config protocol. When the keyboard interface enumerated first, the open was denied and the tool printed "Cannot find footswitch ..." -- intermittently, until a reboot reshuffled the enumeration order. Select interface 1 explicitly on all platforms, which is what the non-OSX path already did. Keep a macOS-only fallback to hid_open() for older hidapi (<0.14) that doesn't report interface_number on macOS, so existing setups keep working. Tested on macOS 26.4.1 (arm64) with hidapi 0.15.0: footswitch -r now reads reliably across unplug/replug cycles that previously triggered the failure.
titan550
marked this pull request as ready for review
June 24, 2026 07:07
rgerganov
approved these changes
Jun 24, 2026
rgerganov
left a comment
Owner
There was a problem hiding this comment.
I am not able to this on a MacOS device at the moment but the root cause analysis sounds reasonable and the patch looks good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human Note
I kept getting this error randomly even when the USB pedal was plugged in.
This patch fixed the issue for me.
Problem
On macOS,
footswitchintermittently fails with:even though the device is connected and visible to the system (
ioreg/hidutilboth show it). A reboot "fixes" it for a while, then it comes back.Root cause
The macOS branch of
init_pid()opened the device withhid_open(vid, pid, NULL), which opens whichever HID interface hidapienumerates first. The pedal is a composite device:
unprivileged process open (
IOHIDDeviceOpenreturnskIOReturnNotPermitted,0xE00002E2)hidapi's macOS enumeration order isn't stable, so when interface 0 came
first,
hid_open()tried it, was denied, and returnedNULL→ "Cannot findfootswitch". A reboot just reshuffled the order, which is why the failure
seemed to come and go.
Fix
Use the
interface_number == 1selection that the non-OSX path already used,for all platforms. A macOS-only fallback to the previous
hid_open(vid, pid, NULL)is kept for older hidapi (<0.14) that doesn'treport
interface_numberon macOS, so existing setups are unaffected.Testing
footswitch -rnow readsreliably, including across unplug/replug cycles that previously triggered
the failure.
make,-Wall).#ifdef OSX, and the libusbbackend has always reported
interface_number.Notes
scythe.c,scythe2.c, andfootswitch1p.cuse the same barehid_open()pattern and likely share this latent issue on composite devices (possibly
related to #60). Left out to keep this PR focused — happy to follow up.