Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news


  

Author Topic: How to send MAME a keystroke in Linux?  (Read 459 times)

0 Members and 1 Guest are viewing this topic.

wrybreadsf

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 17
  • I want to build my own arcade controls!
How to send MAME a keystroke in Linux?
« on: April 04, 2018, 01:27:51 am »
I'm working on a "screensaver" python script that automatically cycles through a bunch of MAME roms when my cabinet isn't in use. Each game stays on the screen for X amount of minutes, and if anyone starts playing the game the screensaver script pauses to let the person play. It then kicks in again after X minutes of inactivity. Gets me out of the rut of loading on the same few games every time, and makes the cabinet a bit more dynamic and varied. I can only look at Mr. Do and Ms Pacman so many times, ha.

Everything is working great except when I try to send a keystroke to MAME. For example, to exit a game, I send the ESC key. But for some reason that doesn't work. Ditto with sending mouse clicks. I've tried all sorts of methods but none are working, MAME just ignores the input.

I'm on Linux, Mame 0.175.

I'd also love to send keystrokes to bypass the warning screen (if present). I know I can recompile for that but so far I haven't had any luck compiling.

I don't imagine anyone has any tips?

I've tried pyautogui, xautomator, evdev, subprocess directly, and a few other methods.

Code: [Select]
#!/usr/bin/python



import subprocess, time


# launch a ROM (adjust paths to taste)
   
rom_name = "mrdo"
cmd = "/home/wrybread/.attract/mame/mame -rompath $HOME/.attract/mame/roms -skip_gameinfo -autosave %s" % rom_name
print cmd
p = subprocess.Popen(cmd.split(" "), stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE, stderr=subprocess.STDOUT)


time.sleep(5)


# exit by sending the ESC key via xautomator
p2 = subprocess.Popen(['xte'], stdin=subprocess.PIPE)
p2.communicate(input="key Escape ") # not sure why need space after string



Thenasty

  • Trade Count: (+16)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4196
    • Thenasty's Arcademania Horizontal/Vertical monitor setup.
Re: How to send MAME a keystroke in Linux?
« Reply #1 on: April 04, 2018, 12:13:57 pm »
I don't have a Linux script you looking for but....


Usually a Front End can do that.

I use Advmenu as my FE and it does exactly wjhat you looking for (I'm sure some other FE do it).

https://www.advancemame.it/download



Thenasty's Arcademania Horizontal/Vertical setup.
http://forum.arcadecontrols.com/index.php?topic=26696.0

Free VGA Breakout Cable
http://forum.arcadecontrols.com/index.php?topic=38228.0

Ultimate All in One Coin Mech write up (Make your own)
http://forum.arcadecontrols.com/index.php?topic=19200.0

wrybreadsf

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 17
  • I want to build my own arcade controls!
Re: How to send MAME a keystroke in Linux?
« Reply #2 on: April 04, 2018, 02:15:06 pm »
Interesting. That front end can automatically cycle through games (as opposed to videos of games) after a period of inactivity? And if the user starts playing, it stops cycling and lets a user play?

I'm using Attract Mode currently.

wrybreadsf

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 17
  • I want to build my own arcade controls!
Re: How to send MAME a keystroke in Linux?
« Reply #3 on: April 04, 2018, 04:48:36 pm »
Aha, apparently this is a common issue. Google "mame FORCE_DIRECTINPUT" for lots more info. Here for example:

http://forum.arcadecontrols.com/index.php?topic=92761.0

I've successfully recompiled my MAME version (0.175), but I can't find this FORCE_DIRECTINPUT string. Long shot I know, but does anyone know how to enable directinput in Mame 0.175?

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2942
  • 0x2b|~0x2b?
Re: How to send MAME a keystroke in Linux?
« Reply #4 on: April 06, 2018, 10:06:41 pm »
DirectInput is a Win32 API so it won't help you.

ZoOl007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 134
    • RGBcommander
Re: How to send MAME a keystroke in Linux?
« Reply #5 on: April 07, 2018, 03:50:04 am »
just a thought: I think that the 'keystrokes' are being ignored because the application doesn't have focus.

  
 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31