What it does: It's software-written precision aim for FPS games, when you play using a controller (Tested using Xbox 360 controller for win, would work with other controllers with a Z axis for LB and a right analogue stick).
Which games it will work with: First Person Shooters which use the mouse to aim, that will accept the method of mouse movement. Tested on Battlefield 3 and theHunter. Found no issue with compiled version and punkbuster? I've heard there could be one.
Why I wrote it: Okay, so I've recently bought a gaming rig, I bought battlefield 3 and theHunter and I like to play them using an xbox controller (i guess I'm a console gamer at heart)...
I tend to play as recon and I found that the joystick sensitivity wouldn't balance, i.e. it's either not sensitive enough when hip firing or it's too sensitive when lining up a shot (you have to go back and forth a lot to try and hit the right place)... This was similar for
How it works: When you hold down LB (Past a certain threshold) it works out how much pressure is on LB and moves the mouse slower based on that.
Description of options: To make the script as adaptable as possible I've made the key values into adjustable variables (So that you can make the precision and when it kicks in just right) There are some defaults that i think work quite well but here's a description of the adjustable variables so that you don't have to track them down to understand what they do:
Joystick Threshold - The amount you have to move the right analogue stick before the mouse starts moving. Included because battlefield 3 can "stray" a little using an xbox 360 controller, 7 works well as a default value on my own but it depends on your calibration.
Sensitivity - The default sensitivity (I.E. The mouse sensitivity for hip firing or firing without precision aim)
PrecisionLB - The sensitivity for when you've got LB pressed half way (Where to start precision)
Precise Sensitivity - The Sensitivity for when LB is pressed all the way (The program will work out a difference between PrecisionLB and Precise sensitivity so that the amount of pressure on LB directly correlates to the amount of precision)
Trigger Threshold - After how much pressure on LB should the precision aiming kick in
Trigger Deadzone - After how much pressure on LB should the program be at full precision.
Hope someone finds it useful, it's a bit specific for us who like to use joypads and FPSes on Pc.
Cheers,
Jamey
The Script(Also Uploaded compiled version here: http://www.mediafire...991cv9h2t9jdqun):
-Requires Xinput.ahk to be in the same folder (Not in compiled version) (http://www.autohotke...pic.php?t=39091)
- Requires json.ahk to be in the same folder (Not in compiled version) (http://www.autohotke...pic.php?t=34565)
#include xinput.ahk
#include json.ahk
#SingleInstance
#persistent
#NoTrayIcon
IfNotExist opts.ini
{
IniWrite, 1, opts.ini, MousePrecision, Enabled
IniWrite, 7, opts.ini, MousePrecision, Threshold
IniWrite, 250, opts.ini, MousePrecision, TriggerThreshold
IniWrite, 60, opts.ini, MousePrecision, Sensitivity
IniWrite, 2, opts.ini, MousePrecision, Precision
IniWrite, 48, opts.ini, MousePrecision, PrecisionLB
IniWrite, 100, opts.ini, MousePrecision, ThresholdLB
}
;Read options From Ini File
IniRead, MouseEnabled, opts.ini, MousePrecision, Enabled
IniRead, Threshold, opts.ini, MousePrecision, Threshold
IniRead, TThreshold, opts.ini, MousePrecision, TriggerThreshold
IniRead, Sensitivity, opts.ini, MousePrecision, Sensitivity
IniRead, Precise, opts.ini, MousePrecision, Precision
IniRead, PreciseLB, opts.ini, MousePrecision, PrecisionLB
IniRead, ThreshLB, opts.ini, MousePrecision, ThresholdLB
;Set them as globals
JoyMultiplier := Sensitivity/100
PrecisionMultiplier := Precise/100
JoyThreshold := Threshold
TriggerThreshold := TThreshold
;Lower Bounds/Biting Point
PrecisionLB := PreciseLB/100
ThresholdLB := ThreshLB
;Detect the joypad
JoystickNumber = 0
if JoystickNumber <= 0
{
Loop 16 ; Query each joystick number to find out which ones exist.
{
GetKeyState, JoyName, %A_Index%JoyName
if JoyName <>
{
JoystickNumber = %A_Index%
break
}
}
if JoystickNumber <= 0
{
MsgBox The system does not appear to have any joysticks.
ExitApp
}
}
; work out threshold for joystick movement
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
;Initialize XInput
XInput_Init()
;Initialize GUI
Gui, Add, Text,, Precision Aim for BF
if MouseEnabled = 1
{
Gui, Add, Checkbox, vMouseEnabled gToggleMouse Checked, Enabled?
Gui, Add, Text, vMouseLabel3, Joystick Threshold:
Gui, Add, Edit, vEdit3
Gui, Add, UpDown, vThreshold gChangeThreshold Range0-50, %Threshold%
Gui, Add, Text, vMouseLabel1, Sensitivity:
Gui, Add, Edit, vEdit1
Gui, Add, UpDown, vSensitivity gChangeSensitivity Range2-100, %Sensitivity%
Gui, Add, Text, vMouseLabel5, PreisionLB:
Gui, Add, Edit, vEdit5
Gui, Add, UpDown, vPreciseLB gChangePreciseLB Range2-100, %PreciseLB%
Gui, Add, Text, vMouseLabel2, Precise Sensitivity:
Gui, Add, Edit, vEdit2
Gui, Add, UpDown, vPrecise gChangePrecise Range2-100, %Precise%
Gui, Add, Text, vMouseLabel6, Trigger Threshold:
Gui, Add, Edit, vEdit6
Gui, Add, UpDown, vTThresholdLB gChangeTThresholdLB Range0-255, %ThreshLB%
Gui, Add, Text, vMouseLabel4, Trigger DeadZone:
Gui, Add, Edit, vEdit4
Gui, Add, UpDown, vTThreshold gChangeTThreshold Range0-255, %TriggerThreshold%
}
else
{
Gui, Add, Checkbox, vMouseEnabled gToggleMouse, Enabled?
Gui, Add, Text, vMouseLabel3 Disabled, Joystick Threshold:
Gui, Add, Edit, vEdit3 Disabled
Gui, Add, UpDown, vThreshold gChangeThreshold Disabled Range0-50, %Threshold%
Gui, Add, Text, vMouseLabel1 Disabled, Sensitivity:
Gui, Add, Edit, vEdit1 Disabled
Gui, Add, UpDown, vSensitivity gChangeSensitivity Range1-100 Disabled, %Sensitivity%
Gui, Add, Text, vMouseLabel5 Disabled, PreisionLB:
Gui, Add, Edit, vEdit5 Disabled
Gui, Add, UpDown, vPreciseLB Disabled gChangePreciseLB Range2-100, %PreciseLB%
Gui, Add, Text, vMouseLabel2 Disabled, Precise Sensitivity:
Gui, Add, Edit, vEdit2 Disabled
Gui, Add, UpDown, vPrecise gChangePrecise Range1-100 Disabled, %Precise%
Gui, Add, Text, vMouseLabel6 Disabled, Trigger Threshold:
Gui, Add, Edit, vEdit6 Disabled
Gui, Add, UpDown, vTThresholdLB Disabled gChangeTThresholdLB Range0-255, %ThreshLB%
Gui, Add, Text, vMouseLabel4 Disabled, Trigger DeadZone:
Gui, Add, Edit, vEdit4 Disabled
Gui, Add, UpDown, vTThreshold Disabled gChangeTThreshold Range0-255, %TriggerThreshold%
}
;Gui, Add, Checkbox, vButtonsEnabled gToggleButtons, Enable Buttons?
IfExist, xpadder.exe
{
Gui, Add, Button, gOpenXP, Open Xpadder
Gui, Show, W150 H400 Center, Precision Aim
}
IfNotExist, xpadder.exe
{
Gui, Show, W150 H350 Center, Precision Aim
}
IfExist, xpadder2.exe
{
Gui, Add, Button, gOpenXP2, Open XP2Mod
}
SetTimer, WatchJoystick, 10
return
ChangeSensitivity:
Gui, Submit, NoHide
JoyMultiplier := Sensitivity/100
return
ChangePrecise:
Gui, Submit, NoHide
PrecisionMultiplier := Precise/100
return
ChangePreciseLB:
Gui, Submit, NoHide
PrecisionLB := PreciseLB/100
return
ChangeTThresholdLB:
Gui, Submit, NoHide
ThresholdLB := TThresholdLB
return
ChangeTThreshold:
Gui, Submit, NoHide
TriggerThreshold := TThreshold
return
ChangeThreshold:
Gui, Submit, NoHide
JoyThreshold := Threshold
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
return
ToggleMouse:
Gui, Submit, NoHide
if %MouseEnabled% = 0
{
DisableMouse()
}
else
{
EnableMouse()
}
return
DisableMouse()
{
GuiControl, Disable, MouseLabel1
GuiControl, Disable, Edit1
GuiControl, Disable, Sensitivity
GuiControl, Disable, MouseLabel2
GuiControl, Disable, Edit2
GuiControl, Disable, Precise
GuiControl, Disable, MouseLabel3
GuiControl, Disable, Edit3
GuiControl, Disable, Threshold
GuiControl, Disable, MouseLabel4
GuiControl, Disable, Edit4
GuiControl, Disable, TThreshold
GuiControl, Disable, MouseLabel5
GuiControl, Disable, Edit5
GuiControl, Disable, TThresholdLB
GuiControl, Disable, MouseLabel6
GuiControl, Disable, Edit6
GuiControl, Disable, PreciseLB
}
EnableMouse(){
GuiControl, Enable, MouseLabel1
GuiControl, Enable, Edit1
GuiControl, Enable, Sensitivity
GuiControl, Enable, MouseLabel2
GuiControl, Enable, Edit2
GuiControl, Enable, Precise
GuiControl, Enable, MouseLabel3
GuiControl, Enable, Edit3
GuiControl, Enable, Threshold
GuiControl, Enable, MouseLabel4
GuiControl, Enable, Edit4
GuiControl, Enable, TThreshold
GuiControl, Enable, MouseLabel5
GuiControl, Enable, Edit5
GuiControl, Enable, TThresholdLB
GuiControl, Enable, MouseLabel6
GuiControl, Enable, Edit6
GuiControl, Enable, PreciseLB
}
OpenXP:
IfExist, xpadder.exe
Run xpadder.exe
IfNotExist, xpadder.exe
MsgBox, Couldn't Find Xpadder.exe
return
OpenXP2:
IfExist, xpadder2.exe
Run xpadder2.exe
IfNotExist, xpadder2.exe
MsgBox, Couldn't Find Xpadder2.exe
return
GuiClose:
GuiEscape:
Gui, Submit
IniWrite, %MouseEnabled%, opts.ini, MousePrecision, Enabled
IniWrite, %JoyThreshold%, opts.ini, MousePrecision, Threshold
IniWrite, %TriggerThreshold%, opts.ini, MousePrecision, TriggerThreshold
IniWrite, %Sensitivity%, opts.ini, MousePrecision, Sensitivity
IniWrite, %Precise%, opts.ini, MousePrecision, Precision
IniWrite, %PreciseLB%, opts.ini, MousePrecision, PrecisionLB
IniWrite, %ThresholdLB%, opts.ini, MousePrecision, ThresholdLB
ExitApp
return
WatchJoystick:
if MouseEnabled = 1
{
MouseNeedsToBeMoved := false
SetFormat, float, 03
GetKeyState, joyu, %JoystickNumber%JoyU
GetKeyState, joyr, %JoystickNumber%JoyR
if joyu > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaX := joyu - JoyThresholdUpper
}
else if joyu < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaX := joyu - JoyThresholdLower
}
else
{
DeltaX = 0
}
if joyr > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaY := joyr - JoyThresholdUpper
}
else if joyr < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaY := joyr - JoyThresholdLower
}
else
{
DeltaY = 0
}
if MouseNeedsToBeMoved
{
LT := 0
SetMouseDelay, -1
Loop, 4
{
if XInput_GetState(A_Index-1, State)=0 {
LT := json(State,"bLeftTrigger")
}
}
if ((LT >= ThresholdLB) AND (LT < TriggerThreshold))
{
;Calculate precision multiplier
;Move by multiplier
;Get the amount past the lower bound
;IE strip off the unnecessary data
AmountPastLowerBound := LT - ThresholdLB
;Increment Amount
;One percent of the difference between the trigger thresholds
PercentOfBounds := TriggerThreshold-ThresholdLB
; Percentage that the trigger is held past LB
PercentagePressure := (AmountPastLowerBound / PercentOfBounds) * 100
; Percentage Multiplier
;One percent of the difference between upper and lower
DifferenceP := PreciseLB-Precise
InvertedPercentage := 100-PercentagePressure
PercentageDiff := DifferenceP * InvertedPercentage / 100
NewMultForUse := PercentageDiff
;Then use it
mouseXY(DeltaX * (NewMultForUse /100), DeltaY * (NewMultForUse /100))
}
else if (LT >= TriggerThreshold)
{
;Past deadzone, full precision movement
;MouseMove, DeltaX * PrecisionMultiplier, DeltaY * PrecisionMultiplier, 0, R
mouseXY(DeltaX * PrecisionMultiplier, DeltaY * PrecisionMultiplier)
}
else
{
;LT not held Regular movement
;MouseMove, DeltaX * JoyMultiplier, DeltaY * JoyMultiplier, 0, R
mouseXY(DeltaX * JoyMultiplier, DeltaY * JoyMultiplier)
}
}
}
return
mouseXY(x,y)
{
DllCall("mouse_event",uint,1,int,x,int,y,uint,0,int,0)
}




