Customizable Gamepad Scripts

Post gaming related scripts
User avatar
Simon Belmont
Posts: 19
Joined: 03 Dec 2020, 00:14

Customizable Gamepad Scripts

Post by Simon Belmont » 18 Mar 2023, 07:05

I wrote four versions of this gamepad script to accommodate mouse functionality on both analog sticks, each analog stick individually, as well as no mouse functionality at all. If you are looking for a script to enhance gamepad functionality (especially in older "retro" games), very likely one of these four will suit your needs (or could be modified to do so).

Additionally, each script features four "modes"; selected by toggling between any combination of Num Lock & Scroll Lock. Each "mode" has its own keybind-variables and points of adjustment (mod-keys, inverting an axis, mouse speed, etc). I tried to include a ready means of making any adjustments one might want, without bloating each script with things few would ever need. Each script is a single, independent file; which can be named whatever you like. I relied heavily on AutoHotkey's help files while writing these, and most of what you'll see below is nothing more than a synergized compilation of what can be found there. I have tested these in many games, and am reasonably sure they are entirely bug-free. If you find anything amiss, please let me know.

I've included what I hope are very clear instructions throughout the variables-portion of each script, wherever they might be needed. Where lengthier instruction would be helpful, they'll be located just above the given variable. Where a few brief words of instruction would suffice, they are found immediately following the variable (in-line with it). The hope is that these scripts will be 'beginner-friendly'. Which is also why I'm not elaborating on every detail here. Without any immediate context, it would be pointless. Just copy-paste one of the scripts into an editor and look for the ;s. Hopefully it will all be very clear. But, if you do have any questions, I'll do my best to answer them.

I primarily started working on these to better marry old DOS/early-Windows games to modern gamepads. But they work pretty well in present-day PC games too. I'm currently experimenting with pre-patterned mouse-movements, assigned to an analog stick, to produce predictable weapon-attacks in games like Ultima Underworld: The Stygian Abyss & Daggerfall; where you would normally hold down a mouse button and drag the mouse in certain directions, depending on the type of weapon-attack you want to use. When I get it dialed-in, I'll post it here too.

Lastly, each script's keybind-variables and other settings were left as-is, after I removed all game-specific binds & settings (used during play-testing in games), and gave them more generic binds & settings for one last test run in a Notepad++ txt. You will almost certainly need to adjust at least the keybind-variables. The mouse settings would probably be fine to leave as-is though.

Script 1: Mouse functionality is assigned to both the left & right analog sticks, separately.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with mouse movement assigned to both analog sticks (separately).

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; By toggling On/Off any combination of Num Lock & Scroll Lock, four full 'sets' of keybinds & adjustments can be easily accessed.

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

	Joy_Counter = 2



; The following eight Timers should require no adjustment; I recommend leaving them alone.

	SetTimer, Joy_Output, 10

	SetTimer, Joy_POV_Mod, 10

	SetTimer, Joy_POV_NS, 10

	SetTimer, Joy_POV_WE, 10

	SetTimer, Joy_XY_Mod, 10

	SetTimer, Joy_XY, 10

	SetTimer, Joy_ZR_Mod, 10

	SetTimer, Joy_ZR, 10

return	; End of auto-execute.



; Below are two Hotkeys which Reload or Close, respectively, this script.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}



; Below is the header for the Timer which watches to see which "MODE" you are in. Within this Timer lie all customizable variables.

Joy_Output:
NumLock_Var := GetKeyState("NumLock", "T")
ScrollLock_Var := GetKeyState("ScrollLock", "T")
if NumLock_Var and ScrollLock_Var	; Num Lock: On, Scroll Lock: On, "MODE-4".
{



; "MODE-4" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-4" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-4" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if NumLock_Var and !ScrollLock_Var	; Num Lock: On, Scroll Lock: Off, "MODE-3".
{



; "MODE-3" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-3" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-3" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and ScrollLock_Var	; Num Lock: Off, Scroll Lock: On, "MODE-2".
{



; "MODE-2" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-2" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-2" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and !ScrollLock_Var	; Num Lock: Off, Scroll Lock: Off, "MODE-1".
{



; "MODE-1" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-1" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-1" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
return



; NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_XY:
Joy_XY_Move := false
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if JoyX < %X_Var_Lf%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Lf
}
else if JoyX > %X_Var_Rt%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Rt
}
else
	X_Delta = 0

if JoyY < %Y_Var_Up%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Up
}
else if JoyY > %Y_Var_Dn%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Dn
}
else
	Y_Delta = 0

if Joy_XY_Move
{
	MouseMove, X_Delta * Mouse_Speed_X * Invert_X, Y_Delta * Mouse_Speed_Y * Invert_Y, 0, R
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_ZR:
Joy_ZR_Move := false
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if JoyZ < %Z_Var_Lf%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Lf
}
else if JoyZ > %Z_Var_Rt%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Rt
}
else
	Z_Delta = 0

if JoyR < %R_Var_Up%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Up
}
else if JoyR > %R_Var_Dn%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Dn
}
else
	R_Delta = 0

if Joy_ZR_Move
{
	MouseMove, Z_Delta * Mouse_Speed_Z * Invert_Z, R_Delta * Mouse_Speed_R * Invert_R, 0, R
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Script 2: Mouse functionality is assigned to the left analog stick, and key-variables are bound to the right analog stick.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with mouse movement assigned to the left analog stick and keybinds assigned to the right analog stick.

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; By toggling On/Off any combination of Num Lock & Scroll Lock, four full 'sets' of keybinds & adjustments can be easily accessed.

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

	Joy_Counter = 2



; The following nine Timers should require no adjustment; I recommend leaving them alone.

	SetTimer, Joy_Output, 10

	SetTimer, Joy_POV_Mod, 10

	SetTimer, Joy_POV_NS, 10

	SetTimer, Joy_POV_WE, 10

	SetTimer, Joy_XY_Mod, 10

	SetTimer, Joy_XY, 10

	SetTimer, Joy_ZR_Mod, 10

	SetTimer, Joy_Z, 10

	SetTimer, Joy_R, 10

return	; End of auto-execute.



; Below are two Hotkeys which Reload or Close, respectively, this script.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}



; Below is the header for the Timer which watches to see which "MODE" you are in. Within this Timer lie all customizable variables.

Joy_Output:
NumLock_Var := GetKeyState("NumLock", "T")
ScrollLock_Var := GetKeyState("ScrollLock", "T")
if NumLock_Var and ScrollLock_Var	; Num Lock: On, Scroll Lock: On, "MODE-4".
{



; "MODE-4" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-4" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-4" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if NumLock_Var and !ScrollLock_Var	; Num Lock: On, Scroll Lock: Off, "MODE-3".
{



; "MODE-3" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-3" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-3" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and ScrollLock_Var	; Num Lock: Off, Scroll Lock: On, "MODE-2".
{



; "MODE-2" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-2" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-2" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and !ScrollLock_Var	; Num Lock: Off, Scroll Lock: Off, "MODE-1".
{



; "MODE-1" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

	JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-1" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-1" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
return



; NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_XY:
Joy_XY_Move := false
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if JoyX < %X_Var_Lf%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Lf
}
else if JoyX > %X_Var_Rt%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Rt
}
else
	X_Delta = 0

if JoyY < %Y_Var_Up%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Up
}
else if JoyY > %Y_Var_Dn%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Dn
}
else
	Y_Delta = 0

if Joy_XY_Move
{
	MouseMove, X_Delta * Mouse_Speed_X * Invert_X, Y_Delta * Mouse_Speed_Y * Invert_Y, 0, R
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_Z:
JoyZ := GetKeyState("JoyZ")
if JoyZ < %Z_Var_Lf%
{
	if JoyZ_Lf_State
		return

	Send, %JoyZ_Lf_a% down}%JoyZ_Lf_b% down}
	JoyZ_Lf_State := true
	SetTimer, Joy_Z_Lf_up, 10
	return
}
else if JoyZ > %Z_Var_Rt%
{
	if JoyZ_Rt_State
		return

	Send, %JoyZ_Rt_a% down}%JoyZ_Rt_b% down}
	JoyZ_Rt_State := true
	SetTimer, Joy_Z_Rt_up, 10
	return
}
return

Joy_R:
JoyR := GetKeyState("JoyR")
if JoyR < %R_Var_Up%
{
	if JoyR_Up_State
		return

	Send, %JoyR_Up_a% down}%JoyR_Up_b% down}
	JoyR_Up_State := true
	SetTimer, Joy_R_Up_up, 10
	return
}
else if JoyR > %R_Var_Dn%
{
	if JoyR_Dn_State
		return

	Send, %JoyR_Dn_a% down}%JoyR_Dn_b% down}
	JoyR_Dn_State := true
	SetTimer, Joy_R_Dn_up, 10
	return
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy_Z_Lf_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ < %Z_Var_Lf%
		return

	JoyZ_Lf_State := ""
	SetTimer, Joy_Z_Lf_up, Off
	Send, %JoyZ_Lf_a% up}%JoyZ_Lf_b% up}
	return
}
return

Joy_Z_Rt_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ > %Z_Var_Rt%
		return

	JoyZ_Rt_State := ""
	SetTimer, Joy_Z_Rt_up, Off
	Send, %JoyZ_Rt_a% up}%JoyZ_Rt_b% up}
	return
}
return

Joy_R_Up_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR < %R_Var_Up%
		return

	JoyR_Up_State := ""
	SetTimer, Joy_R_Up_up, Off
	Send, %JoyR_Up_a% up}%JoyR_Up_b% up}
	return
}
return

