This is a little late, so you may not want to get into it, but I once hacked firmata a little, so that it could read an encoder. I'll attach it.

Collin