At least in linux, midi devices can be read just like any other character device. It's not a ton of work to read the midi data and translate it to keypresses or whatever else you want.
I used to have a Griffin Powermate and did something similar with it. It was a ton of fun.