Ugh. Well I somewhat understand the code you've written Chris. The directional button works so thanks for that. I'm trying to expand the code to get buttons 1 - 8 and one of the two joysticks on my Recoil gamepad to work with the game Area-51. Here's a link to the pad that I'm have
http://www.gemini-usa.com/a5/modelDetai ... =GemGaming
So I'm starting with button 6 or rather joy6 but I can't get it to work. What am I doing wrong here. Can someone help me here.
Code:
#Persistent
SetTimer, WatchPOV, 5
return
; The "GetKeyState" checks if a keyboard key or mouse/joystick button
; is down or up. Also retrieves joystick status.
; GetKeyState, OutputVar, KeyName [, Mode]
WatchPOV:
GetKeyState, POV, JoyPOV ; Get position of the POV control.
Key1ToHoldDownPrev = %Key1ToHoldDown%
Key2ToHoldDownPrev = %Key2ToHoldDown%
; Each "Prev" variable now holds the key that was down before (if any).
GetKeyState, PadButton6, Joy6 ; Get postion of button 6 on the gamepad
PadKey6ToHoldDownPrev = %PadKey6ToHoldDown%
; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, check for ranges:
if POV < 0 ; No angle to report
{
Key1ToHoldDown =
Key2ToHoldDown =
}
else if POV > 33750 ; 337.5 to 360 degrees: Forward
{ ; move forward
Key1ToHoldDown = w
Key2ToHoldDown =
}
else if POV between 0 and 2250 ; 0 to 22.5 degrees: Forward
{ ; move forward
Key1ToHoldDown = w
Key2ToHoldDown =
}
else if POV between 2251 and 6750 ; Up+Right
{ ; move forward & strafe right
Key1ToHoldDown = w
Key2ToHoldDown = d
}
else if POV between 6751 and 11250 ; Right
{ ; strafe right
Key1ToHoldDown =
Key2ToHoldDown = d
}
else if POV between 11251 and 15750 ; Down+Right
{ ; lean right
Key1ToHoldDown = e
Key2ToHoldDown =
}
else if POV between 15751 and 20250 ; Down
{ ; move backwards
Key1ToHoldDown = s
Key2ToHoldDown =
}
else if POV between 20251 and 24750 ; Down+Left
{ ; lean left
Key1ToHoldDown = q
Key2ToHoldDown =
}
else if POV between 24751 and 29250 ; Left
{ ; strafe left
Key1ToHoldDown = a
Key2ToHoldDown =
}
else if POV between 29251 and 33750 ; Up+Left
{ ; move forward & strafe left
Key1ToHoldDown = w
Key2ToHoldDown = a
}
if (PadButton6 = D or PadButton6 = U)
{
; assign left mouse button to variable PadKey6ToHoldDown
; fire primary weapon
PadKey6ToHoldDown = LButton
; MsgBox, 0, , The button status is %PadButton6%,
}
SetKeyDelay -1 ; Avoid delays between keystrokes.
if Key1ToHoldDown <> %Key1ToHoldDownPrev% ; Key #1 needs adjusting.
{
if Key1ToHoldDownPrev <> ; There is a previous key to release.
Send, {%Key1ToHoldDownPrev% up} ; Release it.
if Key1ToHoldDown <> ; There is a key to press down.
Send, {%Key1ToHoldDown% down} ; Press it down.
}
if Key2ToHoldDown <> %Key2ToHoldDownPrev% ; Key #2 needs adjusting.
{
if Key2ToHoldDownPrev <> ; There is a previous key to release.
Send, {%Key2ToHoldDownPrev% up} ; Release it.
if Key2ToHoldDown <> ; There is a key to press down.
Send, {%Key2ToHoldDown% down} ; Press it down.
}
if PadKey6ToHoldDown <> %PadKey6ToHoldDownPrev% ; compare current button status to previous status
{
if PadKey6ToHoldDownPrev <>
; Send, {%PadKey6ToHoldDownPrev% up} ; Release left mouse button
Send, Left mouse button up
if PadKey6ToHoldDown <>
; Send, (%PadKey6ToHoldDown% down) ; press & hold the left mouse button down
Send, Left mouse button down
}
return