Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/footswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ void usage() {
}

void init_pid(unsigned short vid, unsigned short pid) {
#ifdef OSX
hid_init();
dev = hid_open(vid, pid, NULL);
#else
struct hid_device_info *info = NULL, *ptr = NULL;
hid_init();
// Config protocol is on interface 1. Interface 0 is the keyboard, which
// macOS won't open, so we can't just hid_open() by vid/pid here.
info = hid_enumerate(vid, pid);
ptr = info;
while (ptr != NULL) {
Expand All @@ -89,6 +87,12 @@ void init_pid(unsigned short vid, unsigned short pid) {
ptr = ptr->next;
}
hid_free_enumeration(info);
#ifdef OSX
// Older hidapi (<0.14) doesn't report interface_number on macOS, so the
// loop finds nothing -- fall back to opening by vid/pid.
if (dev == NULL) {
dev = hid_open(vid, pid, NULL);
}
#endif
}

Expand Down
Loading