switch to hidapi for better cross-platform support
I'm using my Apex 50% of the time on a Mac and its not possible to get raw access for libusb to HID devices. The Mac's HID driver makes an exclusive claim to them.
however, sending HID reports via hidapi is doable. I'm attempt to prototype the enable macro command in python, but I'd suggest using haskell-hidapi in this script to port the existing functionality. I'd send a patch myself if I could, but Haskell escapes my imperative brain ;-|
This might actually be worth looking into, because right now starting ApexCtl causes a driver detach in linux, which registers as a device unplug/plug, which doesn't feel 'clean'.
After quickly glancing over haskell-hidapi, it seems that this library has everything that is necessary to reimplement ApexCtl using hidapi.
sweet!
OTOH, here's all i got so far for python, it just segfaults the hidapi hook-driver. Did I misinterpret what ApexCtl sends to enable the macro keys?
#!/usr/bin/env python
import hidapi #https://github.com/jbaiter/hidapi-cffi
hid = hidapi.Device([d for d in hidapi.enumerate(0x1038, 0x1202)][0]) #get 1st steelseries apex keyboard. 0x1200 is RAW version.
bs_enable = [0x02, 0x00, 0x02] #https://github.com/tuxmark5/ApexCtl/blob/master/src/Main.hs#L43 - command to enable all macro keys
dat_enable = str(bytearray(bs_enable)).ljust(32,"\x00") #stringify and pad to 32 bytes
hid.send_feature_report(data=dat_enable,report_id="\x09")
It seems that you interpreted ApexCtl's behavior correctly and as far as I can tell there is nothing wrong with your script. Just make sure that you are invoking the python bindings of hidapi correctly.