Hi Everyone,
A design feature of my machine is that I wanted a single key for Pause/Escape. I found info on getting Autohotkey working with Mame and all sorts of old information about recompiling Mame, etc.. What I did not find was something current that worked. I adapted the script I found (with credit to the original author) and made a few changes.
Here is what I have working:
Bigbox 8.3
Mame 0.199
LedBlinky 6.5.0.1
Autohotkey 1.1.26.01
Windows 10
i.e. All very current stuff.
Here's what happens:
When in Bigbox - the Pause/Exit key is mapped to Escape and is RED.
When Mame loads - the key is turned to Orange and it is a Pause key...
Unless you hold it for 1.6 seconds, at that point it turns RED and sends an Escape to Mame exiting the game..
To use it - you really need to do a few things:
Set the Escape key to Red in the Front End panel in LEDBlinky so that its always RED when using BigBox
Put the AHK script in the Platform / Autohotkey script tab in Bigbox (which makes things easier actually)
keyboardprovider IN mame.ini MUST BE SET TO dinput
Then be able to interpret some of the documentation in the script and set things up..
I've been messing with this off and on for a while now and finally got to the point where I focused on it enough to get it all working. I may go back and see if I can make it even a bit more efficient - I had to learn some Autohotkey as part of this so it may not be as clean as it could be..
There is a fair amount of interaction between all of the pieces - but it works.. My Pause/Escape button changes functionality and color depending on the context its in..
Hope I save others out there some time..
*****************************************************************************************************************
#NoEnv ;Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ;Enable warnings to assist with detecting common errors.
#SingleInstance force
SendMode Event ;Works with Mame! Sendmode Input does not seem to work in Mame
SetWorkingDir %A_ScriptDir% ;Ensures a consistent starting directory.
SetKeyDelay -1,110 ;For Mame to get the inputs
/*
ORIGINAL AUTHOR: WXFORECASTER 10/12/10
DESCRIPTION: DESIGN OVERRIDE SUCH THAT A SINGLE KEY PRESS AND KEY HOLD
GENERATE DIFFERENT FUNCTIONALITY
Updated: 7/31/18 - Bob Perkins - customized for MAME and my environment
V2.0
*/
/*
BEGIN HOLDESCAPE CODE
SET USER DEFINED VARIABLES BELOW
FOR MAME TO ACCEPT AHK SCRIPTS keyboardprovider IN mame.ini MUST BE SET TO dinput!
*/
timeToExit := 1.6 ;time in seconds key must be pressed before sending exit (this can be a decimal e.g. 1.5)
pauseKey := "p" ;your MAME pause key. If using letter, be sure to put in quotes (e.g. "n")
exitKey := "Esc" ;your MAME exit key. If using letter, be sure to put in quotes (e.g. "n")
exitScript := 0 ;0= leave script running, 1= close script when the MAME exit key is fired
/*
LEDBLINKY SPECIFIC SETTINGS
PAUSE_EXIT is the name of the dual purpose key set in GenLEDBlinkyInputMap.exe
*/
LedBlinkyexe := "C:\Users\Arcade Machine\Lakeside_Arcade_Software\LEDBlinky\Ledblinky.exe" ;Full path to Ledblinky
Led_Red := "PAUSE_EXIT`,R`,48|PAUSE_EXIT`,G`,0" ;Comma's need to be escaped!
Led_Orange := "PAUSE_EXIT`,R`,48|PAUSE_EXIT`,G`,24" ;Comma's need to be escaped!
;Make it so the following code only works if MAME is the active window
#IfWinActive ahk_class MAME
{
;Establish Hotkey Mapping based on the emulate key above and trigger a chunk of code below (lblPauseExit)
LedBlinkySet(Led_Orange) ;Make the Pause key Orange
Hotkey, $%exitKey%, lblPauseExit
}
return
lblPauseExit:
KeyWait %exitKey%, T%timeToExit%
if ErrorLevel = 1 ;timeout was reached...exit MAME
{
send {Blind} {%exitKey% downtemp} ;Send MAME Exit
send {Blind} {%exitKey% up}
LedBlinkySet(Led_Red)
if (exitScript = 1)
ExitApp
}
else
{
send {Blind} {%pauseKey% downtemp} ;Send MAME pause/unpause
send {Blind} {%pauseKey% up}
LedBlinkySet(Led_Orange)
}
return
LedBlinkySet(MyColor)
{
Global LedBlinkyexe
Run "%LedBlinkyexe%" "14" "%MyColor%" ;LedBlinky expects 2 parameters 14=light LED
}
***************************************************************************************