Using a MIDI controller in Tiled

Question

Some programs, such as GIMP can be controlled using a USB MIDI controller.
I was wondering if it is possible to control Tiled in this way?

Background

My usage of tiled is a bit special. I use Tiled as a tactical map for running Dungeons & Dragons. My players connect through VNC and we manipulate the map directly while playing. We talk through Mumble, and I have a bot for rolling dice. The setup is very flexible, and because tiled is so awesome I can quickly draw up a map when needed.

However, it would be even more smooth if I could assign actions to a MIDI controller, for instance controlling layer transparency through a fader. I use layers for lighting effect (night layer with stars, darkness layer, an orange indoor light layer etc), and controlling these with faders would take away some of the stress of having to click around looking for the right layer and control. In addition, rotating objects through a knob, or a fader, would save a lot of clicking.

Alternative solutions

If there is no built in support for MIDI devices, is there some way of controlling tiled through another program (some kind of IPC)? I could then just write a controller script which does the USB communication.

Any other ideas how to achieve this?

If nothing else, where would be a good place in the code for me to start adding MIDI controller support? I’d be willing to put some effort into making a decent patch, at least for myself.