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: MALA pre- and post-command issues  (Read 4444 times)

0 Members and 1 Guest are viewing this topic.

bsweet0us

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:December 18, 2020, 09:59:46 am
MALA pre- and post-command issues
« on: February 07, 2009, 10:28:59 am »
So I've got MALA set up the way I want and FINALLY got a N64-to-USB cable for my N64 joysticks.  Now for the problem I'm having.

I downloaded JoyToKey to map the "trigger" on the bottom of the joystick to "ESC" to quit FCEUltra, ZSNES and Fusion as that button won't be used for those apps.  I've got JoyToKey configured to use the digital thumbpad for NES, SNES and Genesis games and the buttons configured the way I want so I need to load that program as a pre-command in MALA.  I browsed to the executable for JoyToKey in the pre-command field and it does in fact launch JoyToKey.  However, MALA seems to stop loading and the generic MALA "loading..." screen stays on the display until I press select ("1") for a second time.  The game then loads and the controller works as it should.  Upon exiting the game back to MALA (with the trigger or "ESC"via the keyboard), the game launches again and the controller does not respond.  (I'm assuming this is because the JoyToKey program was killed via the post-command...see below).

I'm currently using the command "tskill joytokey" since I'm running XP Home.  Is that the most effective way to exit an app that launches before a game is started?  I wouldn't have to stop and restart JoyToKey each time, but I obviously don't want the trigger mapped to "ESC" when in Project64.  That being said, how would I go about loading a different config with the pre-command function in MALA?  Is it even possible?

Any suggestions from the brilliant minds that frequent these forums?

Thanks in advance for any help you can provide! 
« Last Edit: February 07, 2009, 02:22:08 pm by bsweet0us »

g00ber

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 22
  • Last login:June 09, 2009, 02:39:39 pm
Re: MALA pre- and post-command issues
« Reply #1 on: February 09, 2009, 11:03:36 am »
Not sure if I can solve your problem, but a workaround may be to use a tool called 'AutoHotKey'. (http://www.autohotkey.com/)

Basically, what you can do is set up a memory resident program to launch your 'Joy2Key' upon launching of your emulator.  The code you would need to set up to run would be to use the 'IfWinActive' / 'IfWinNotActive' functions so that when it detects a program running, it runs the joy2key software to reprogram the keys.

http://www.autohotkey.com/docs/commands/IfWinActive.htm

The code would look something like this:

Loop
{
   IfWinActive, FCEUX   ;NES emulator for example  (replace FCEUX with whatever program you are running (has to be the name in the title bar))
   {
       Run c:\...\...\joy2key   ;replace with the path and options for your program to change keys
   }
   IfWinNotActive, FCEUX
   {
      Run c:\...\...\joy2key   ;replace with path and options for your program to revert changes when returning to mala
   }
}

« Last Edit: February 09, 2009, 09:28:17 pm by g00ber »

bsweet0us

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 42
  • Last login:December 18, 2020, 09:59:46 am
Re: MALA pre- and post-command issues
« Reply #2 on: February 11, 2009, 08:03:47 am »
Not sure if I can solve your problem, but a workaround may be to use a tool called 'AutoHotKey'. (http://www.autohotkey.com/)

Basically, what you can do is set up a memory resident program to launch your 'Joy2Key' upon launching of your emulator.  The code you would need to set up to run would be to use the 'IfWinActive' / 'IfWinNotActive' functions so that when it detects a program running, it runs the joy2key software to reprogram the keys.

http://www.autohotkey.com/docs/commands/IfWinActive.htm

The code would look something like this:

Loop
{
   IfWinActive, FCEUX   ;NES emulator for example  (replace FCEUX with whatever program you are running (has to be the name in the title bar))
   {
       Run c:\...\...\joy2key   ;replace with the path and options for your program to change keys
   }
   IfWinNotActive, FCEUX
   {
      Run c:\...\...\joy2key   ;replace with path and options for your program to revert changes when returning to mala
   }
}



Thanks for the advice...with a little tweaking to the code you provided I got it working efficiently enough for my tastes.  For those interested, here's what the problem I initially encountered was and how I worked around it.

The "loop" command is needed to keep AHK open, but with the script provided the computer is always going to be in one state or the other (the window referred by IfWinActive and IfWinNotActive will ALWAYS be active or not active) so that part of the script would continuously run due to the "loop" function.

To remedy, I wrote the following in (bolded)

Loop
{
   IfWinActive, FCEUX   ;NES emulator for example  (replace FCEUX with whatever program you are running (has to be the name in the title bar))
   {
       Run c:\...\...\joy2key   ;replace with the path and options for your program to change keys
WinWaitClose, FCEUX   ;waits for the emulator window to close before continuing the script
run tskill joytokey    ;exits the Joy2Key application as it is minimized in the system tray, so can't simply close the window (tskill only on Windows 2000, XP and Vista, I think)
   }
   IfWinNotActive, FCEUX
   {
      WinWait, FCEUX   ;halts the script until the emulator window is opened again
reload    ;launches the script from the beginning
   }
}

I am not remotely good at this, but this seems to work well enough.  Couple of quick screen flashes as it launches Joy2Key and kills it, but that's an acceptable exchange for being able to exit my NES, SNES and Genesis emulators with the trigger on the N64 pad!

BTW, if anyone can help with the initial pre-command and post-command problem, I'd be interested in utilizing that route simple for aesthetic purposes.

Thanks again g00ber!

g00ber

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 22
  • Last login:June 09, 2009, 02:39:39 pm
Re: MALA pre- and post-command issues
« Reply #3 on: February 11, 2009, 12:42:25 pm »
Glad I could help.  It's come in handy for me a few times already.

I set up a couple scripts so that I could control main volume via my arcade controls, and also one for sending an ESC key on loading an emulator to put it to full screen.  The options with AutoHotKey are pretty much endless. :)