Somewhat related, a small ruby project of mine to read input events from the linux kernel. https://github.com/rickhull/device_input
The README goes in some depth about kernel events and timestamps and time implementations on 32-bit vs 64-bit systems.