Joy_R_Dn_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR > %R_Var_Dn%
		return

	JoyR_Dn_State := ""
	SetTimer, Joy_R_Dn_up, Off
	Send, %JoyR_Dn_a% up}%JoyR_Dn_b% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Script 3: Key-variables are bound to the left analog stick, and mouse functionality is assigned to the right analog stick.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with mouse movement assigned to the right analog stick and keybinds assigned to the left analog stick.

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; By toggling On/Off any combination of Num Lock & Scroll Lock, four full 'sets' of keybinds & adjustments can be easily accessed.

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

	Joy_Counter = 2



; The following nine Timers should require no adjustment; I recommend leaving them alone.

	SetTimer, Joy_Output, 10

	SetTimer, Joy_POV_Mod, 10

	SetTimer, Joy_POV_NS, 10

	SetTimer, Joy_POV_WE, 10

	SetTimer, Joy_XY_Mod, 10

	SetTimer, Joy_X, 10

	SetTimer, Joy_Y, 10

	SetTimer, Joy_ZR_Mod, 10

	SetTimer, Joy_ZR, 10

return	; End of auto-execute.



; Below are two Hotkeys which Reload or Close, respectively, this script.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}



; Below is the header for the Timer which watches to see which "MODE" you are in. Within this Timer lie all customizable variables.

Joy_Output:
NumLock_Var := GetKeyState("NumLock", "T")
ScrollLock_Var := GetKeyState("ScrollLock", "T")
if NumLock_Var and ScrollLock_Var	; Num Lock: On, Scroll Lock: On, "MODE-4".
{



; "MODE-4" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-4" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-4" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if NumLock_Var and !ScrollLock_Var	; Num Lock: On, Scroll Lock: Off, "Game 3".
{



; "MODE-3" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-3" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-3" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and ScrollLock_Var	; Num Lock: Off, Scroll Lock: On, "Game 2".
{



; "MODE-2" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-2" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-2" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and !ScrollLock_Var	; Num Lock: Off, Scroll Lock: Off, "Game 1".
{



; "MODE-1" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Speed of pointer-travel.

	Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
	Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

	JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-1" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-1" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
return



; NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_X:
JoyX := GetKeyState("JoyX")
if JoyX < %X_Var_Lf%
{
	if JoyX_Lf_State
		return

	Send, %JoyX_Lf_a% down}%JoyX_Lf_b% down}
	JoyX_Lf_State := true
	SetTimer, Joy_X_Lf_up, 10
	return
}
else if JoyX > %X_Var_Rt%
{
	if JoyX_Rt_State
		return

	Send, %JoyX_Rt_a% down}%JoyX_Rt_b% down}
	JoyX_Rt_State := true
	SetTimer, Joy_X_Rt_up, 10
	return
}
return

Joy_Y:
JoyY := GetKeyState("JoyY")
if JoyY < %Y_Var_Up%
{
	if JoyY_Up_State
		return

	Send, %JoyY_Up_a% down}%JoyY_Up_b% down}
	JoyY_Up_State := true
	SetTimer, Joy_Y_Up_up, 10
	return
}
else if JoyY > %Y_Var_Dn%
{
	if JoyY_Dn_State
		return

	Send, %JoyY_Dn_a% down}%JoyY_Dn_b% down}
	JoyY_Dn_State := true
	SetTimer, Joy_Y_Dn_up, 10
	return
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_ZR:
Joy_ZR_Move := false
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if JoyZ < %Z_Var_Lf%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Lf
}
else if JoyZ > %Z_Var_Rt%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Rt
}
else
	Z_Delta = 0

if JoyR < %R_Var_Up%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Up
}
else if JoyR > %R_Var_Dn%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Dn
}
else
	R_Delta = 0

if Joy_ZR_Move
{
	MouseMove, Z_Delta * Mouse_Speed_Z * Invert_Z, R_Delta * Mouse_Speed_R * Invert_R, 0, R
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_X_Lf_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX < %X_Var_Lf%
		return

	JoyX_Lf_State := ""
	SetTimer, Joy_X_Lf_up, Off
	Send, %JoyX_Lf_a% up}%JoyX_Lf_b% up}
	return
}
return

Joy_X_Rt_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX > %X_Var_Rt%
		return

	JoyX_Rt_State := ""
	SetTimer, Joy_X_Rt_up, Off
	Send, %JoyX_Rt_a% up}%JoyX_Rt_b% up}
	return
}
return

Joy_Y_Up_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY < %Y_Var_Up%
		return

	JoyY_Up_State := ""
	SetTimer, Joy_Y_Up_up, Off
	Send, %JoyY_Up_a% up}%JoyY_Up_b% up}
	return
}
return

Joy_Y_Dn_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY > %Y_Var_Dn%
		return

	JoyY_Dn_State := ""
	SetTimer, Joy_Y_Dn_up, Off
	Send, %JoyY_Dn_a% up}%JoyY_Dn_b% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Script 4: No mouse functionality assigned to either analog stick. Rather, key-variables are bound to each stick's various axes points.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with keybinds assigned to both analog sticks (separately).

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; By toggling On/Off any combination of Num Lock & Scroll Lock, four full 'sets' of keybinds & adjustments can be easily accessed.

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

	Joy_Counter = 2



; The following ten Timers should require no adjustment; I recommend leaving them alone.

	SetTimer, Joy_Output, 10

	SetTimer, Joy_POV_Mod, 10

	SetTimer, Joy_POV_NS, 10

	SetTimer, Joy_POV_WE, 10

	SetTimer, Joy_XY_Mod, 10

	SetTimer, Joy_X, 10

	SetTimer, Joy_Y, 10

	SetTimer, Joy_ZR_Mod, 10

	SetTimer, Joy_Z, 10

	SetTimer, Joy_R, 10

return	; End of auto-execute.



; Below are two Hotkeys which Reload or Close, respectively, this script.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}



; Below is the header for the Timer which watches to see which "MODE" you are in. Within this Timer lie all customizable variables.

Joy_Output:
NumLock_Var := GetKeyState("NumLock", "T")
ScrollLock_Var := GetKeyState("ScrollLock", "T")
if NumLock_Var and ScrollLock_Var	; Num Lock: On, Scroll Lock: On, "MODE-4".
{



; "MODE-4" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-4" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-4" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if NumLock_Var and !ScrollLock_Var	; Num Lock: On, Scroll Lock: Off, "Game 3".
{



; "MODE-3" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-3" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-3" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and ScrollLock_Var	; Num Lock: Off, Scroll Lock: On, "Game 2".
{



; "MODE-2" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-2" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-2" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
else if !NumLock_Var and !ScrollLock_Var	; Num Lock: Off, Scroll Lock: Off, "Game 1".
{



; "MODE-1" CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

	JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
	JoyPOV_N := "{Up"		; D-Pad-North/Up.
	JoyPOV_S := "{Down"		; D-Pad-South/Down.
	JoyPOV_W := "{Left"		; D-Pad-West/Left.
	JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_X = 5	; Decrease to reduce required displacement.
	Req_Disp_Y = 5	; (same as above).

	Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_Y_Mod = 5	; (same as above).

;  Left Analog Stick keybinds.

	JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
	JoyX_Lf_a := "{Left"	; Left-Stick: Left.
	JoyX_Lf_b := "{F25"		; (nested within the above)
	JoyX_Rt_a := "{Right"	; Left-Stick: Right.
	JoyX_Rt_b := "{F25"		; (nested within the above)
	JoyY_Up_a := "{Up"		; Left-Stick: Up.
	JoyY_Up_b := "{F25"		; (nested within the above)
	JoyY_Dn_a := "{Down"	; Left-Stick: Down.
	JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

	Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
	Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

	Req_Disp_Z = 5	; Decrease to reduce required displacement.
	Req_Disp_R = 5	; (same as above).

	Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
	Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Keybinds.

	JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
	JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
	JoyZ_Lf_b := "{F25"		; (nested within the above)
	JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
	JoyZ_Rt_b := "{F25"		; (nested within the above)
	JoyR_Up_a := "{Up"		; Right-Stick: Up.
	JoyR_Up_b := "{F25"		; (nested within the above)
	JoyR_Dn_a := "{Down"	; Right-Stick: Down.
	JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

	Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{LButton"	; X, on an XBOX Controller.
	Joy1_b := "{x"			; (nested within the above)
	Joy2_a := "{MButton"	; A, on an XBOX Controller.
	Joy2_b := "{a"			; (nested within the above)
	Joy3_a := "{RButton"	; B, on an XBOX Controller.
	Joy3_b := "{b"			; (nested within the above)
	Joy4_a := "{F25"		; Y, on an XBOX Controller.
	Joy4_b := "{y"			; (nested within the above)
	Joy5_a := "{["			; LB, on an XBOX Controller.
	Joy5_b := "{Shift"		; (nested within the above)
	Joy6_a := "{]"			; RB, on an XBOX Controller.
	Joy6_b := "{Del"		; (nested within the above)
	Joy7_a := "{l"			; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested within the above)
	Joy8_a := "{r"			; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested within the above)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested within the above)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested within the above)
	Joy11_a := "{Shift"		; L3, on many Controllers.
	Joy11_b := "{F1"		; (nested within the above)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F1"		; (nested within the above)



; END OF "MODE-1" CUSTOMIZABLE VARIABLE SECTION!!!   NO "MODE-1" CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



	X_Var_Lf := 50 - Req_Disp_X
	X_Var_Rt := 50 + Req_Disp_X
	Y_Var_Up := 50 - Req_Disp_Y
	Y_Var_Dn := 50 + Req_Disp_Y

	X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
	X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
	Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
	Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

	Z_Var_Lf := 50 - Req_Disp_Z
	Z_Var_Rt := 50 + Req_Disp_Z
	R_Var_Up := 50 - Req_Disp_R
	R_Var_Dn := 50 + Req_Disp_R

	Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
	Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
	R_Var_Up_Mod := 50 - Req_Disp_R_Mod
	R_Var_Dn_Mod := 50 + Req_Disp_R_Mod



}
return



; NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_X:
JoyX := GetKeyState("JoyX")
if JoyX < %X_Var_Lf%
{
	if JoyX_Lf_State
		return

	Send, %JoyX_Lf_a% down}%JoyX_Lf_b% down}
	JoyX_Lf_State := true
	SetTimer, Joy_X_Lf_up, 10
	return
}
else if JoyX > %X_Var_Rt%
{
	if JoyX_Rt_State
		return

	Send, %JoyX_Rt_a% down}%JoyX_Rt_b% down}
	JoyX_Rt_State := true
	SetTimer, Joy_X_Rt_up, 10
	return
}
return

Joy_Y:
JoyY := GetKeyState("JoyY")
if JoyY < %Y_Var_Up%
{
	if JoyY_Up_State
		return

	Send, %JoyY_Up_a% down}%JoyY_Up_b% down}
	JoyY_Up_State := true
	SetTimer, Joy_Y_Up_up, 10
	return
}
else if JoyY > %Y_Var_Dn%
{
	if JoyY_Dn_State
		return

	Send, %JoyY_Dn_a% down}%JoyY_Dn_b% down}
	JoyY_Dn_State := true
	SetTimer, Joy_Y_Dn_up, 10
	return
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_Z:
JoyZ := GetKeyState("JoyZ")
if JoyZ < %Z_Var_Lf%
{
	if JoyZ_Lf_State
		return

	Send, %JoyZ_Lf_a% down}%JoyZ_Lf_b% down}
	JoyZ_Lf_State := true
	SetTimer, Joy_Z_Lf_up, 10
	return
}
else if JoyZ > %Z_Var_Rt%
{
	if JoyZ_Rt_State
		return

	Send, %JoyZ_Rt_a% down}%JoyZ_Rt_b% down}
	JoyZ_Rt_State := true
	SetTimer, Joy_Z_Rt_up, 10
	return
}
return

Joy_R:
JoyR := GetKeyState("JoyR")
if JoyR < %R_Var_Up%
{
	if JoyR_Up_State
		return

	Send, %JoyR_Up_a% down}%JoyR_Up_b% down}
	JoyR_Up_State := true
	SetTimer, Joy_R_Up_up, 10
	return
}
else if JoyR > %R_Var_Dn%
{
	if JoyR_Dn_State
		return

	Send, %JoyR_Dn_a% down}%JoyR_Dn_b% down}
	JoyR_Dn_State := true
	SetTimer, Joy_R_Dn_up, 10
	return
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_X_Lf_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX < %X_Var_Lf%
		return

	JoyX_Lf_State := ""
	SetTimer, Joy_X_Lf_up, Off
	Send, %JoyX_Lf_a% up}%JoyX_Lf_b% up}
	return
}
return

Joy_X_Rt_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX > %X_Var_Rt%
		return

	JoyX_Rt_State := ""
	SetTimer, Joy_X_Rt_up, Off
	Send, %JoyX_Rt_a% up}%JoyX_Rt_b% up}
	return
}
return

Joy_Y_Up_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY < %Y_Var_Up%
		return

	JoyY_Up_State := ""
	SetTimer, Joy_Y_Up_up, Off
	Send, %JoyY_Up_a% up}%JoyY_Up_b% up}
	return
}
return

Joy_Y_Dn_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY > %Y_Var_Dn%
		return

	JoyY_Dn_State := ""
	SetTimer, Joy_Y_Dn_up, Off
	Send, %JoyY_Dn_a% up}%JoyY_Dn_b% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy_Z_Lf_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ < %Z_Var_Lf%
		return

	JoyZ_Lf_State := ""
	SetTimer, Joy_Z_Lf_up, Off
	Send, %JoyZ_Lf_a% up}%JoyZ_Lf_b% up}
	return
}
return

Joy_Z_Rt_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ > %Z_Var_Rt%
		return

	JoyZ_Rt_State := ""
	SetTimer, Joy_Z_Rt_up, Off
	Send, %JoyZ_Rt_a% up}%JoyZ_Rt_b% up}
	return
}
return

Joy_R_Up_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR < %R_Var_Up%
		return

	JoyR_Up_State := ""
	SetTimer, Joy_R_Up_up, Off
	Send, %JoyR_Up_a% up}%JoyR_Up_b% up}
	return
}
return

Joy_R_Dn_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR > %R_Var_Dn%
		return

	JoyR_Dn_State := ""
	SetTimer, Joy_R_Dn_up, Off
	Send, %JoyR_Dn_a% up}%JoyR_Dn_b% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Last edited by Simon Belmont on 23 Apr 2023, 19:03, edited 3 times in total.

Omarfarra
Posts: 1
Joined: 26 Mar 2023, 22:53

Re: Gamepad Script, Four Versions

Post by Omarfarra » 26 Mar 2023, 23:07

Dude what the h? Is this script supposed to be easy to use or something? What's wrong with making a script you DON'T HAVE TO BE A CODING EXPERT TO USE?? what kind of 'old school' game is gonna need 4 f___ing sets of controls with each button of the 4 sets having it's own modifiers and sh---?? Seriously? I can only ever come up with MAYBE 1. Maybe 2 extra functions for SOME of the buttons for even the most complex game controls. You need to make a script that's usable by people who don't know jack s##t about d@#$! Think of any piece of code your making as literature, and all literature published in the United States is geared towards a fifth grade audience (for a reason). Am i just this dumb?? Or this script is waaaay overkill ...

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: Gamepad Script, Four Versions

Post by boiler » 26 Mar 2023, 23:28

@Omarfarra — If you don’t like it, don’t use it. Why bash it? What have you contributed to the community? OP wrote something and put it out there for whomever might find it useful. If you don’t find it useful, fine.

Omarfarra wrote: You need to make a script that's usable by people who don't know jack s##t about d@#$!
Why does he need to do anything? What have you done?

Omarfarra wrote: … all literature published in the United States is geared towards a fifth grade audience (for a reason). Am i just this dumb??
This tells us all we need to know about your thought processes.

User avatar
Simon Belmont
Posts: 19
Joined: 03 Dec 2020, 00:14

Re: Gamepad Script, Four Versions

Post by Simon Belmont » 28 Mar 2023, 23:44

In re-going-through the four above gamepad scripts I found a few minor corrections that could be made. Though, nothing that would have caused errors; just a few superfluous variables. I have edited the above post, and the scripts therein, to reflect those corrections. As well, I made slight changes to their layouts and wording to bring them in-line with the below scripts. I'm hoping for some semblance of consistency here.

As to whether these scripts are "beginner-friendly" or not; that would depend more on the beginner, than it would the script. Though, when I say that I'm hoping that these scripts will be "beginner-friendly", I mostly mean that everything the user would need to interact with is written in a 'long-form', rather than being reduced to it's shortest possible form (which might look like nothing more than coding gibberish to them). And, maybe these scripts still look like exactly that to a beginner. But, a few searches in the help-files, a little reading, a little trial-n-error, and it should become clear how they work. There are nothing in-play here that can't be searched for by name, as it apears in script, in AutoHotkey's help files. I really did try to make these as clean and easy to use as I could, while still achieving the desired outcome.

I play dozens of old DOS games; graphics aren't everything. Most old DOS games use input-layouts which are unique to them; even when published by the same company. Wolfenstein 3D and DOOM (both made by id Software) are a good example. There was no 'generally agreed upon layout' back then. So, I find having several modes, per script, to be helpful. But, for those who find these modes cumbersome (and, if you do, I get it!),

Here are 'no-mode' variants of the above gamepad scripts. I have edited and updated the instructions throughout to reflect all changes. I have also attempted to better separate customizable variable-groupings from less-customizable (static) variables, as well as offer general instructions which are hopefully more clear [again, this now applies to the above 'four-mode' scripts as well].

Script 1: Mouse functionality is assigned to both the left & right analog sticks, separately.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with mouse movement assigned to both analog sticks (separately).

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!   CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

Joy_Counter = 2



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
JoyPOV_N := "{Up"		; D-Pad-North/Up.
JoyPOV_S := "{Down"		; D-Pad-South/Down.
JoyPOV_W := "{Left"		; D-Pad-West/Left.
JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_X = 5	; Decrease to reduce required displacement.
Req_Disp_Y = 5	; (same as above).

Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick Mod-Key.

JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_R = 1	; (same as above).

; Speed of pointer-travel.

Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_Z = 5	; Decrease to reduce required displacement.
Req_Disp_R = 5	; (same as above).

Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

