Is there a way to monitor the signals an HID (Human Interface) device sends to the OS?
Solution 1:
NSEvent
To monitor input events sent to macOS from Human Interface Devices (HID), look at NSEvent's addGlobalMonitorForEventsMatchingMask:handler:
. This is the method used to associate scripts and tasks to hotkeys by third party macOS tools.
You will likely need to write in Objective-C or Swift and codesign the resulting binary. I expect you will also need to grant the binary additional access rights at runtime – probably in the Accessibility panel of System Preferences > Security & Privacy.
A search on GitHub will provide a few sample projects using this method.