OK, so here is my second try at some patches. These mostly implement keyboard action mapping and there's plenty of tests to go together with it. I believe the keyboard part is pretty much done, as is SetActionMap. Of course I'm ignoring the username strings and all the device ownership part, I'll leave that for later.
As before I'll leave the patches here to get some feedback before I try to commit.
Cheers