Joy1_a := "{LButton"	; X, on an XBOX Controller.
Joy1_b := "{x"			; (nested within the above)
Joy2_a := "{MButton"	; A, on an XBOX Controller.
Joy2_b := "{a"			; (nested within the above)
Joy3_a := "{RButton"	; B, on an XBOX Controller.
Joy3_b := "{b"			; (nested within the above)
Joy4_a := "{F25"		; Y, on an XBOX Controller.
Joy4_b := "{y"			; (nested within the above)
Joy5_a := "{["			; LB, on an XBOX Controller.
Joy5_b := "{Shift"		; (nested within the above)
Joy6_a := "{]"			; RB, on an XBOX Controller.
Joy6_b := "{Del"		; (nested within the above)
Joy7_a := "{l"			; LT, on an XBOX Controller.
Joy7_b := "{Alt"		; (nested within the above)
Joy8_a := "{r"			; RT, on an XBOX Controller.
Joy8_b := "{Ctrl"		; (nested within the above)
Joy9_a := "{F25"		; Select, on many Controllers.
Joy9_b := "{Tab"		; (nested within the above)
Joy10_a := "{F25"		; Start, on many Controllers.
Joy10_b := "{Esc"		; (nested within the above)
Joy11_a := "{Shift"		; L3, on many Controllers.
Joy11_b := "{F1"		; (nested within the above)
Joy12_a := "{F25"		; R3, on many Controllers.
Joy12_b := "{F1"		; (nested within the above)



; END OF CUSTOMIZABLE VARIABLE SECTION!!!   NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



X_Var_Lf := 50 - Req_Disp_X
X_Var_Rt := 50 + Req_Disp_X
Y_Var_Up := 50 - Req_Disp_Y
Y_Var_Dn := 50 + Req_Disp_Y

X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

Z_Var_Lf := 50 - Req_Disp_Z
Z_Var_Rt := 50 + Req_Disp_Z
R_Var_Up := 50 - Req_Disp_R
R_Var_Dn := 50 + Req_Disp_R

Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
R_Var_Up_Mod := 50 - Req_Disp_R_Mod
R_Var_Dn_Mod := 50 + Req_Disp_R_Mod

SetTimer, Joy_POV_Mod, 10

SetTimer, Joy_POV_NS, 10

SetTimer, Joy_POV_WE, 10

SetTimer, Joy_XY_Mod, 10

SetTimer, Joy_XY, 10

SetTimer, Joy_ZR_Mod, 10

SetTimer, Joy_ZR, 10

return	; End of auto-execute.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}

Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_XY:
Joy_XY_Move := false
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if JoyX < %X_Var_Lf%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Lf
}
else if JoyX > %X_Var_Rt%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Rt
}
else
	X_Delta = 0

if JoyY < %Y_Var_Up%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Up
}
else if JoyY > %Y_Var_Dn%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Dn
}
else
	Y_Delta = 0

if Joy_XY_Move
{
	MouseMove, X_Delta * Mouse_Speed_X * Invert_X, Y_Delta * Mouse_Speed_Y * Invert_Y, 0, R
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_ZR:
Joy_ZR_Move := false
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if JoyZ < %Z_Var_Lf%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Lf
}
else if JoyZ > %Z_Var_Rt%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Rt
}
else
	Z_Delta = 0

if JoyR < %R_Var_Up%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Up
}
else if JoyR > %R_Var_Dn%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Dn
}
else
	R_Delta = 0

if Joy_ZR_Move
{
	MouseMove, Z_Delta * Mouse_Speed_Z * Invert_Z, R_Delta * Mouse_Speed_R * Invert_R, 0, R
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Script 2: Mouse functionality is assigned to the left analog stick, and key-variables are bound to the right analog stick.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with mouse movement assigned to the left analog stick and keybinds assigned to the right analog stick.

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!   CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

Joy_Counter = 2



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
JoyPOV_N := "{Up"		; D-Pad-North/Up.
JoyPOV_S := "{Down"		; D-Pad-South/Down.
JoyPOV_W := "{Left"		; D-Pad-West/Left.
JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_X = 5	; Decrease to reduce required displacement.
Req_Disp_Y = 5	; (same as above).

Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick keybinds.

JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_Z = 5	; Decrease to reduce required displacement.
Req_Disp_R = 5	; (same as above).

Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick keybinds.

JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
JoyZ_Lf_b := "{F25"		; (nested within the above)
JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
JoyZ_Rt_b := "{F25"		; (nested within the above)
JoyR_Up_a := "{Up"		; Right-Stick: Up.
JoyR_Up_b := "{F25"		; (nested within the above)
JoyR_Dn_a := "{Down"	; Right-Stick: Down.
JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

Joy1_a := "{LButton"	; X, on an XBOX Controller.
Joy1_b := "{x"			; (nested within the above)
Joy2_a := "{MButton"	; A, on an XBOX Controller.
Joy2_b := "{a"			; (nested within the above)
Joy3_a := "{RButton"	; B, on an XBOX Controller.
Joy3_b := "{b"			; (nested within the above)
Joy4_a := "{F25"		; Y, on an XBOX Controller.
Joy4_b := "{y"			; (nested within the above)
Joy5_a := "{["			; LB, on an XBOX Controller.
Joy5_b := "{Shift"		; (nested within the above)
Joy6_a := "{]"			; RB, on an XBOX Controller.
Joy6_b := "{Del"		; (nested within the above)
Joy7_a := "{l"			; LT, on an XBOX Controller.
Joy7_b := "{Alt"		; (nested within the above)
Joy8_a := "{r"			; RT, on an XBOX Controller.
Joy8_b := "{Ctrl"		; (nested within the above)
Joy9_a := "{F25"		; Select, on many Controllers.
Joy9_b := "{Tab"		; (nested within the above)
Joy10_a := "{F25"		; Start, on many Controllers.
Joy10_b := "{Esc"		; (nested within the above)
Joy11_a := "{Shift"		; L3, on many Controllers.
Joy11_b := "{F1"		; (nested within the above)
Joy12_a := "{F25"		; R3, on many Controllers.
Joy12_b := "{F1"		; (nested within the above)



; END OF CUSTOMIZABLE VARIABLE SECTION!!!   NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



X_Var_Lf := 50 - Req_Disp_X
X_Var_Rt := 50 + Req_Disp_X
Y_Var_Up := 50 - Req_Disp_Y
Y_Var_Dn := 50 + Req_Disp_Y

X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

Z_Var_Lf := 50 - Req_Disp_Z
Z_Var_Rt := 50 + Req_Disp_Z
R_Var_Up := 50 - Req_Disp_R
R_Var_Dn := 50 + Req_Disp_R

Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
R_Var_Up_Mod := 50 - Req_Disp_R_Mod
R_Var_Dn_Mod := 50 + Req_Disp_R_Mod

SetTimer, Joy_POV_Mod, 10

SetTimer, Joy_POV_NS, 10

SetTimer, Joy_POV_WE, 10

SetTimer, Joy_XY_Mod, 10

SetTimer, Joy_XY, 10

SetTimer, Joy_ZR_Mod, 10

SetTimer, Joy_Z, 10

SetTimer, Joy_R, 10

return	; End of auto-execute.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}

Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_XY:
Joy_XY_Move := false
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if JoyX < %X_Var_Lf%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Lf
}
else if JoyX > %X_Var_Rt%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Rt
}
else
	X_Delta = 0

if JoyY < %Y_Var_Up%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Up
}
else if JoyY > %Y_Var_Dn%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Dn
}
else
	Y_Delta = 0

if Joy_XY_Move
{
	MouseMove, X_Delta * Mouse_Speed_X * Invert_X, Y_Delta * Mouse_Speed_Y * Invert_Y, 0, R
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_Z:
JoyZ := GetKeyState("JoyZ")
if JoyZ < %Z_Var_Lf%
{
	if JoyZ_Lf_State
		return

	Send, %JoyZ_Lf_a% down}%JoyZ_Lf_b% down}
	JoyZ_Lf_State := true
	SetTimer, Joy_Z_Lf_up, 10
	return
}
else if JoyZ > %Z_Var_Rt%
{
	if JoyZ_Rt_State
		return

	Send, %JoyZ_Rt_a% down}%JoyZ_Rt_b% down}
	JoyZ_Rt_State := true
	SetTimer, Joy_Z_Rt_up, 10
	return
}
return

Joy_R:
JoyR := GetKeyState("JoyR")
if JoyR < %R_Var_Up%
{
	if JoyR_Up_State
		return

	Send, %JoyR_Up_a% down}%JoyR_Up_b% down}
	JoyR_Up_State := true
	SetTimer, Joy_R_Up_up, 10
	return
}
else if JoyR > %R_Var_Dn%
{
	if JoyR_Dn_State
		return

	Send, %JoyR_Dn_a% down}%JoyR_Dn_b% down}
	JoyR_Dn_State := true
	SetTimer, Joy_R_Dn_up, 10
	return
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy_Z_Lf_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ < %Z_Var_Lf%
		return

	JoyZ_Lf_State := ""
	SetTimer, Joy_Z_Lf_up, Off
	Send, %JoyZ_Lf_a% up}%JoyZ_Lf_b% up}
	return
}
return

Joy_Z_Rt_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ > %Z_Var_Rt%
		return

	JoyZ_Rt_State := ""
	SetTimer, Joy_Z_Rt_up, Off
	Send, %JoyZ_Rt_a% up}%JoyZ_Rt_b% up}
	return
}
return

Joy_R_Up_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR < %R_Var_Up%
		return

	JoyR_Up_State := ""
	SetTimer, Joy_R_Up_up, Off
	Send, %JoyR_Up_a% up}%JoyR_Up_b% up}
	return
}
return

Joy_R_Dn_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR > %R_Var_Dn%
		return

	JoyR_Dn_State := ""
	SetTimer, Joy_R_Dn_up, Off
	Send, %JoyR_Dn_a% up}%JoyR_Dn_b% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Script 3: Key-variables are bound to the left analog stick, and mouse functionality is assigned to the right analog stick.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with mouse movement assigned to the right analog stick and keybinds assigned to the left analog stick.

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!   CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

