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: About the pre command  (Read 4880 times)

0 Members and 1 Guest are viewing this topic.

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5158
  • Last login:May 24, 2025, 09:57:44 pm
  • Wheres my coffee?
    • Skenny's Outpost
About the pre command
« on: December 18, 2014, 10:40:49 am »
I wrote a small program that checks if a joystick or game pad is plugged into a usb port.
I first set the emulator (NES emulator: fceux.exe) up to use the keyboard keys (arcade control panel).
Then I copied the fceux.cfg file and renamed the copy "no_joystick_fceux.cfg"
I then opened the emulator and set up NES to use the game pad, then quit the emulator, copied the fceux.cfg file and renamed the copied file to "joystick_fceux.cfg"

When a game is selected in NES emulator, if a gamepad is plugged in, the program copies the "joystick_fceux.cfg" to the fceux.cfg file.
If gamepad is not plugged in, the program copies the "no_joystick_fceux.cfg" to the fceux.cfg file.

So the game starts with either keyboard input or gamepad input setup automatically.

I placed this program into the pre command for NES emulator.
Line I used was C:\arcade\nes\joytest.exe
Joytest is the name of the program.
But it didn't work.
It would work fine if I ran joytest before opening mala.
After much head scratching and searching on here for the possible cause, I tried "CMD C:\arcade\nes\joytest.exe" in the pre command box (minus the quote marks).
This is where I found the problem. The command box popped up and showed that I was still in the C:\arcade\mala path.
So I changed my program to specify the complete path for the cfg files it intends to manipulate.
The program was looking for just the config files. I placed joytest in the nes folder so I figured it would just see them, since it was in the same folder.
That worked when I ran joytest outside of mala, but not when I ran it as a pre command.
So I changed joytest to look for the cfg files in the complete path C:\Arcade\NES\ (config file)
Now it works like a charm!

ToDo list: Polish up the program by letting it get the paths it needs to specify from an ini file, that way the path can be set by user.
Need to also tweak it to work with other emulators.
Also right now it is just looking for gamepad 1, need to handle if gamepad 2 is plugged in or not.

Anyway, the jest of this long post is just to point out that if you use the pre command, just remember that the "behind the scenes path" remains the mala path, so if the program is not in the mala folder, it may not work right.


DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5158
  • Last login:May 24, 2025, 09:57:44 pm
  • Wheres my coffee?
    • Skenny's Outpost
Re: About the pre command
« Reply #1 on: December 22, 2014, 12:04:23 am »
Ive got the above mentioned program finished and I think it works good, for me anyway.
I think drventure wrote a program that may do the same thing, Im not sure.
If anyone wants to test my program, I can post it.
What does it do?
When you start an emulator (nes just for example), from Mala, the precommand runs my program, which I call paddetect, that is located in the emulators folder.
Paddetect checks to see if a game pad is plugged into the usb port, if it is it rewrites the emulators config file to be set up for the gamepad.
If no pad is plugged in, a config file set up for keyboard is written.
This takes a little work on first setup.
You have to open the emulator, go into its setting, and set it up for keyboard (arcade control panel) inputs.
You then close the emulator, copy the config file, then rename the copied config file something like none.cfg
You repeat this process for 1 gamepad plugged in, second gamepad plugged in, or both gamepads plugged in.
You then have to enter the config names in paddetect's settings file.
If anyone is interested I can go deeper into the setup routine. Its really not that hard, just a little time consuming, but once its set up it should be good to go.
This program could work with any front end, as long as the front end allows you to run a program before starting a game.

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:July 18, 2025, 04:23:38 pm
    • My personal forum
Re: About the pre command
« Reply #2 on: January 13, 2015, 04:40:53 am »
It looks interesting!
You could to share it! :-)

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5158
  • Last login:May 24, 2025, 09:57:44 pm
  • Wheres my coffee?
    • Skenny's Outpost
Re: About the pre command
« Reply #3 on: January 13, 2015, 02:20:00 pm »
Ok, here it is.
Unzip it to paddetect.exe
You will have to place a copy of this program in each of your emulator folders. (Emuls that use the usb gamepads).
Here is the time consuming part:
Then go into each emulator and set it up for 1 gamepade plugged in (after you plug in one game pad), and set up player 1 for the gamepad.
Set up player two for the keyboard (arcade cp) controls.
Exit emul, rename the config file to p1& the config file name.
Repeat with the other game pad set up for player 2 and player 1 for keyboard.
Exit, rename config to P2&config name.
Repeat for both. (P1=gamepad and P2=gamepad) rename to both & config name.
Repeat for neither. (P1 and P2 set up for keyboard) rename to neither & config name.

Now run paddetect so that a paddetect.set file is created. Open the set file with notepad and enter the names of the renamed config files.
Now point the precommand in Mala to the paddetect.exe file for each emulator. (Precommand must point to the paddetect in the folder for that particular emulator.)

When Mala opens the emulator, paddetect is run first, Paddect looks to see what if any game pads are plugged in, then rewrites the emulators config file appropriately.
I have used this successfully on NES (FCEUX) and SNES.
I have found on SNES that there is a input.cfg (not the config file) that needs the modifications. (Not sure what emulator this is, I just put this on my nephews arcade machine and will need to get more info.)
I can post some examples of my setups, if needed.
Welcome all comments and any bug fixes or suggestions.


empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:July 18, 2025, 04:23:38 pm
    • My personal forum
Re: About the pre command
« Reply #4 on: January 14, 2015, 01:57:40 am »
Thanks!
I'll take a look when I have just time!
Btw, in what language is it programmed?

Thanks!

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5158
  • Last login:May 24, 2025, 09:57:44 pm
  • Wheres my coffee?
    • Skenny's Outpost
Re: About the pre command
« Reply #5 on: January 14, 2015, 01:59:32 am »
Thanks!
I'll take a look when I have just time!
Btw, in what language is it programmed?

Thanks!

VB6.

DaOld Man

  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5158
  • Last login:May 24, 2025, 09:57:44 pm
  • Wheres my coffee?
    • Skenny's Outpost
Re: About the pre command
« Reply #6 on: January 23, 2015, 09:56:55 pm »
Hey there empardopo, get a chance to check out paddetect yet?

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:July 18, 2025, 04:23:38 pm
    • My personal forum
Re: About the pre command
« Reply #7 on: January 26, 2015, 05:10:56 am »
I have not had time to test it yet but I have it on my to-do list ...