First, you'll need to determine which joystick buttons are player 1 start and button 1. Put this in a .ahk file and run it to figure that out.
; July 6, 2005: Added auto-detection of joystick number.
; May 8, 2005 : Fixed: JoyAxes is no longer queried as a means of
; detecting whether the joystick is connected. Some joysticks are
; gamepads and don't have even a single axis.
; If you want to unconditionally use a specific joystick number, change
; the following value from 0 to the number of the joystick (1-16).
; A value of 0 causes the joystick number to be auto-detected:
JoystickNumber = 0
; END OF CONFIG SECTION. Do not make changes below this point unless
; you wish to alter the basic functionality of the script.
; Auto-detect the joystick number if called for:
if JoystickNumber <= 0
{
Loop 16 ; Query each joystick number to find out which ones exist.
{
GetKeyState, JoyName, %A_Index%JoyName
if JoyName <>
{
JoystickNumber = %A_Index%
break
}
}
if JoystickNumber <= 0
{
MsgBox The system does not appear to have any joysticks.
ExitApp
}
}
#SingleInstance
SetFormat, float, 03 ; Omit decimal point from axis position percentages.
GetKeyState, joy_buttons, %JoystickNumber%JoyButtons
GetKeyState, joy_name, %JoystickNumber%JoyName
GetKeyState, joy_info, %JoystickNumber%JoyInfo
Loop
{
buttons_down =
Loop, %joy_buttons%
{
GetKeyState, joy%a_index%, %JoystickNumber%joy%a_index%
if joy%a_index% = D
buttons_down = %buttons_down%%a_space%%a_index%
}
GetKeyState, joyx, %JoystickNumber%JoyX
axis_info = X%joyx%
GetKeyState, joyy, %JoystickNumber%JoyY
axis_info = %axis_info%%a_space%%a_space%Y%joyy%
IfInString, joy_info, Z
{
GetKeyState, joyz, %JoystickNumber%JoyZ
axis_info = %axis_info%%a_space%%a_space%Z%joyz%
}
IfInString, joy_info, R
{
GetKeyState, joyr, %JoystickNumber%JoyR
axis_info = %axis_info%%a_space%%a_space%R%joyr%
}
IfInString, joy_info, U
{
GetKeyState, joyu, %JoystickNumber%JoyU
axis_info = %axis_info%%a_space%%a_space%U%joyu%
}
IfInString, joy_info, V
{
GetKeyState, joyv, %JoystickNumber%JoyV
axis_info = %axis_info%%a_space%%a_space%V%joyv%
}
IfInString, joy_info, P
{
GetKeyState, joyp, %JoystickNumber%JoyPOV
axis_info = %axis_info%%a_space%%a_space%POV%joyp%
}
ToolTip, %joy_name% (#%JoystickNumber%):`n%axis_info%`nButtons Down: %buttons_down%`n`n(right-click the tray icon to exit)
Sleep, 100
}
return
So let's say player 1 start is Joy1 and player 1 button 1 is Joy2. To have a them send escape when you press them both, you would put this into a script.
$Joy1::
send {Joy1}
GetKeyState, state, Joy2
if state = D
send {esc}
return
If you hold down joy2 and press joy1, it should send escape. Otherwise both keys should function as normal.
As for visual pinball, try a script like this (I'm gonna combine it with the script we've already done.)
setTitleMatchMode, 2
$Joy1::
send {Joy1}
GetKeyState, state, Joy2
if state = D
send {esc}
return
#IfWinActive, visual pinball
joy3::a
joy4::s
joy5::q
This script will remap joy3 to a, joy 4 to s, and joy5 to q, but only in Visual Pinball. Simply modify to meet your needs. Also, the text that comes after "#IfWinActive," needs to be a string of text from the titlebar of the visual pinball window and it is case sensitive. I have no idea if this is correct (it probably isn't) so you'll need to change that as well.
I'm fairly knowledgeable about AHK, so if any of this is unclear, let me know and I'll try to help some more.