Joy_Counter = 2



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
JoyPOV_N := "{Up"		; D-Pad-North/Up.
JoyPOV_S := "{Down"		; D-Pad-South/Down.
JoyPOV_W := "{Left"		; D-Pad-West/Left.
JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_X = 5	; Decrease to reduce required displacement.
Req_Disp_Y = 5	; (same as above).

Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick keybinds.

JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
JoyX_Lf_a := "{Left"	; Left-Stick: Left.
JoyX_Lf_b := "{F25"		; (nested within the above)
JoyX_Rt_a := "{Right"	; Left-Stick: Right.
JoyX_Rt_b := "{F25"		; (nested within the above)
JoyY_Up_a := "{Up"		; Left-Stick: Up.
JoyY_Up_b := "{F25"		; (nested within the above)
JoyY_Dn_a := "{Down"	; Left-Stick: Down.
JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_R = 1	; (same as above).

; Speed of pointer-travel.

Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_Z = 5	; Decrease to reduce required displacement.
Req_Disp_R = 5	; (same as above).

Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick Mod-Key.

JoyZR_Mod := "{F25"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

Joy1_a := "{LButton"	; X, on an XBOX Controller.
Joy1_b := "{x"			; (nested within the above)
Joy2_a := "{MButton"	; A, on an XBOX Controller.
Joy2_b := "{a"			; (nested within the above)
Joy3_a := "{RButton"	; B, on an XBOX Controller.
Joy3_b := "{b"			; (nested within the above)
Joy4_a := "{F25"		; Y, on an XBOX Controller.
Joy4_b := "{y"			; (nested within the above)
Joy5_a := "{["			; LB, on an XBOX Controller.
Joy5_b := "{Shift"		; (nested within the above)
Joy6_a := "{]"			; RB, on an XBOX Controller.
Joy6_b := "{Del"		; (nested within the above)
Joy7_a := "{l"			; LT, on an XBOX Controller.
Joy7_b := "{Alt"		; (nested within the above)
Joy8_a := "{r"			; RT, on an XBOX Controller.
Joy8_b := "{Ctrl"		; (nested within the above)
Joy9_a := "{F25"		; Select, on many Controllers.
Joy9_b := "{Tab"		; (nested within the above)
Joy10_a := "{F25"		; Start, on many Controllers.
Joy10_b := "{Esc"		; (nested within the above)
Joy11_a := "{Shift"		; L3, on many Controllers.
Joy11_b := "{F1"		; (nested within the above)
Joy12_a := "{F25"		; R3, on many Controllers.
Joy12_b := "{F1"		; (nested within the above)



; END OF CUSTOMIZABLE VARIABLE SECTION!!!   NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



X_Var_Lf := 50 - Req_Disp_X
X_Var_Rt := 50 + Req_Disp_X
Y_Var_Up := 50 - Req_Disp_Y
Y_Var_Dn := 50 + Req_Disp_Y

X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

Z_Var_Lf := 50 - Req_Disp_Z
Z_Var_Rt := 50 + Req_Disp_Z
R_Var_Up := 50 - Req_Disp_R
R_Var_Dn := 50 + Req_Disp_R

Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
R_Var_Up_Mod := 50 - Req_Disp_R_Mod
R_Var_Dn_Mod := 50 + Req_Disp_R_Mod

SetTimer, Joy_POV_Mod, 10

SetTimer, Joy_POV_NS, 10

SetTimer, Joy_POV_WE, 10

SetTimer, Joy_XY_Mod, 10

SetTimer, Joy_X, 10

SetTimer, Joy_Y, 10

SetTimer, Joy_ZR_Mod, 10

SetTimer, Joy_ZR, 10

return	; End of auto-execute.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}

Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_X:
JoyX := GetKeyState("JoyX")
if JoyX < %X_Var_Lf%
{
	if JoyX_Lf_State
		return

	Send, %JoyX_Lf_a% down}%JoyX_Lf_b% down}
	JoyX_Lf_State := true
	SetTimer, Joy_X_Lf_up, 10
	return
}
else if JoyX > %X_Var_Rt%
{
	if JoyX_Rt_State
		return

	Send, %JoyX_Rt_a% down}%JoyX_Rt_b% down}
	JoyX_Rt_State := true
	SetTimer, Joy_X_Rt_up, 10
	return
}
return

Joy_Y:
JoyY := GetKeyState("JoyY")
if JoyY < %Y_Var_Up%
{
	if JoyY_Up_State
		return

	Send, %JoyY_Up_a% down}%JoyY_Up_b% down}
	JoyY_Up_State := true
	SetTimer, Joy_Y_Up_up, 10
	return
}
else if JoyY > %Y_Var_Dn%
{
	if JoyY_Dn_State
		return

	Send, %JoyY_Dn_a% down}%JoyY_Dn_b% down}
	JoyY_Dn_State := true
	SetTimer, Joy_Y_Dn_up, 10
	return
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_ZR:
Joy_ZR_Move := false
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if JoyZ < %Z_Var_Lf%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Lf
}
else if JoyZ > %Z_Var_Rt%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Rt
}
else
	Z_Delta = 0

if JoyR < %R_Var_Up%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Up
}
else if JoyR > %R_Var_Dn%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Dn
}
else
	R_Delta = 0

if Joy_ZR_Move
{
	MouseMove, Z_Delta * Mouse_Speed_Z * Invert_Z, R_Delta * Mouse_Speed_R * Invert_R, 0, R
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_X_Lf_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX < %X_Var_Lf%
		return

	JoyX_Lf_State := ""
	SetTimer, Joy_X_Lf_up, Off
	Send, %JoyX_Lf_a% up}%JoyX_Lf_b% up}
	return
}
return

Joy_X_Rt_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX > %X_Var_Rt%
		return

	JoyX_Rt_State := ""
	SetTimer, Joy_X_Rt_up, Off
	Send, %JoyX_Rt_a% up}%JoyX_Rt_b% up}
	return
}
return

Joy_Y_Up_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY < %Y_Var_Up%
		return

	JoyY_Up_State := ""
	SetTimer, Joy_Y_Up_up, Off
	Send, %JoyY_Up_a% up}%JoyY_Up_b% up}
	return
}
return

Joy_Y_Dn_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY > %Y_Var_Dn%
		return

	JoyY_Dn_State := ""
	SetTimer, Joy_Y_Dn_up, Off
	Send, %JoyY_Dn_a% up}%JoyY_Dn_b% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Script 4: No mouse functionality assigned to either analog stick. Rather, key-variables are bound to each stick's various axes points.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; Complete gamepad script with keybinds assigned to both analog sticks (separately).

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!   CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

Joy_Counter = 2



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
JoyPOV_N := "{Up"		; D-Pad-North/Up.
JoyPOV_S := "{Down"		; D-Pad-South/Down.
JoyPOV_W := "{Left"		; D-Pad-West/Left.
JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following fifteen variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_Y = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_X = 5	; Decrease to reduce required displacement.
Req_Disp_Y = 5	; (same as above).

Req_Disp_X_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_Y_Mod = 5	; (same as above).

; Left Analog Stick keybinds.

JoyXY_Mod := "{F25"		; Mods all Left-Stick output.
JoyX_Lf_a := "{Left"	; Left-Stick: Left.
JoyX_Lf_b := "{F25"		; (nested within the above)
JoyX_Rt_a := "{Right"	; Left-Stick: Right.
JoyX_Rt_b := "{F25"		; (nested within the above)
JoyY_Up_a := "{Up"		; Left-Stick: Up.
JoyY_Up_b := "{F25"		; (nested within the above)
JoyY_Dn_a := "{Down"	; Left-Stick: Down.
JoyY_Dn_b := "{F25"		; (nested within the above)



