openyou/emokit — pull request #90 by soltanmm (2013-08-13 03:54:41+00:00)
Title: PIC for x86-64 *nix linking & a non-blocking poll in C API

Two big things:
---

I had problems linking my files against Emokit on my x86-64 machine due to the lack of a position-independent code flag in the build files (it's either this or using wide-addressing, which is... well as far as I've heard, dumb). I added this to the top-level `CMakeLists.txt` using the built-in CMake macro, made available in version 2.8.9. This means that the required CMake version was upped to CMake 2.8.9. If this is a problem it should be fairly easy to add the necessary (messy) if/endif switches to make it work in earlier CMake versions.

I had major major headaches getting emokit's C API to play nicely with threads due to the blocking read if the device was unplugged in the middle of the program running. Every session would end with a segfault because the hanging thread would finally be cut off and not be able to clean up after itself because it hung around longer than any thread should reasonably hang around for. I managed to work around it, but the solution was disgusting and I hated the code. So instead, I added the more elegant solution: a non-blocking poll. I no longer feel like vomiting on my keyboard and I don't think anyone else should feel that way ever. Unless they had the [fish](http://www.youtube.com/watch?v=HA6KGogOrjM) for dinner. Then they can enjoy their food poisoning.

One minor thing:
---

I've removed the Findlibusb-1.0.cmake file. It wasn't being used and it was confusing for me to discern what it was doing there when I initially forked the repository, and therefore t'was culled.

Some notes:
---

I haven't tested this outside of Linux, and I have yet to *ever* use the Python API (because I'm a masochist and love C/C++/D and other evil things). If there's something broken over yonder due to this request, well, erm, I guess I wouldn't feel bad about being called a fool, but please do it with a kind firm tone, as if speaking to your goldfish. Or something.

Thanks~!