Re: I\'m looking for a turnkey \'stars gamepad setup
here's my lhe setup for an xbox controller. dpad selects 4 tables. left analog stick moves mouse. buttons are fold, check/call, bet/raise. bottom button is left click. holding left trigger choses the auto actions just above each button. holding left and right trigger and pressing fold button chooses 'auto fold'. black and white buttons do auto post and sit out.
<font class="small">Code:</font><hr /><pre>
; Increase the following value to make the mouse cursor move faster:
JoyMultiplier = 0.40
JoyThreshold = 2
ButtonA = 1
ButtonB = 2
ButtonX = 3
ButtonY = 4
ButtonLeftT = 11
ButtonRightT = 12
ButtonWhite = 6
ButtonBlack = 5
ButtonLPDown = 9
ButtonRPDown = 10
ButtonBack = 8
; If your system has more than one joystick, increase this value to use a joystick
; other than the first:
JoystickNumber = 1
#SingleInstance
Hotkey, %JoystickNumber%Joy%ButtonA%, ButtonBack
Hotkey, !x, exitFunc
; Calculate the axis displacements that are needed to start moving the cursor:
JoyThresholdUpper = 50
JoyThresholdUpper += %JoyThreshold%
JoyThresholdLower = 50
JoyThresholdLower -= %JoyThreshold%
SetTimer, WatchJoystick, 10 ; Monitor the movement of the joystick.
return ; End of auto-execute section.
ButtonBack:
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left,,, 1, 0, D ; Hold down the left mouse button.
SetTimer, WaitForUp, 10
Return
exitFunc:
ExitApp
return
WaitForUp:
GetKeyState, AState, %JoystickNumber%Joy%ButtonA%
if AState = D ; The button is still, down, so keep waiting.
return
; Otherwise, the button has been released.
SetTimer, WaitForUp, off
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left,,, 1, 0, U ; Release the mouse button.
return
WatchJoyStick:
MoveMouse? = n ; Set default.
SetFormat, float, 03
GetKeyState, joyv, %JoystickNumber%JoyX
GetKeyState, joyu, %JoystickNumber%JoyY
if joyv > %JoyThresholdUpper%
{
MoveMouse? = y
DeltaX = %joyv%
DeltaX -= %JoyThresholdUpper%
}
else if joyv < %JoyThresholdLower%
{
MoveMouse? = y
DeltaX = %joyv%
DeltaX -= %JoyThresholdLower%
}
else
DeltaX = 0
if joyu > %JoyThresholdUpper%
{
MoveMouse? = y
DeltaY = %joyu%
DeltaY -= %JoyThresholdUpper%
}
else if joyu < %JoyThresholdLower%
{
MoveMouse? = y
DeltaY = %joyu%
DeltaY -= %JoyThresholdLower%
}
else
DeltaY = 0
if MoveMouse? = y
{
DeltaX *= %JoyMultiplier%
DeltaY *= %JoyMultiplier%
SetMouseDelay, -1 ; Makes movement smoother.
MouseMove, %DeltaX%, %DeltaY%, 0, R
}
GetKeyState, LTState, %JoystickNumber%Joy%ButtonLeftT%
GetKeyState, XState, %JoystickNumber%Joy%ButtonX%
GetKeyState, YState, %JoystickNumber%Joy%ButtonY%
GetKeyState, AState, %JoystickNumber%Joy%ButtonA%
GetKeyState, BState, %JoystickNumber%Joy%ButtonB%
GetKeyState, RTState, %JoystickNumber%Joy%ButtonRightT%
GetKeyState, WhiteState, %JoystickNumber%Joy%ButtonWhite%
GetKeyState, BlackState, %JoystickNumber%Joy%ButtonBlack%
GetKeyState, LPDState, %JoystickNumber%Joy%ButtonLPDown%
GetKeyState, RPDState, %JoystickNumber%Joy%ButtonRPDown%
GetKeyState, BackState, %JoystickNumber%Joy%ButtonBack%
GetKeyState, joyPOV, %JoystickNumber%JoyPOV
if (JoyPov = 31500)
{
CoordMode, Mouse, Screen
MouseMove,400,300,0
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
SetTimer, WatchJoystick, Off
Sleep, 100
SetTimer, WatchJoystick, 10
}
if (JoyPov = 4500)
{
CoordMode, Mouse, Screen
MouseMove,1200,300,0
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
SetTimer, WatchJoystick, Off
Sleep, 100
SetTimer, WatchJoystick, 10
}
if (JoyPov = 22500)
{
CoordMode, Mouse, Screen
MouseMove,400,900,0
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
SetTimer, WatchJoystick, Off
Sleep, 100
SetTimer, WatchJoystick, 10
}
if (JoyPov = 13500)
{
CoordMode, Mouse, Screen
MouseMove,1200,900,0
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
SetTimer, WatchJoystick, Off
Sleep, 100
SetTimer, WatchJoystick, 10
}
;fold
If ((LTState = "U") and (XState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (470+rx), (550+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;check
If ((LTState = "U") and (YState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (600+rx), (550+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;raise
If ((LTState = "U") and (BState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (720+rx), (550+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;fold
If ((LTState = "D") and (XState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (470+rx), (500+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;check
If ((LTState = "D") and (YState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (600+rx), (500+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;raise
If ((LTState = "D") and (BState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (720+rx), (500+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;fold
If ((LTState = "D") and (XState = "D") and (RTState = "D"))
{
SetMouseDelay, -1 ; Makes movement smoother.
Random, rx, -16, 16
Random, ry, -2, 2
MouseClick, left, (470+rx), (520+ry), 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;autopost
If ((LTState = "U") and (BlackState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left, 16, 425, 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
;muck
If ((LTState = "U") and (WhiteState = "D") and (RTState = "U"))
{
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left, 16, 405, 1, 0
SetTimer, WatchJoystick, Off
Sleep, 200
SetTimer, WatchJoystick, 10
}
Return
</pre><hr />
I'm using some ghetto 64 bit version of XBCD, so the joysticks may not work with a standard XBCD 'out of the box'.
|