; Regarding the following fifteen variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_R = 1	; (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_Z = 5	; Decrease to reduce required displacement.
Req_Disp_R = 5	; (same as above).

Req_Disp_Z_Mod = 5	; Decrease to reduce required displacement.
Req_Disp_R_Mod = 5	; (same as above).

; Right Analog Stick keybinds.

JoyZR_Mod := "{F25"		; Mods all Right-Stick output.
JoyZ_Lf_a := "{Left"	; Right-Stick: Left.
JoyZ_Lf_b := "{F25"		; (nested within the above)
JoyZ_Rt_a := "{Right"	; Right-Stick: Right.
JoyZ_Rt_b := "{F25"		; (nested within the above)
JoyR_Up_a := "{Up"		; Right-Stick: Up.
JoyR_Up_b := "{F25"		; (nested within the above)
JoyR_Dn_a := "{Down"	; Right-Stick: Down.
JoyR_Dn_b := "{F25"		; (nested within the above)



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

Joy_Counter_Range := 0	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: Keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

Joy1_a := "{LButton"	; X, on an XBOX Controller.
Joy1_b := "{x"			; (nested within the above)
Joy2_a := "{MButton"	; A, on an XBOX Controller.
Joy2_b := "{a"			; (nested within the above)
Joy3_a := "{RButton"	; B, on an XBOX Controller.
Joy3_b := "{b"			; (nested within the above)
Joy4_a := "{F25"		; Y, on an XBOX Controller.
Joy4_b := "{y"			; (nested within the above)
Joy5_a := "{["			; LB, on an XBOX Controller.
Joy5_b := "{Shift"		; (nested within the above)
Joy6_a := "{]"			; RB, on an XBOX Controller.
Joy6_b := "{Del"		; (nested within the above)
Joy7_a := "{l"			; LT, on an XBOX Controller.
Joy7_b := "{Alt"		; (nested within the above)
Joy8_a := "{r"			; RT, on an XBOX Controller.
Joy8_b := "{Ctrl"		; (nested within the above)
Joy9_a := "{F25"		; Select, on many Controllers.
Joy9_b := "{Tab"		; (nested within the above)
Joy10_a := "{F25"		; Start, on many Controllers.
Joy10_b := "{Esc"		; (nested within the above)
Joy11_a := "{Shift"		; L3, on many Controllers.
Joy11_b := "{F1"		; (nested within the above)
Joy12_a := "{F25"		; R3, on many Controllers.
Joy12_b := "{F1"		; (nested within the above)



; END OF CUSTOMIZABLE VARIABLE SECTION!!!   NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



X_Var_Lf := 50 - Req_Disp_X
X_Var_Rt := 50 + Req_Disp_X
Y_Var_Up := 50 - Req_Disp_Y
Y_Var_Dn := 50 + Req_Disp_Y

X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

Z_Var_Lf := 50 - Req_Disp_Z
Z_Var_Rt := 50 + Req_Disp_Z
R_Var_Up := 50 - Req_Disp_R
R_Var_Dn := 50 + Req_Disp_R

Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
R_Var_Up_Mod := 50 - Req_Disp_R_Mod
R_Var_Dn_Mod := 50 + Req_Disp_R_Mod

SetTimer, Joy_POV_Mod, 10

SetTimer, Joy_POV_NS, 10

SetTimer, Joy_POV_WE, 10

SetTimer, Joy_XY_Mod, 10

SetTimer, Joy_X, 10

SetTimer, Joy_Y, 10

SetTimer, Joy_ZR_Mod, 10

SetTimer, Joy_Z, 10

SetTimer, Joy_R, 10

return	; End of auto-execute.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}

Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_X:
JoyX := GetKeyState("JoyX")
if JoyX < %X_Var_Lf%
{
	if JoyX_Lf_State
		return

	Send, %JoyX_Lf_a% down}%JoyX_Lf_b% down}
	JoyX_Lf_State := true
	SetTimer, Joy_X_Lf_up, 10
	return
}
else if JoyX > %X_Var_Rt%
{
	if JoyX_Rt_State
		return

	Send, %JoyX_Rt_a% down}%JoyX_Rt_b% down}
	JoyX_Rt_State := true
	SetTimer, Joy_X_Rt_up, 10
	return
}
return

Joy_Y:
JoyY := GetKeyState("JoyY")
if JoyY < %Y_Var_Up%
{
	if JoyY_Up_State
		return

	Send, %JoyY_Up_a% down}%JoyY_Up_b% down}
	JoyY_Up_State := true
	SetTimer, Joy_Y_Up_up, 10
	return
}
else if JoyY > %Y_Var_Dn%
{
	if JoyY_Dn_State
		return

	Send, %JoyY_Dn_a% down}%JoyY_Dn_b% down}
	JoyY_Dn_State := true
	SetTimer, Joy_Y_Dn_up, 10
	return
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_Z:
JoyZ := GetKeyState("JoyZ")
if JoyZ < %Z_Var_Lf%
{
	if JoyZ_Lf_State
		return

	Send, %JoyZ_Lf_a% down}%JoyZ_Lf_b% down}
	JoyZ_Lf_State := true
	SetTimer, Joy_Z_Lf_up, 10
	return
}
else if JoyZ > %Z_Var_Rt%
{
	if JoyZ_Rt_State
		return

	Send, %JoyZ_Rt_a% down}%JoyZ_Rt_b% down}
	JoyZ_Rt_State := true
	SetTimer, Joy_Z_Rt_up, 10
	return
}
return

Joy_R:
JoyR := GetKeyState("JoyR")
if JoyR < %R_Var_Up%
{
	if JoyR_Up_State
		return

	Send, %JoyR_Up_a% down}%JoyR_Up_b% down}
	JoyR_Up_State := true
	SetTimer, Joy_R_Up_up, 10
	return
}
else if JoyR > %R_Var_Dn%
{
	if JoyR_Dn_State
		return

	Send, %JoyR_Dn_a% down}%JoyR_Dn_b% down}
	JoyR_Dn_State := true
	SetTimer, Joy_R_Dn_up, 10
	return
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_X_Lf_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX < %X_Var_Lf%
		return

	JoyX_Lf_State := ""
	SetTimer, Joy_X_Lf_up, Off
	Send, %JoyX_Lf_a% up}%JoyX_Lf_b% up}
	return
}
return

Joy_X_Rt_up:
JoyX := GetKeyState("JoyX")
{
	if JoyX > %X_Var_Rt%
		return

	JoyX_Rt_State := ""
	SetTimer, Joy_X_Rt_up, Off
	Send, %JoyX_Rt_a% up}%JoyX_Rt_b% up}
	return
}
return

Joy_Y_Up_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY < %Y_Var_Up%
		return

	JoyY_Up_State := ""
	SetTimer, Joy_Y_Up_up, Off
	Send, %JoyY_Up_a% up}%JoyY_Up_b% up}
	return
}
return

Joy_Y_Dn_up:
JoyY := GetKeyState("JoyY")
{
	if JoyY > %Y_Var_Dn%
		return

	JoyY_Dn_State := ""
	SetTimer, Joy_Y_Dn_up, Off
	Send, %JoyY_Dn_a% up}%JoyY_Dn_b% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy_Z_Lf_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ < %Z_Var_Lf%
		return

	JoyZ_Lf_State := ""
	SetTimer, Joy_Z_Lf_up, Off
	Send, %JoyZ_Lf_a% up}%JoyZ_Lf_b% up}
	return
}
return

Joy_Z_Rt_up:
JoyZ := GetKeyState("JoyZ")
{
	if JoyZ > %Z_Var_Rt%
		return

	JoyZ_Rt_State := ""
	SetTimer, Joy_Z_Rt_up, Off
	Send, %JoyZ_Rt_a% up}%JoyZ_Rt_b% up}
	return
}
return

Joy_R_Up_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR < %R_Var_Up%
		return

	JoyR_Up_State := ""
	SetTimer, Joy_R_Up_up, Off
	Send, %JoyR_Up_a% up}%JoyR_Up_b% up}
	return
}
return

Joy_R_Dn_up:
JoyR := GetKeyState("JoyR")
{
	if JoyR > %R_Var_Dn%
		return

	JoyR_Dn_State := ""
	SetTimer, Joy_R_Dn_up, Off
	Send, %JoyR_Dn_a% up}%JoyR_Dn_b% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return
Last edited by Simon Belmont on 10 Apr 2023, 06:16, edited 3 times in total.

User avatar
Simon Belmont
Posts: 19
Joined: 03 Dec 2020, 00:14

Re: Gamepad Script, Four Versions

Post by Simon Belmont » 29 Mar 2023, 03:12

For anyone who just wants to 'dip a toe' into one of these gamepad scripts, here's a 'no-mode' version of Script 1 that I configured for DOOM, DOOM II & Final DOOM (the default, un-modded [GOG] versions of each game).

I use a Logitech F510 controller, which features a 'PlayStation-esque' layout. But this should work just fine with any current-gen controller.

Code: Select all

#HotkeyInterval, 99000000
#KeyHistory, 0
#MaxHotkeysPerInterval, 99000000
#NoEnv
#Persistent
#SingleInstance, Force
#Warn, UseUnsetGlobal, Off
ListLines, Off
Process, Priority, , A
SendMode, Input
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWorkingDir, %A_ScriptDir%
Thread, Interrupt, -1, -1
Thread, NoTimers, false



; GENERAL NOTES: READ THEM!!!



; [Configured for DOOM, DOOM II & Final DOOM]

; D-Pad					/	Basic, 4-directional movement
; Left Analog Stick		/	Quick, analog 4-directional movement
; Right Analog Stick	/	Quick, analog 4-directional movement with an Alt mod-key, for strafing.

; Joy1		/	X		/	Square		/	[Left Mouse Button (enter & fire)] <<< Tap VERY lightly when using this button to Load a game! >>>
; Joy2		/	A		/	Cross		/	[f (unlock map & movement)] & [Space (opens doors, uses switches, etc)]
; Joy3		/	B		/	Circle		/	"No" & [Right Mouse Button (hold to strafe, double-click to interact)]
; Joy4		/	Y		/	Triangle	/	"Yes" & Sends Counter-output, to toggle between weapons using the same number.
; Joy5		/	LB		/	L1			/	Toggles Counter down.
; Joy6		/	RB		/	R1			/	Toggles Counter up.
; Joy7		/	LT		/	L2			/	[Alt (hold to strafe)]
; Joy8		/	RT		/	R2			/	[Ctrl (fire)]
; Joy9		/	Back	/	Select		/	[Tab (map)]
; Joy10		/	Start	/	Start		/	[Esc (menu)]
; Joy11		/	L3		/	L3			/	[F6 (quick-save)]
; Joy12		/	R3		/	R3			/	[F9 (quick-load)]



; Complete gamepad script with mouse movement assigned to both analog sticks (separately).

; Right Control + Home reloads the script. Right Control + End closes the script.

; An optional regressive/progressive, 1 to %var% (max: 10), counter is included (more details on that feature are given just above the relevant variables).

; POV-Hat (D-Pad) has four cardinal directions; relying upon combined cardinals to achieve diagonals.

