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
Lightguns Arcade1Up Try the site in https mode Site News

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

  

Author Topic: Possible to get joystick mode of game from command line?  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

wrybreadsf

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 23
  • Last login:January 05, 2024, 11:25:02 pm
  • I want to build my own arcade controls!
Possible to get joystick mode of game from command line?
« on: April 04, 2018, 05:14:03 pm »
I'm trying to find out if a game uses a 4-way or 8-way joystick from command line. The front end I'm using (Attract Mode) has lines in its romlist files, so if all else fails I can get it from that. The lines look like this:

mrtnt;Mr. TNT;mame;;1983;Techstar (Telko license);;2;90;joystick (4-way),joystick (4-way);good;1;raster;;;;
mspacmat;Ms. Pac Attack;mame;mspacman;1981;hack;;2;90;joystick (4-way),joystick (4-way);good;1;raster;mspacman;;;
mspacman;Ms. Pac-Man;mame;;1981;Midway / General Computer Corporation;;2;90;joystick (4-way),joystick (4-way);good;1;raster;;;;
mspacmab;Ms. Pac-Man (bootleg);mame;mspacman;1981;bootleg;;2;90;joystick (4-way),joystick (4-way);good;1;raster;mspacman;;;
mspacmbe;Ms. Pac-Man (bootleg, encrypted);mame;mspacman;1981;bootleg;;2;90;joystick (4-way),joystick (4-way);good;1;raster;mspacman;;;
mspacmnf;Ms. Pac-Man (fast!);mame;mspacman;1981;hack;;2;90;joystick (4-way),joystick (4-way);good;1;raster;mspacman;;;

But I'm wondering if there's some way to query the ROM from commandline to get this info? I've been looking through the manual and google for awhile now and don't see it. Apologies if it's obvious and I missed something.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19399
  • Last login:March 16, 2024, 05:59:16 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Possible to get joystick mode of game from command line?
« Reply #1 on: April 04, 2018, 11:30:13 pm »
The closest you can do is "mame.exe -lx rom" where rom is the romname for the game in question.  That'll give you the entire list xml entry for the game though, not just control info.  Of course controls.dat is more suited for this kind of thing, but it's sadly outdated an imcomplete. 

ZoOl007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 161
  • Last login:August 02, 2020, 12:03:38 pm
    • RGBcommander
Re: Possible to get joystick mode of game from command line?
« Reply #2 on: April 05, 2018, 03:41:27 am »
Hi your best bet on windows is to use powershell to pipe (eg the | ) the output of the command above
mame.exe -lx dkong | regexLikePowerShellThingHere

regex
(?<=ways=")(.*)(?="\/\>)
yields output
4
with this input
<control type="joy" player="1" buttons="1" ways="4"/> 

wrybreadsf

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 23
  • Last login:January 05, 2024, 11:25:02 pm
  • I want to build my own arcade controls!
Re: Possible to get joystick mode of game from command line?
« Reply #3 on: April 05, 2018, 03:43:16 pm »
Awesome and thanks!

For those on Linux or (I think) Mac:

./mame -lx dkong | grep -oP -m 1 '(?<=ways=")(.*)(?="\/\>)'

(This outputs "4")

Note the -P flag, which tells grep that it's a Perl Regex. That little detail got me pretty confused.

The -o flag tells grep to just show the found text, as opposed to the entire line.

And the -m 1 tells it to just show the first result. Otherwise it'll show each player's joystick orientation which, I think, is always the same.

Can also make a bash script called joystick.sh or whatever:

Code: [Select]
#!/bin/bash

rom=$1

mame -lx $rom | grep -oP -m 1 '(?<=ways=")(.*)(?="\/\>)'

joystick.sh shinobi

(outputs "8")

Other options:

Code: [Select]
(?<=ways=")\d+
(?<=ways=")[^"]
« Last Edit: April 05, 2018, 05:21:49 pm by wrybreadsf »

nexusmtz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 489
  • Last login:June 01, 2022, 03:14:22 am
Re: Possible to get joystick mode of game from command line?
« Reply #4 on: April 06, 2018, 05:11:04 am »
Hi your best bet on windows is to use powershell to pipe (eg the | ) the output of the command above
mame.exe -lx dkong | regexLikePowerShellThingHere

regex
(?<=ways=")(.*)(?="\/\>)
yields output
4
with this input
<control type="joy" player="1" buttons="1" ways="4"/>
I know it's moot for Wry, but in case someone else wants to do this in powershell the regex way, it's:
Code: [Select]
(.\mame64.exe -lx dkong | select-string '(?<=ways=")(.*)(?="\/\>)').matches[0].value
But to use powershell's xml abilities, it would be:
Code: [Select]
([xml](.\mame64.exe -lx dkong)).mame.machine.input.control.ways[0]
The second method won't get thrown off if 'ways' appears under something other than 'control'.