#include #include #include #include #include #include #include #include "xtools.h" #include "mame.h" Window mame_start(Display *dpy) { if ( fork() == 0 ) { /* Start mame */ if ( execlp("xmame", "xmame", "-rp", "/home/glibersat/Dev/pacman/", "mspacman.zip", "-skip_gameinfo", (char*)NULL) < 0 ) { perror("Couldn't start MAME"); exit(1); } } else { /* Get mame XID */ printf("DEBUG: FIXME: Sync is bad!\n"); sleep(1); Window wid = x_wname_to_wid(dpy, RootWindow(dpy, DefaultScreen(dpy)), "xmame"); if ( wid <= 0 ) { printf("Unable to get MAME XID, exiting\n"); exit(1); } return wid; } } /** * Make MAME load a state by simulating user's input */ void mame_state_load(Display *dpy, Window wid, mame_save_state_t state) { x_send_pushkey(dpy, wid, XK_o); x_send_pushkey(dpy, wid, XK_k); x_send_pushkey(dpy, wid, XK_F7); x_send_pushkey(dpy, wid, state); x_send_pushkey(dpy, wid, XK_p); } /** * Pause/Unpause MAME */ void mame_pause_toggle(Display *dpy, Window wid) { x_send_pushkey(dpy, wid, XK_p); }