; Each directional input-method (D-Pad, L-Stick, R-Stick) has the option of an assignable, constant mod-key; which applies to all output associated with that input-method. This comes in handy in games which require you to hold down a certain button or key to run, as opposed to walking slowly.

; I have (for testing) bound Left, Middle & Right Click to Joy1 (X), Joy2 (A) & Joy3 (B), respectively; as well as bound other keys to all other gamepad buttons. Any of these can, of course, be reassigned below. I encourage you do so! It is highly unlikely that good results will had, without first customizing the keybind-variables to best suit the application.

; Use "{F25" (or higher) to leave any keybind "blank".

; For information on specific Key names consult AutoHotkey's help files. Search for: "Send" or "Keys".



; END OF GENERAL NOTES!!!   CUSTOMIZABLE VARIABLE SECTION BELLOW!!!



; Regarding the following single variable: any number between 1 and %var% (max: 10) is fine here. I use 2 because that is the default weapon in DOOM. If you do not enable the bellow Counter feature, this variable will be unused.

Joy_Counter = 2



; Regarding the following five variables: D-Pad (POV Hat) keybinds and their optional universal mod-key.

JoyPOV_Mod := "{F25"	; Mods all D-Pad output.
JoyPOV_N := "{Up"		; D-Pad-North/Up.
JoyPOV_S := "{Down"		; D-Pad-South/Down.
JoyPOV_W := "{Left"		; D-Pad-West/Left.
JoyPOV_E := "{Right"	; D-Pad-East/Right.



; Regarding the following nine variables: Left Analog Stick function & responsiveness.

; Inverted, or not.

Invert_X = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_Y = 1	; (same as above).

; Speed of pointer-travel.

Mouse_Speed_X = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
Mouse_Speed_Y = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_X = 5	; Decrease to reduce required displacement.
Req_Disp_Y = 5	; (same as above).

Req_Disp_X_Mod = 3	; Decrease to reduce required displacement.
Req_Disp_Y_Mod = 3	; (same as above).

; Left Analog Stick Mod-Key.

JoyXY_Mod := "{F25"	; Mods all Left-Stick output.



; Regarding the following nine variables: Right Analog Stick function & responsiveness.

; Inverted, or not.

Invert_Z = 1	; Normal Axis = 1. Inverted Axis = -1.
Invert_R = 1	; (same as above).

; Speed of pointer-travel.

Mouse_Speed_Z = 1.06	; Horizontal Speed (1 ≈ 2500 DPI, sort of).
Mouse_Speed_R = 0.60	; Vertical Speed (same as above).

; Sensitivity. Regard these values as percentages (%). Setting the mod-variable higher than the non-mod-variable can produce a dynamic effect.

Req_Disp_Z = 5	; Decrease to reduce required displacement.
Req_Disp_R = 5	; (same as above).

Req_Disp_Z_Mod = 3	; Decrease to reduce required displacement.
Req_Disp_R_Mod = 3	; (same as above).

; Right Analog Stick Mod-Key.

JoyZR_Mod := "{Alt"	; Mods all Right-Stick output.



; The below variable is an optional Counter, primarily for FPS games which use keyboard number-keys to access various weapons. While enabled, Joy5 (Left Bumper) and Joy6 (Right Bumper) regress and progress, respectively, a numeric counter from 1 to %Joy_Counter_Range% (max: 10), and send the resulting number as a key-press. Meanwhile, Joy4 (Y on an XBOX controller) will also send the same key-press, without influencing the counter. Having the ability to send the same number repeatedly, without influencing the counter, is essential in games like Doom II, Final Doom, StarWars: Dark Forces, etc. Joy4 (Y), Joy5 (Left Bumper) & Joy6 (Right Bumper)'s below-keybinds will continue to function as always, regardless of whether or not the Counter is used. As stated at the beginning of this script, set any keybind that you want to remain "blank" to "{F25" (or higher).

Joy_Counter_Range := 7	; Disabled: 0, Lowest: 1, Highest: 10.



; Regarding the following twenty-four variables: keybinds for C-Buttons, Front Buttons, "Start" & "Select" and Left & Right Analog Stick Buttons.

	Joy1_a := "{F25"		; X, on an XBOX Controller.
	Joy1_b := "{LButton"	; (nested)
	Joy2_a := "{f"			; A, on an XBOX Controller.
	Joy2_b := "{Space"		; (nested)
	Joy3_a := "{n"			; B, on an XBOX Controller.
	Joy3_b := "{RButton"	; (nested)
	Joy4_a := "{y"			; Y, on an XBOX Controller.
	Joy4_b := "{F25"		; (nested)
	Joy5_a := "{F25"		; LB, on an XBOX Controller (Counter, Scrolls Down).
	Joy5_b := "{F25"		; (nested, superfluous)
	Joy6_a := "{F25"		; RB, on an XBOX Controller (Counter, Scrolls Up).
	Joy6_b := "{F25"		; (nested, superfluous)
	Joy7_a := "{F25"		; LT, on an XBOX Controller.
	Joy7_b := "{Alt"		; (nested)
	Joy8_a := "{F25"		; RT, on an XBOX Controller.
	Joy8_b := "{Ctrl"		; (nested)
	Joy9_a := "{F25"		; Select, on many Controllers.
	Joy9_b := "{Tab"		; (nested)
	Joy10_a := "{F25"		; Start, on many Controllers.
	Joy10_b := "{Esc"		; (nested)
	Joy11_a := "{F25"		; L3, on many Controllers.
	Joy11_b := "{F6"		; (nested)
	Joy12_a := "{F25"		; R3, on many Controllers.
	Joy12_b := "{F9"		; (nested)



; END OF CUSTOMIZABLE VARIABLE SECTION!!!   NO CHANGES BELOW THIS POINT SHOULD BE NECESARY!!!



X_Var_Lf := 50 - Req_Disp_X
X_Var_Rt := 50 + Req_Disp_X
Y_Var_Up := 50 - Req_Disp_Y
Y_Var_Dn := 50 + Req_Disp_Y

X_Var_Lf_Mod := 50 - Req_Disp_X_Mod
X_Var_Rt_Mod := 50 + Req_Disp_X_Mod
Y_Var_Up_Mod := 50 - Req_Disp_Y_Mod
Y_Var_Dn_Mod := 50 + Req_Disp_Y_Mod

Z_Var_Lf := 50 - Req_Disp_Z
Z_Var_Rt := 50 + Req_Disp_Z
R_Var_Up := 50 - Req_Disp_R
R_Var_Dn := 50 + Req_Disp_R

Z_Var_Lf_Mod := 50 - Req_Disp_Z_Mod
Z_Var_Rt_Mod := 50 + Req_Disp_Z_Mod
R_Var_Up_Mod := 50 - Req_Disp_R_Mod
R_Var_Dn_Mod := 50 + Req_Disp_R_Mod

SetTimer, Joy_POV_Mod, 10

SetTimer, Joy_POV_NS, 10

SetTimer, Joy_POV_WE, 10

SetTimer, Joy_XY_Mod, 10

SetTimer, Joy_XY, 10

SetTimer, Joy_ZR_Mod, 10

SetTimer, Joy_ZR, 10

return	; End of auto-execute.

>^Home::
{
	Reload
}

>^End::
{
	ExitApp
}

Joy_POV_Mod:
POV := GetKeyState("JoyPOV")
if (POV >= 00000 and POV <=36000)	; Any Input
{
	if JoyPOV_Mod_State
		return

	Send, %JoyPOV_Mod% down}
	JoyPOV_Mod_State := true
	SetTimer, Joy_POV_Mod_up, 10
	return
}
return

Joy_POV_NS:
POV := GetKeyState("JoyPOV")
if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
{
	if JoyPOV_N_State
		return

	Send, %JoyPOV_N% down}
	JoyPOV_N_State := true
	SetTimer, Joy_POV_N_up, 10
	return
}
else if (POV >= 13500 and POV <= 22500)	; South/Down
{
	if JoyPOV_S_State
		return

	Send, %JoyPOV_S% down}
	JoyPOV_S_State := true
	SetTimer, Joy_POV_S_up, 10
	return
}
return

Joy_POV_WE:
POV := GetKeyState("JoyPOV")
if (POV >= 22500 and POV <= 31500)	; West/Left
{
	if JoyPOV_W_State
		return

	Send, %JoyPOV_W% down}
	JoyPOV_W_State := true
	SetTimer, Joy_POV_W_up, 10
	return
}
else if (POV >= 04500 and POV <= 13500)	; East/Right
{
	if JoyPOV_E_State
		return

	Send, %JoyPOV_E% down}
	JoyPOV_E_State := true
	SetTimer, Joy_POV_E_up, 10
	return
}
return

Joy_XY_Mod:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
{
	if JoyXY_Mod_State
		return

	Send, %JoyXY_Mod% down}
	JoyXY_Mod_State := true
	SetTimer, Joy_XY_Mod_up, 10
	return
}
return

Joy_XY:
Joy_XY_Move := false
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
if JoyX < %X_Var_Lf%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Lf
}
else if JoyX > %X_Var_Rt%
{
	Joy_XY_Move := true
	X_Delta := JoyX - X_Var_Rt
}
else
	X_Delta = 0

if JoyY < %Y_Var_Up%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Up
}
else if JoyY > %Y_Var_Dn%
{
	Joy_XY_Move := true
	Y_Delta := JoyY - Y_Var_Dn
}
else
	Y_Delta = 0

if Joy_XY_Move
{
	MouseMove, X_Delta * Mouse_Speed_X * Invert_X, Y_Delta * Mouse_Speed_Y * Invert_Y, 0, R
}
return

