Closed ghost closed 7 years ago
Lisp bindings? You're the man.
How would you feel about, instead of the code you've proposed here, accessor functions for struct monome_event
?
E.g. int monome_event_get_grid(const struct *monome_event, int *out_x, int *out_y);
Is that any easier to bind to?
accessor functions will achieve the same goal. Probably I will wrap the bare FFI in something more 'lispy' so doesn't matter much whether extra cruft lies in the first lisp layer or the underlying driver. So I will send a different pull with those wrapper functions at some point...
Please do, I'm excited to see what you're building.
I started writing common lisp bindings to libmonome: https://github.com/rick-monster/cl-monome ... but defining callbacks in common lisp which have to dig into C structs can be a huge pain and it's annoying to add unnecessary C glue code to my bindings. So I bolted on something to libmonome which allows to define button callbacks with a simpler coordinate signature:
https://github.com/rick-monster/libmonome/blob/master/public/monome.h#L58
This makes it very easy to define callbacks from common lisp: https://github.com/rick-monster/cl-monome/blob/master/cl-monome.lisp#L77
and keeps the binding simple, without needing to build in a load of knowledge about the underlying data structures in libmonome. I also modified simple.c to hint the alternative callback mechanism:
https://github.com/rick-monster/libmonome/blob/master/examples/simple.c#L42
Hopefully this addition makes some sense in a broader context!