At the moment I'm working on a cabinet build based off Ubuntu Xenial, and trying to make things boot straight into a front end via startx & .xinitrc.
That much works and I get graphics displaying normally on tty1, but I'm having this symptom:
When the machine reaches the front end (Attract Mode) in this case, keystrokes respond normally. Once I open a game (any game), MAME doesn't appear to respond to any keys, including the esc key. The keyboard itself still works, because I can 'CTRL-ALT-F2' to tty2, then sign in and 'kill -9 $(pgrep mame)' to regain control and return to the front end in tty1. For some games (older ones? 'lighter' ones? e.g. dkong) after killing it once like this I can then re-enter via the front end and MAME works normally with all keys behaving. For other games (e.g. donpachi, or its sequels) it still won't respond and needs to be killed from another console, every time.
I've noticed that even in games like donpachi that don't respond to keys, if I hold down PgDn (which is the 'fast forward' key in SDL-based MAME) while opening the game, the top-right corner will show the framerate and percentage of speedup, and then that doesn't drop away when the key is released; the game keeps running (and graphically looking fine) and the fast forward stats keep updating, even though MAME's no longer responding to keystrokes or even apparently aware the fast forwarding should have stopped -- almost like the keyboard is 'freezing', save for the CTRL-ALT console switching.
This happens whether or not there's a front end involved; changing ~/.xinitrc to run a MAME game directly has the same symptoms.
The system is installed on a 1TB USB HDD, and the same problem happens on three separate physical machines when booting from that disk (one AMD video card, one Nvidia, one Intel off the mobo).
The system was originally installed as a regular amd64 desktop, with mame64 successfully compiled on itself. When running mame64 (directly, or via a front end) off a terminal within a normal lightdm/Unity session, it works flawlessly for all games, so presumably there's some magic going on in the dm layer or nearby, that's 'fixing' whatever is wrong or missing when I'm starting x straight off a console.
I did get some advice that led me to suspect the problem was with the user account not being in the 'video' group, but after 'usermod -a -G video emulation' (and rebooting to be sure) nothing improved.
My experience in Linux is nearly all either cli-based server things, or working within a full DE... this middle ground of raw X is scary :\