Joy_ZR_Mod:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
{
	if JoyZR_Mod_State
		return

	Send, %JoyZR_Mod% down}
	JoyZR_Mod_State := true
	SetTimer, Joy_ZR_Mod_up, 10
	return
}
return

Joy_ZR:
Joy_ZR_Move := false
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
if JoyZ < %Z_Var_Lf%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Lf
}
else if JoyZ > %Z_Var_Rt%
{
	Joy_ZR_Move := true
	Z_Delta := JoyZ - Z_Var_Rt
}
else
	Z_Delta = 0

if JoyR < %R_Var_Up%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Up
}
else if JoyR > %R_Var_Dn%
{
	Joy_ZR_Move := true
	R_Delta := JoyR - R_Var_Dn
}
else
	R_Delta = 0

if Joy_ZR_Move
{
	MouseMove, Z_Delta * Mouse_Speed_Z * Invert_Z, R_Delta * Mouse_Speed_R * Invert_R, 0, R
}
return

Joy1::
{
	if Joy1_State
		return

	Send, %Joy1_a% down}%Joy1_b% down}
	Joy1_State := true
	SetTimer, Joy1_up, 10
	return
}

Joy2::
{
	if Joy2_State
		return

	Send, %Joy2_a% down}%Joy2_b% down}
	Joy2_State := true
	SetTimer, Joy2_up, 10
	return
}

Joy3::
{
	if Joy3_State
		return

	Send, %Joy3_a% down}%Joy3_b% down}
	Joy3_State := true
	SetTimer, Joy3_up, 10
	return
}

Joy4::
{
	if Joy_Counter_Range != 0
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}{%Joy_Counter% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
	else
	{
		if Joy4_State
			return

		Send, %Joy4_a% down}%Joy4_b% down}
		Joy4_State := true
		SetTimer, Joy4_up, 10
		return
	}
}

Joy5::
{
	if Joy_Counter_Range != 0
	{
		if Joy5_State
			return

		Joy_Counter -= 1

		if (Joy_Counter_Range = 10) and (Joy_Counter < 0)
		{
			Joy_Counter = 9
		}
		else if (Joy_Counter_Range != 10) and (Joy_Counter < 1)
		{
			Joy_Counter := Joy_Counter_Range
		}

		Send, %Joy5_a% down}%Joy5_b% down}{%Joy_Counter% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
	else
	{
		if Joy5_State
			return

		Send, %Joy5_a% down}%Joy5_b% down}
		Joy5_State := true
		SetTimer, Joy5_up, 10
		return
	}
}

Joy6::
{
	if Joy_Counter_Range != 0
	{
		if Joy6_State
			return

		Joy_Counter += 1

		if Joy_Counter > %Joy_Counter_Range%
		{
			Joy_Counter = 1
		}

		if Joy_Counter = 10
		{
			Joy_Counter = 0
		}

		Send, %Joy6_a% down}%Joy6_b% down}{%Joy_Counter% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
	else
	{
		if Joy6_State
			return

		Send, %Joy6_a% down}%Joy6_b% down}
		Joy6_State := true
		SetTimer, Joy6_up, 10
		return
	}
}

Joy7::
{
	if Joy7_State
		return

	Send, %Joy7_a% down}%Joy7_b% down}
	Joy7_State := true
	SetTimer, Joy7_up, 10
	return
}

Joy8::
{
	if Joy8_State
		return

	Send, %Joy8_a% down}%Joy8_b% down}
	Joy8_State := true
	SetTimer, Joy8_up, 10
	return
}

Joy9::
{
	if Joy9_State
		return

	Send, %Joy9_a% down}%Joy9_b% down}
	Joy9_State := true
	SetTimer, Joy9_up, 10
	return
}

Joy10::
{
	if Joy10_State
		return

	Send, %Joy10_a% down}%Joy10_b% down}
	Joy10_State := true
	SetTimer, Joy10_up, 10
	return
}

Joy11::
{
	if Joy11_State
		return

	Send, %Joy11_a% down}%Joy11_b% down}
	Joy11_State := true
	SetTimer, Joy11_up, 10
	return
}

Joy12::
{
	if Joy12_State
		return

	Send, %Joy12_a% down}%Joy12_b% down}
	Joy12_State := true
	SetTimer, Joy12_up, 10
	return
}

Joy_POV_Mod_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 00000 and POV <=36000)	; Any Input
		return

	JoyPOV_Mod_State := ""
	SetTimer, Joy_POV_Mod_up, Off
	Send, %JoyPOV_Mod% up}
	return
}
return

Joy_POV_N_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 31500 and POV <= 36000) or (POV >= 00000 and POV <= 04500)	; North/Up
		return

	JoyPOV_N_State := ""
	SetTimer, Joy_POV_N_up, Off
	Send, %JoyPOV_N% up}
	return
}
return

Joy_POV_S_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 13500 and POV <= 22500)	; South/Down
		return

	JoyPOV_S_State := ""
	SetTimer, Joy_POV_S_up, Off
	Send, %JoyPOV_S% up}
	return
}
return

Joy_POV_W_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 22500 and POV <= 31500)	; West/Left
		return

	JoyPOV_W_State := ""
	SetTimer, Joy_POV_W_up, Off
	Send, %JoyPOV_W% up}
	return
}
return

Joy_POV_E_up:
POV := GetKeyState("JoyPOV")
{
	if (POV >= 04500 and POV <= 13500)	; East/Right
		return

	JoyPOV_E_State := ""
	SetTimer, Joy_POV_E_up, Off
	Send, %JoyPOV_E% up}
	return
}
return

Joy_XY_Mod_up:
JoyX := GetKeyState("JoyX")
JoyY := GetKeyState("JoyY")
{
	if (JoyX < X_Var_Lf_Mod) or (JoyX > X_Var_Rt_Mod) or (JoyY < Y_Var_Up_Mod) or (JoyY > Y_Var_Dn_Mod)	; Any Input
		return

	JoyXY_Mod_State := ""
	SetTimer, Joy_XY_Mod_up, Off
	Send, %JoyXY_Mod% up}
	return
}
return

Joy_ZR_Mod_up:
JoyZ := GetKeyState("JoyZ")
JoyR := GetKeyState("JoyR")
{
	if (JoyZ < Z_Var_Lf_Mod) or (JoyZ > Z_Var_Rt_Mod) or (JoyR < R_Var_Up_Mod) or (JoyR > R_Var_Dn_Mod)	; Any Input
		return

	JoyZR_Mod_State := ""
	SetTimer, Joy_ZR_Mod_up, Off
	Send, %JoyZR_Mod% up}
	return
}
return

Joy1_up:
{
	if GetKeyState("Joy1")
		return

	Joy1_State := ""
	SetTimer, Joy1_up, Off
	Send, %Joy1_b% up}%Joy1_a% up}
	return
}
return

Joy2_up:
{
	if GetKeyState("Joy2")
		return

	Joy2_State := ""
	SetTimer, Joy2_up, Off
	Send, %Joy2_b% up}%Joy2_a% up}
	return
}
return

Joy3_up:
{
	if GetKeyState("Joy3")
		return

	Joy3_State := ""
	SetTimer, Joy3_up, Off
	Send, %Joy3_b% up}%Joy3_a% up}
	return
}
return

Joy4_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, {%Joy_Counter% up}%Joy4_b% up}%Joy4_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy4")
			return

		Joy4_State := ""
		SetTimer, Joy4_up, Off
		Send, %Joy4_b% up}%Joy4_a% up}
		return
	}
}
return

Joy5_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, {%Joy_Counter% up}%Joy5_b% up}%Joy5_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy5")
			return

		Joy5_State := ""
		SetTimer, Joy5_up, Off
		Send, %Joy5_b% up}%Joy5_a% up}
		return
	}
}
return

Joy6_up:
{
	if Joy_Counter_Range != 0
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, {%Joy_Counter% up}%Joy6_b% up}%Joy6_a% up}
		return
	}
	else
	{
		if GetKeyState("Joy6")
			return

		Joy6_State := ""
		SetTimer, Joy6_up, Off
		Send, %Joy6_b% up}%Joy6_a% up}
		return
	}
}
return

Joy7_up:
{
	if GetKeyState("Joy7")
		return

	Joy7_State := ""
	SetTimer, Joy7_up, Off
	Send, %Joy7_b% up}%Joy7_a% up}
	return
}
return

Joy8_up:
{
	if GetKeyState("Joy8")
		return

	Joy8_State := ""
	SetTimer, Joy8_up, Off
	Send, %Joy8_b% up}%Joy8_a% up}
	return
}
return

Joy9_up:
{
	if GetKeyState("Joy9")
		return

	Joy9_State := ""
	SetTimer, Joy9_up, Off
	Send, %Joy9_b% up}%Joy9_a% up}
	return
}
return

Joy10_up:
{
	if GetKeyState("Joy10")
		return

	Joy10_State := ""
	SetTimer, Joy10_up, Off
	Send, %Joy10_b% up}%Joy10_a% up}
	return
}
return

Joy11_up:
{
	if GetKeyState("Joy11")
		return

	Joy11_State := ""
	SetTimer, Joy11_up, Off
	Send, %Joy11_b% up}%Joy11_a% up}
	return
}
return

Joy12_up:
{
	if GetKeyState("Joy12")
		return

	Joy12_State := ""
	SetTimer, Joy12_up, Off
	Send, %Joy12_b% up}%Joy12_a% up}
	return
}
return

Post Reply

Return to “Gaming Scripts (v1)”