Add mouse support

As promised, here's mouse support rebased against this branch.