diff --git a/README.md b/README.md index 9067ffc..7d69948 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,38 @@ -### [ Download Latest Binary.](https://github.com/KovaaK/SensitivityMatcher/releases/latest) -[![Screenshot 1](https://i.redd.it/a65t3psme5p11.png)](https://github.com/KovaaK/SensitivityMatcher/releases/latest) -# Sensitivity Matcher +# [ Download Sensitivity Matcher here (NOT the green button).](https://github.com/KovaaK/SensitivityMatcher/releases/latest) +[![Screenshot 1](https://i.redd.it/4c0c0hf99y341.png)](https://github.com/KovaaK/SensitivityMatcher/releases/latest) -This script lets you match your mouse sensitivity between any 3D games directly, and forego paywalled calculators. + +This script lets you match your mouse sensitivity between any 3D games directly, and much more accurately than any paywalled calculators. Run the script, then: 1) Select the preset/game that you are coming from. 2) Input your sensitivity value from your old game. -3) In your new game, adjust its sens until the test matches. +3) In your new game, adjust its setting until the repeater make exact turns in game with no drift. -Press `Alt` `[` to perform one full revolution. +Press `Alt` `Backspace` to perform one full revolution. -Press `Alt` `]` to perform multiple full revolutions. +Press `Alt` `Shift` `Backspace` to perform multiple full revolutions. -Press `Alt` `\` to halt (and clear residuals). +Press `Alt` `\` to halt (also clears the residual angles).   -If the game that you are coming from is not listed, the script can also measure your old sensitivity.\ -Select "Measure any game" and enter your best guess, then: +If the game that you are coming from is not listed, the script can also capture your old sensitivity.\ +Select "Measure any game" and go into the game from which you wish to export your sensitivity, then: -1) Perform rotation(s) to see if the estimate under- or overshoots. -2) Make corrections using the hotkeys below. -3) Test again. Repeat the process until the script always lands on the exact origin even after many turns. -4) Once you're done measuring, you can match it to any game you like with procedures outlined in the first section.\ -Or, if the game is already listed, simply select it from the dropdown to convert immediately. +1) Aim at a precise marker in game, then press the Record hotkey to record your mouse movement +2) Use your mouse to turn 360 degrees aiming back to marker, and press the hotkey again to stop recording. +3) Use the repeater hotkeys to check its accuracy, correct over/undershoots with the fine tuner hotkeys +4) You can now match the captured sensitivity to any game, simply select the game from presets to show the right value, or use the repeater and adjust the in-game value manually if it's not listed in the presets. -Press `Alt` `-` to correct overshoots. +Press `Alt` `/` to start/finish recording. Press `Alt` `+` to correct undershoots. -Press `Alt` `0` to start over if you made a wrong correction. +Press `Alt` `-` to correct overshoots. + +Press `Alt` `0` to restart if you made a wrong correction.   diff --git a/ReleaseAssets/CustomYawList.ini b/ReleaseAssets/CustomYawList.ini index fb57894..decd173 100644 --- a/ReleaseAssets/CustomYawList.ini +++ b/ReleaseAssets/CustomYawList.ini @@ -2,11 +2,15 @@ yaw=0.55550 [Fortnite Config] yaw=2.2220 -[QCDE] -yaw=0.0439453125 [Unit: deg] yaw=1 [Unit: mrad] yaw=0.05729577951308232087679815481411 [Unit: arcmin] yaw=0.01666666666666666666666666666667 +[QCDE] +yaw=0.0439453125 +[Battalion 1944] +yaw=0.0175 +[Insurgency: Sandstorm] +yaw=0.14 diff --git a/ReleaseAssets/ReleaseNotes.md b/ReleaseAssets/ReleaseNotes.md index 12cef2c..457b15d 100644 --- a/ReleaseAssets/ReleaseNotes.md +++ b/ReleaseAssets/ReleaseNotes.md @@ -1,34 +1,42 @@ ## Release Highlights +[version 1.5] -[version 1.4] +[![Screenshot](https://i.redd.it/fa0x8uc89y341.png)](https://github.com/KovaaK/SensitivityMatcher/releases/latest) -_New Feature: Measurement Report_ +_New Feature: Rawinput recording_ -* To facilitate crowdsourced measurement of yaw scales, measurement reports (.csv) are now produced automatically to better enable rigorous verification of shared results. +* In Measurement Mode, you can now set up initial guesses more quickly using your mouse instead (default hotkey is `[Alt][/]` to toggle recording). +* Just record rotations with slight over- or undershoots and mark them accordingly. This immediately narrows down the range, from then on you can further converge the measurement using the repeater. +* This feature is also great for helping new FPS players quickly find a comfortable initial sensitivity. Just record two 180° swipes that you can do comfortably, and the corresponding setting is given for you to set in game. +* The physical sensitivity calculator now also includes a CPI calibration feature to take advantage of the rawinput capability. This lets you get a more accurate calculation of your physical sensitivity accounting for variances in mouse. -_Enhancement (active only in measurement mode): Measurement Cycle Autoscale and Nudge hotkeys_ +_New Feature: Chatbot command generator_ -* Number of multi-cycles auto bumps up during measurement mode as your uncertainty decreases. \ -(Only starts to kicks-in when you get _really_ precise) -* Nudge hotkeys (move one count left/right) to verify whether suspected drift exceeds margin of error. \ -(Residual artifact can drift up to half increment both ways) +* Copy your newly measured sens into your Nightbot !sens commands with the click of a button! +* Just click on "Share" in the physical stats calculator, text summarizing your settings will be generated. +* It will conveniently include your game-specific sensitivity value, your mouse cpi, and the physical sensitivity values representing your overall setting. + +_Usability Change: Default hotkeys of some commands have been changed_ +* Turn once: ~~`Alt [`~~ changed to `Alt` `Backspace` +* Turn a lot: ~~`Alt ]`~~ changed to `Alt` `Shift` `Backspace` +* Jog right: ~~`Alt '`~~ changed to `Alt` `>` +* Jog left: ~~`Alt ;`~~ changed to `Alt` `<` + +_Enhancement: Convergence Log window during Measurement Mode_ + +* Graph showing convergence progress of your estimate tuning. +* GUI buttons for the fine-tuner function, for those who prefer them over hotkeys. +* Display the convergence history as a table (in addition to the detailed log file output). ## Download -[**SensitivityMatcher_exe.zip**](https://github.com/KovaaK/SensitivityMatcher/releases/download/1.4/SensitivityMatcher_exe.zip) \ -[**SensitivityMatcher_a3x.zip**](https://github.com/KovaaK/SensitivityMatcher/releases/download/1.4/SensitivityMatcher_a3x.zip) (Use this instead if .exe is triggering false positives) +[**SensitivityMatcher_exe.zip** (64bit)](https://github.com/KovaaK/SensitivityMatcher/releases/download/1.5/SensitivityMatcher_exe.zip) \ +[**SensitivityMatcher_a3x.zip** (32bit)](https://github.com/KovaaK/SensitivityMatcher/releases/download/1.5/SensitivityMatcher_a3x.zip) (Use this instead if .exe is triggering false positives) [_Go to newest release_](https://github.com/KovaaK/SensitivityMatcher/releases/latest) ## Changelog -_New: Number of cycles bumps up to the (best-case) minimum required to possibly drift one increment given the uncertainty (measurement mode only)._ \ -_New: Added Nudge hotkeys that lets you send individual counts to check if deviation is at least one count \ -(measurement mode only)._ \ -_New: Added button to save current inputs to startup values._ \ -_New: Added back the "Custom" item. Upon selection, it makes your yaw equal the current increment._ \ -_New: Saved custom yaw now includes uncertainty if obtained from measurement. Info dialogue also shows uncertainty._ \ -_New: Asks whether user would like to use default binds if specific hotkeys are markedly unbound._ \ -_New: "Info" button shows contexual instructions depending on selected mode._ \ -_Fix: Measurement hotkeys now unbinds properly if ini is tweaked while still in measurement mode._ \ -_Fix: Measurement bounds are no longer lost when swapping yaw and sens; cancelling Save now restores swap options._ \ -_Fix: Minor optimization for floating point precision for multi-cycle turns._ +_Revert: removed the autocycle scaling that was added in 1.4 -- too hidden of a mechanic_ \ +_New: changed default hotkeys for tuning and jogging counts. See helptext._ \ +_New: changing the cpi field will now immediately save to ini._ \ +_New: script will make distinct beeps when activating/deactivating rawinput recording with hotkeys. Activating with GUI button will show a confirmation dialog instead._ diff --git a/ReleaseAssets/SensitivityMatcher.vbs b/ReleaseAssets/SensitivityMatcher.vbs index 15e818a..06aa395 100644 --- a/ReleaseAssets/SensitivityMatcher.vbs +++ b/ReleaseAssets/SensitivityMatcher.vbs @@ -1,2 +1,37 @@ -Set WshShell = WScript.CreateObject("WScript.Shell") -WshShell.Run "bin\AutoIt3.exe bin\SensitivityMatcher.a3x" +Dim Executable, Script, Command + +Executable = false +Script = false +Command = "" + +If FileExists("bin\AutoIt3.exe") Then + Executable = true + Command = "bin\AutoIt3.exe " +Else If FileExists("bin\AutoIt3_x64.exe") Then + Executable = true + Command = "bin\AutoIt3_x64.exe " + End If +End If + +If FileExists("bin\SensitivityMatcher.a3x") Then + Script = true + Command = Command + "bin\SensitivityMatcher.a3x" +Else If FileExists("bin\SensitivityMatcher.au3") Then + Script = true + Command = Command + "bin\SensitivityMatcher.au3" + End If +End If + +If Executable AND Script Then + Set WshShell = WScript.CreateObject("WScript.Shell") + WshShell.Run Command +End If + +Function FileExists(FilePath) + Set fso = CreateObject("Scripting.FileSystemObject") + If fso.FileExists(FilePath) Then + FileExists=CBool(1) + Else + FileExists=CBool(0) + End If +End Function diff --git a/ReleaseAssets/UserSettings.ini b/ReleaseAssets/UserSettings.ini index 77ffc5b..b0a283a 100644 --- a/ReleaseAssets/UserSettings.ini +++ b/ReleaseAssets/UserSettings.ini @@ -1,33 +1,35 @@ ; Startup values [Default] -sens=1 +sens=1.44318181818182 yaw=0.022 -part=959 -freq=60 -cycl=20 +part=480 +freq=100 +cycl=22 cpi=800 [Hotkeys] -TurnOnce=!{[} -TurnALot=!{]} +TurnOnce=!{BS} +TurnALot=!+{BS} StopTurn=!{\} LessTurn=!{-} MoreTurn=!{=} ClearMem=!{0} -NudgeFwd=!{'} -NudgeBkd=!{;} +JogRight=!{.} +JogLeft =!{,} +ToggleRec=!{/} ; The default hotkeys for the Sensitivity Matcher script are as follows: ; -; TurnOnce=!{[} -; TurnALot=!{]} +; TurnOnce=!{BS} +; TurnALot=!+{BS} ; StopTurn=!{\} ; LessTurn=!{-} ; MoreTurn=!{=} ; ClearMem=!{0} -; NudgeFwd=!{'} -; NudgeBkd=!{;} +; JogRight=!{.} +; JogLeft =!{,} +; ToggleRec=!{/} ; ; Put keys in curly braces to indicate a certain key. Example: {TAB} denotes the TAB key. ; Use lowercase for alphanumerics to avoid unintended behaviours. diff --git a/ReleaseAssets/bin/Header.au3 b/ReleaseAssets/bin/Header.au3 new file mode 100644 index 0000000..69401be --- /dev/null +++ b/ReleaseAssets/bin/Header.au3 @@ -0,0 +1,24 @@ +If _Singleton("Sensitivity Matcher", 1) == 0 Then + WinActivate("Sensitivity Matcher") + Exit +Else + Opt("GUICloseOnESC",0) +EndIf + +#NoTrayIcon +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "HotkeyFunctions.au3" +#include "MiscFunctions.au3" +#include "HelpMessages.au3" +#include "MeasureGUI.au3" +#include "RawInput.au3" diff --git a/ReleaseAssets/bin/HelpMessages.au3 b/ReleaseAssets/bin/HelpMessages.au3 new file mode 100644 index 0000000..995a0a6 --- /dev/null +++ b/ReleaseAssets/bin/HelpMessages.au3 @@ -0,0 +1,118 @@ +Global const $how_to_capture = "------------------------------------------------------------" & @crlf _ + & "To capture sensitivity manually if your game isn't listed:" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & "1) Select ''Measure any game'' to enable capture function." & @crlf _ + & "2) Record a precise turn in game, then check using repeater." & @crlf _ + & "3) Use the fine-tuner hotkeys to fine-tune your estimates." & @crlf _ + & @crlf _ + & "Press [Alt][ / ] to start/finish recording." & @crlf _ + & "Press [Alt][+] to increase counts if repeater undershoots." & @crlf _ + & "Press [Alt][ - ] to decrease counts if repeater overshoots." & @crlf _ + & "Press [Alt][ 0 ] to clear memory if you made a wrong tweak." & @crlf _ + & @crlf _ + & "The estimates will converge to your exact sensitivity as you " _ + & "gradually narrow down its range. You can then use the measured " _ + & "sensitivity and match your new game to it." & @crlf _ + & @crlf + +Global const $how_to_measure = "------------------------------------------------------------" & @crlf _ + & "Making precision measurements:" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & "1) Record a rotation with slight overshoot as initial guess." & @crlf _ + & "2) Mark as overshoot. Repeat the process for an undershoot." & @crlf _ + & "3) Keep narrowing down estimates by testing w/ the repeater." & @crlf _ + & @crlf _ + & "Under/overshoot drifts can take many cycles to become observable. " _ + & "Quantization artifacts can cause phantom shifts up to +/- 0.5 count " _ + & "that will snap back periodically over many rotations. To positively " _ + & "qualify under/overshoots, the deviations must equal or exceed +/- 1 " _ + & "angle increments. Use jog hotkeys to move single incements to check " _ + & "that deviations are at least one count away from origin." & @crlf _ + & @crlf _ + & "Press [Alt][>] to jog one count to the right" & @crlf _ + & "Press [Alt][<] to jog one count to the left" & @crlf _ + & @crlf _ + & "Remember to undo the jog before resuming cycling. To verify the " _ + & "accuracy of your measurement, do at least two measurement sessions " _ + & "with different initial values and check that there are no " _ + & "contradictions between the MeasureReport files (located at root " _ + & "directory of the script.)" & @crlf _ + & @crlf + +Global const $how_to_welcome = "------------------------------------------------------------" & @crlf _ + & "Welcome to Sensitivity Matcher v1.5!" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & @crlf _ + & "IMPORTANT NOTICE - some default hotkeys are changed in v1.5:" & @crlf _ + & @crlf _ + & "Single rotation is now [Alt][Backspace]" & @crlf _ + & "Multi-rotation is now [Alt][Shift][Backspace]" & @crlf _ + & @crlf _ + & "Check your keybinds in UserSettings.ini and make sure they do not " _ + & "coincide with existing in-game binds." & @crlf _ + & @crlf _ + & "Access helptext anytime by clicking on ''Instructions''." + +Func HelpMessage($mode="default") + If $gValid Then + Local $error = BoundUncertainty($gSens,$gBounds) + Local $prcnt = BoundUncertainty($gSens,$gBounds,"%") + Local $time = round($gCycle*$gDelay*(int(360/$gSens/$gPartition)+1)/1000) + If $mode == "welcome" Then + MsgBox(0, "First time use", $how_to_welcome) + ElseIf $mode == "measure" Then + MsgBox(0, "Info", "------------------------------------------------------------" & @crlf _ + & "To match your old sensitivity to a new game:" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & "1) Select the preset/game that you are coming from." & @crlf _ + & "2) Input your sensitivity value from your old game." & @crlf _ + & "3) In your new game, adjust its sens until repeater matches." & @crlf _ + & @crlf _ + & "Press [Alt][Backspace] to send one turn." & @crlf _ + & "Press [Alt][Shift][Backspace] to send " & $gCycle & " turns." & @crlf _ + & "Press [Alt][ \ ] to halt (also clears residual)." & @crlf _ + & @crlf _ + & $how_to_capture & $how_to_measure _ + & "------------------------------------------------------------" & @crlf _ + & "Additional Info:" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & "Key bindings can be changed in UserSettings.ini " & @crlf _ + & @crlf _ + & "Interval: " & $gDelay & " ms (round up to nearest 0.01 sec.)" & @crlf _ + & "Estimated Completion Time for " & $gCycle _ + & " cycles: " & $time & " sec" & @crlf _ + & @crlf _ + & "Current Residual Angle: " & $gResidual & "°" & @crlf _ + & "Current Upper Bound: " & $gBounds[1] & "°" & @crlf _ + & "Current Increment: " & $gSens & "°" & @crlf _ + & "Current Lower Bound: " & $gBounds[0] & "°" & @crlf _ + & "Uncertainty: ±" & $error & "° (±" & $prcnt & "%)" ) + Else + MsgBox(0, "Info", "------------------------------------------------------------" & @crlf _ + & "To match your old sensitivity to a new game:" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & "1) Select the preset/game that you are coming from." & @crlf _ + & "2) Input your sensitivity value from your old game." & @crlf _ + & "3) In your new game, adjust its sens until repeater matches." & @crlf _ + & @crlf _ + & "Press [Alt][Backspace] to send one turn." & @crlf _ + & "Press [Alt][Shift][Backspace] to send " & $gCycle & " turns." & @crlf _ + & "Press [Alt][ \ ] to halt (also clears residual)." & @crlf _ + & @crlf _ + & $how_to_capture _ + & "------------------------------------------------------------" & @crlf _ + & "Additional Info:" & @crlf _ + & "------------------------------------------------------------" & @crlf _ + & "Key bindings can be changed in UserSettings.ini " & @crlf _ + & @crlf _ + & "Interval: " & $gDelay & " ms (round up to nearest 0.01 sec.)" & @crlf _ + & "Estimated Completion Time for " & $gCycle _ + & " cycles: " & $time & " sec" & @crlf _ + & @crlf _ + & "Current Residual Angle: " & $gResidual & "°" & @crlf _ + & "Current Increment: " & $gSens & "°" ) + EndIf + Else + MsgBox(0, "Error", "Inputs must be positive numbers") + EndIf +EndFunc diff --git a/ReleaseAssets/bin/HotkeyFunctions.au3 b/ReleaseAssets/bin/HotkeyFunctions.au3 new file mode 100644 index 0000000..5d536f4 --- /dev/null +++ b/ReleaseAssets/bin/HotkeyFunctions.au3 @@ -0,0 +1,208 @@ +Func KeybindSetter($mode,$subset="all") + Local $size = 9 + Local $readval[$size] + Local $default[$size] = [ "!{BS}" , "!+{BS}", "!{\}" , _ + "!{-}" , "!{=}" , "!{0}" , _ + "!{.}" , "!{,}" , "!{/}" ] + Local $keyname[$size] = [ "TurnOnce","TurnAlot","StopTurn", _ + "LessTurn","MoreTurn","ClearMem", _ + "JogRight","JogLeft","ToggleRec" ] + Local $fncname[$size] = [ "SingleCycle", _ + "AutoCycle", _ + "Halt", _ + "DecreasePolygon", _ + "IncreasePolygon", _ + "ClearBounds", _ + "JogRight", _ + "JogLeft", _ + "RecordYawToggle" ] + For $i = 0 to $size-1 + $readval[$i] = IniRead($gSettingIni,"Hotkeys",$keyname[$i],$default[$i]) + Next + Local $start = 0 + Local $end = $size-1 + If $subset = "measure" Then + $start = 3 + ElseIf $subset = "turn" Then + $end = 2 + EndIf + Switch $mode + Case "initialize" + Return $readval + Case "save" + For $i = $start To $end + If $gHotkey[$i] Then + IniWrite($gSettingIni,"Hotkeys",$keyname[$i],$gHotkey[$i]) + EndIf + Next + Case "disable" + For $i = $start to $end + If $gHotkey[$i] Then + HotKeySet($gHotkey[$i]) + EndIf + Next + Case "enable" + For $i = $start to $end + If $gHotkey[$i] Then + HotKeySet($gHotkey[$i],$fncname[$i]) + ElseIf MsgBox(4,"Hotkeys","The hotkey "&$keyname[$i]&" is unbound."&@crlf& _ + "Use default bind of "&$default[$i]&" instead?") == 6 Then + $gHotkey[$i] = $default[$i] + HotKeySet($gHotkey[$i],$fncname[$i]) + EndIf + Next + EndSwitch +EndFunc + +Func DecreasePolygon() + If $gMode>0 and (not $g_isRecording) Then + $gMode=0 + If $gValid Then + $gResidual = 0 + $gBounds[0] = $gSens + _ArrayAdd($gHistory, $gSens) + If $gBounds[1] < $gBounds[0] Then + $gBounds[1] = 0 + $gSens = $gBounds[0] * 2 + Else + $gSens =($gBounds[0] + $gBounds[1]) / 2 + EndIf + UpdateMeasurementStatsWindow() + IniWrite($gReportFile,"Convergence Log", _ + "lwrbnd:,"&$gBounds[0]&",nxtgss:,"&$gSens& _ + ",uncrty:+/-,"&BoundUncertainty($gSens,$gBounds)& _ + ",(+/-"&BoundUncertainty($gSens,$gBounds,"%")&"%),mincycl", _ + BoundUncertainty($gSens,$gBounds,"rev") ) + Else + HelpMessage() + EndIf + sleep(10) + $gMode=1 + EndIf +EndFunc + +Func IncreasePolygon() + If $gMode>0 and (not $g_isRecording) Then + $gMode=0 + If $gValid Then + $gResidual = 0 + $gBounds[1] = $gSens + _ArrayAdd($gHistory, $gSens) + If $gBounds[1] < $gBounds[0] Then + $gBounds[0] = 0 + $gSens = $gBounds[1] / 2 + Else + $gSens =($gBounds[0] + $gBounds[1]) / 2 + EndIf + UpdateMeasurementStatsWindow() + IniWrite($gReportFile,"Convergence Log", _ + "uprbnd:,"&$gBounds[1]&",nxtgss:,"&$gSens& _ + ",uncrty:+/-,"&BoundUncertainty($gSens,$gBounds)& _ + ",(+/-"&BoundUncertainty($gSens,$gBounds,"%")&"%),mincycl", _ + BoundUncertainty($gSens,$gBounds,"rev") ) + Else + HelpMessage() + EndIf + sleep(10) + $gMode=1 + EndIf +EndFunc + +Func ClearBounds() + $gResidual = 0 + $gBounds[0] = 0 + $gBounds[1] = 0 + $gPartition = NormalizedPartition($gSens,$defaultTurnPeriod,$gDelay) + $gReportFile= CleanupFileName("MeasureReport"&_Now()&".csv") + UpdateMeasurementStatsWindow("CLEAR") + Global $gHistory[1] = [0] +EndFunc + +Func JogLeft() + If $gMode > 0 Then + $gMode = 0 + _MouseMovePlus(-1,0) + $gMode = 1 + EndIf +EndFunc + +Func JogRight() + If $gMode > 0 Then + $gMode = 0 + _MouseMovePlus(1,0) + $gMode = 1 + EndIf +EndFunc + +Func SingleCycle() + If $gValid Then + TestMouse(1) + Else + HelpMessage() + EndIf +EndFunc + +Func AutoCycle() + If $gValid Then + TestMouse($gCycle) + Else + HelpMessage() + EndIf +EndFunc + +Func Halt() + If $gMode > -1 Then + $gMode = -1 + $gResidual = 0 + EndIf +EndFunc + +Func RecordYawToggle() + If $gMode > 0 Then + $gMode = 0 + local $idMsg[2] = [$g_incidental_recordButton,"HOTKEY"] + EventMeasurementStatsWindow($idMsg) + sleep(10) + $gMode = 1 + EndIf +EndFunc + + + +Func TestMouse($cycle) + If $gMode > 0 Then ; three states of $gMode: -1, 0, 1. A 0 means in-progress and exits the command without doing anything. + $gMode = 0 ; -1 means manual override and is checked for before performing every operation, 1 means all is good to go. + + $partition = $gPartition + $delay = $gDelay + $turn = 0.0 + $totalcount = 1 + $grandtotal = (($cycle*360)+$gResidual)/$gSens + + While $cycle > 0 + $cycle = $cycle - 1 + $turn = 360 ; one revolution in deg + $totalcount = ( $turn + $gResidual ) / ( $gSens ) ; partitioned by user-defined increments + $totalcount = Round( $totalcount ) ; round to nearest integer + $gResidual = ( $turn + $gResidual ) - ( $gSens * $totalcount ) ; save the residual angles + While $totalcount > $partition + If $gMode < 0 Then + ExitLoop + EndIf + _MouseMovePlus($partition,0) + $totalcount = $totalcount - $partition + Sleep($delay) + WEnd + If $gMode < 0 Then + ExitLoop + EndIf + _MouseMovePlus($totalcount,0) ; do the leftover + Sleep($delay) + WEnd + + If $gMode == 0 Then + $gMode = 1 + $gResidual = $gSens * ( $grandtotal - round($grandtotal) ) + EndIf + EndIf +EndFunc diff --git a/ReleaseAssets/bin/MeasureGUI.au3 b/ReleaseAssets/bin/MeasureGUI.au3 new file mode 100644 index 0000000..4fe6bc9 --- /dev/null +++ b/ReleaseAssets/bin/MeasureGUI.au3 @@ -0,0 +1,143 @@ +#include +Global $g_incidental_recordButton +Global $g_incidental_measureGUI[10] + $g_incidental_measureGUI[0] = "INACTIVE" +Global $gHistory[1] = [0] + +Func DestroyMeasurementStatsWindow() + If $g_incidental_measureGUI[0] == "INACTIVE" Then + Else + for $i=1 to 8 + GUICtrlDelete($g_incidental_measureGUI[$i]) + next + GUIDelete($g_incidental_measureGUI[0]) + $g_incidental_measureGUI[0] = "INACTIVE" + $g_isRecording = false + GUICtrlSetData($g_incidental_recordButton, "Record") + GUICtrlSetState($g_incidental_recordButton,$GUI_DISABLE) + GUICtrlSetData($g_incidental_measureGUI[9], String( 360/$gSens)) + _GUICtrlEdit_SetSel($g_incidental_measureGUI[9], 0, 0 ) + EndIf +EndFunc + +Func MakeMeasurementStatsWindow() + $g_incidental_measureGUI[0] = GUICreate("Convergence Log",205,235,-209,-49,$WS_CAPTION,BitOR($WS_EX_MDICHILD,$WS_EX_TOOLWINDOW),$idGUI) + GUICtrlCreateLabel( "Upper Bound:", 5,5,70,20) + GUICtrlCreateLabel( "Lower Bound:", 5,25,70,20) + GUICtrlCreateLabel( "Uncertainty: ±", 5,45,70,20) + $g_incidental_measureGUI[2] = GUICtrlCreateLabel($gBounds[1]&"°",75,5,125,20) + $g_incidental_measureGUI[1] = GUICtrlCreateLabel($gBounds[0]&"°",75,25,125,20) + $g_incidental_measureGUI[3] = GUICtrlCreateLabel(BoundUncertainty($gSens,$gBounds,"%")&"%",75,45,130,20) + $g_incidental_measureGUI[4] = GUICtrlCreateButton("Go Shorter", 5, 205, 65, 25) + $g_incidental_measureGUI[5] = GUICtrlCreateButton("Reset", 70, 205, 65, 25) + $g_incidental_measureGUI[6] = GUICtrlCreateButton("Go Further", 135, 205, 65, 25) + $g_incidental_measureGUI[7] = GUICtrlCreateButton("Table", 164, 179, 35, 20) + $g_incidental_measureGUI[8] = GUICtrlCreateGraphic(5,65,195,135, 0x07) + GUICtrlSetBkColor($g_incidental_measureGUI[8], 0xffffff) + GUISetState(@SW_SHOW) + GUICtrlSetState($g_incidental_measureGUI[7],$GUI_FOCUS) + GUICtrlSetState($g_incidental_recordButton,$GUI_ENABLE) +EndFunc + +Func UpdateMeasurementStatsWindow($mode=0) + If $g_incidental_measureGUI[0] == "INACTIVE" Then + Else + GUICtrlSetData($g_incidental_measureGUI[1], $gBounds[0]&"°") + GUICtrlSetData($g_incidental_measureGUI[2], $gBounds[1]&"°") + GUICtrlSetData($g_incidental_measureGUI[3], BoundUncertainty($gSens,$gBounds,"%")&"%") + DrawMeasurementStatsGraph($mode) + EndIf +EndFunc + +Func EventMeasurementStatsWindow($idMsg) + if $g_incidental_measureGUI[0] == "INACTIVE" then + return + elseif $idMsg[0] == $g_incidental_recordButton then + Local $tempPtr = $g_incidental_measureGUI[0] ; save the pointer of the measureGUI window + $g_incidental_measureGUI[0] = "INACTIVE" ; lock this function from being executed by hotkey until it has completed + if $tempPtr == "INACTIVE" then return ; double check for edge cases of async hijack + if $g_isRecording then + $g_isRecording = not $g_isRecording ; stop recording first + local $l_yawbuffer = $g_yawbuffer ; store the finalized reference value + GUICtrlSetData($g_incidental_measureGUI[9], $l_yawbuffer) ; show the finalized yawbuffer value + sleep(10) ; give a pause to make sure the value is fixated a bit + $l_yawbuffer = Abs($l_yawbuffer) ; only want magnitude of counts + if $l_yawbuffer > 0 then ; check if any counts have been recorded + if $idMsg[1] == "HOTKEY" then ; play sound if ended by hotkey + $gSens = 360/$l_yawbuffer + Beep(330,100) + Beep(220,100) + elseif MsgBox(260,"","Recorded "&$l_yawbuffer&" counts for one revolution, confirm entry?")==6 then + $gSens = 360/$l_yawbuffer ; if not ended by hotkey, show dialog to confirm entry before committing + endif + elseif $idMsg[1] == "HOTKEY" then ; play sound if ended by hotkey with no count recorded + Beep(220,100) + endif + GUICtrlSetData($g_incidental_recordButton, "Record") ; restore button text to normal status + GUICtrlSetData($g_incidental_measureGUI[9], String( 360/$gSens)) + _GUICtrlEdit_SetSel($g_incidental_measureGUI[9],0,0) + else + $g_yawbuffer = 0 ; clear buffer first before activating + GUICtrlSetData($g_incidental_measureGUI[9], "0") ; initialize recorded count display + GUICtrlSetData($g_incidental_recordButton, "Recording...") ; change button text to show recording status + if $idMsg[1] == "HOTKEY" then Beep(330,100) ; play the commencement beep only if activated by hotkey + $g_isRecording = not $g_isRecording ; toggle rawinput state only after everything is set + endif + $g_incidental_measureGUI[0] = $tempPtr ; release the execution lock + elseif $idMsg[1] == $g_incidental_measureGUI[0] then + Switch $idMsg[0] + Case $g_incidental_measureGUI[4] + DecreasePolygon() + Case $g_incidental_measureGUI[5] + ClearBounds() + Case $g_incidental_measureGUI[6] + IncreasePolygon() + Case $g_incidental_measureGUI[7] + _ArrayDisplay($gHistory, "Table", UBound($gHistory)>1 ? "1:" : "") + EndSwitch + elseif $g_isRecording then ; if no relelvant events but is in measure mode, only then check if recording is active + GUICtrlSetData($g_incidental_measureGUI[9], $g_yawbuffer&"..."); live update the displayed counts + endif +EndFunc + +Func DrawMeasurementStatsGraph($mode) + AutoItSetOption ( "GUICoordMode", 0 ) + if $mode=="CLEAR" then + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_MOVE, 0, 134) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_COLOR, 0xffffff) + Local $yOffset= UBound($gHistory)==1 ? 0 : _ArrayMin($gHistory,1,1) + Local $yScale = (_ArrayMax($gHistory,1,1)-$yOffset) + Local $xScale = UBound($gHistory) + For $i = 1 to UBound($gHistory)-1 + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_LINE, 194*($i-1)/$xScale, 134*(1-($gHistory[$i]-$yOffset)/$yScale)) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_MOVE, 194*($i-1)/$xScale, 134*(1-($gHistory[$i]-$yOffset)/$yScale)) + Next + else + Local $lastHistory = _ArrayPop($gHistory) + + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_MOVE, 0, 134) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_COLOR, 0xffffff) + Local $yOffset= UBound($gHistory)==1 ? 0 : _ArrayMin($gHistory,1,1) + Local $yScale = (_ArrayMax($gHistory,1,1)-$yOffset) + Local $xScale = UBound($gHistory) + For $i = 1 to UBound($gHistory)-1 + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_LINE, 194*($i-1)/$xScale, 134*(1-($gHistory[$i]-$yOffset)/$yScale)) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_MOVE, 194*($i-1)/$xScale, 134*(1-($gHistory[$i]-$yOffset)/$yScale)) + Next + + _ArrayAdd($gHistory,$lastHistory) + + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_MOVE, 0, 134) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_COLOR, 0x000000) + $yOffset= UBound($gHistory)==1 ? 0 : _ArrayMin($gHistory,1,1) + $yScale = (_ArrayMax($gHistory,1,1)-$yOffset) + $xScale = UBound($gHistory) + For $i = 1 to UBound($gHistory)-1 + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_LINE, 194*($i-1)/$xScale, 134*(1-($gHistory[$i]-$yOffset)/$yScale)) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_MOVE, 194*($i-1)/$xScale, 134*(1-($gHistory[$i]-$yOffset)/$yScale)) + Next + endif + + AutoItSetOption ( "GUICoordMode", 1 ) + GUICtrlSetGraphic($g_incidental_measureGUI[8], $GUI_GR_REFRESH) +EndFunc diff --git a/ReleaseAssets/bin/MiscFunctions.au3 b/ReleaseAssets/bin/MiscFunctions.au3 new file mode 100644 index 0000000..8e29137 --- /dev/null +++ b/ReleaseAssets/bin/MiscFunctions.au3 @@ -0,0 +1,112 @@ + +Global Const $defaultTurnPeriod = 1000 + +Func FirstLaunchCheck() + if IniRead($gSettingIni,"FirstLaunch","Read1.5",0)==1 then + else + HelpMessage("welcome") + IniWrite($gSettingIni,"FirstLaunch","Read1.5",1) + endif +EndFunc + +Func UpdatePartition($limit,$sens,$bound,$delay) + Local $error = 1 + If $bound[1] AND ($bound[1] > $bound[0]) Then + $error = BoundUncertainty($sens,$bound,"%") / 100 + EndIf + Local $parti = NormalizedPartition($sens, $defaultTurnPeriod*$error, $delay) + If $parti > $limit Then + $parti = $limit + EndIf + Return $parti +EndFunc + +Func NormalizedPartition($incre,$turntime,$delay) + Local $total = round( 360 / $incre ) + Local $slice = ceiling( $total * $delay / $turntime ) + If $slice > $total Then + $slice = $total + EndIf + Return $slice +EndFunc + +Func BoundUncertainty($sens,$bounds,$mode=".") + Local $output = ($bounds[1]-$bounds[0])/2 + If $mode == "%" Then + $output = ($bounds[1]-$bounds[0])*50/$sens + ElseIf $mode == "rev" Then + $output = Ceiling($sens*$sens/($bounds[1]-$bounds[0])/360) + EndIf + If $output < 0 OR ($bounds[1]==0) Then + Return "infty" + Else + Return $output + EndIf +EndFunc + +Func CleanupFileName($input) + $input = StringReplace( $input, "?", "" ) + $input = StringReplace( $input, ":", "-" ) + $input = StringReplace( $input, "*", "" ) + $input = StringReplace( $input, "|", "" ) + $input = StringReplace( $input, "/", "-" ) + $input = StringReplace( $input, "\", "" ) + $input = StringReplace( $input, "<", "" ) + $input = StringReplace( $input, ">", "" ) + $input = StringReplace( $input, " ", "_" ) + Return $input +EndFunc + +Func InputsValid($sSens, $sPartition, $sYaw, $sTickRate, $sCycle) + return _StringIsNumber(GuiCtrlRead($sYaw)) AND 0<_GetNumberFromString(GuiCtrlRead($sYaw)) _ + AND _StringIsNumber(GuiCtrlRead($sSens)) AND 0<_GetNumberFromString(GuiCtrlRead($sSens)) _ + AND _StringIsNumber(GuiCtrlRead($sCycle)) AND 0<_GetNumberFromString(GuiCtrlRead($sCycle)) _ + AND _StringIsNumber(GuiCtrlRead($sTickrate)) AND 0<_GetNumberFromString(GuiCtrlRead($sTickrate)) _ + AND _StringIsNumber(GuiCtrlRead($sPartition)) AND 0<_GetNumberFromString(GuiCtrlRead($sPartition)) +EndFunc + + +Func LoadYawList($sFilePath) + Local $aYawList = IniReadSectionNames($sFilePath) + Local $sYawList = "Measure any game|" & _ + "Quake/Source|" & _ + "Overwatch|" & _ + "Rainbow6/Reflex|" & _ + "Diabotical|" & _ + "Custom|" + For $i = 1 to UBound($aYawList)-1 + $sYawList = $sYawList & "/ " & $aYawList[$i] & "|" + Next + $sYawList = $sYawList & "< Save current yaw >|" + Return $sYawList +EndFunc + +Func _MouseMovePlus($X = "", $Y = "") + Local $MOUSEEVENTF_MOVE = 0x1 + DllCall("user32.dll", "none", "mouse_event", _ + "long", $MOUSEEVENTF_MOVE, _ + "long", $X, _ + "long", $Y, _ + "long", 0, _ + "long", 0) +EndFunc + +Func _StringIsNumber($input) ; Checks if an input string is a number. +; The default StringIsDigit() function doesn't recognize negatives or decimals. +; "If $input == String(Number($input))" doesn't recognize ".1" since Number(".1") returns 0.1 +; So, here's a regex I pulled from http://www.regular-expressions.info/floatingpoint.html + $array = StringRegExp($input, '^[-+]?([0-9]*\.[0-9]+|[0-9]+)$', 3) + if UBound($array) > 0 Then + Return True + EndIf + Return False +EndFunc + +Func _GetNumberFromString($input) ; uses the above regular expression to pull a proper number +; $array = StringRegExp($input, '^[-+]?([0-9]*\.[0-9]+|[0-9]+)$', 3) ; this didn't return negatives + $array = StringRegExp($input, '^([-+])?(\d*\.\d+|\d+)$', 3) + if UBound($array) > 1 Then + Return Number($array[0] & $array[1]) ; $array[0] is "" or "-", $array[1] is the number. + EndIf + Return "error" +EndFunc diff --git a/ReleaseAssets/bin/RawInput.au3 b/ReleaseAssets/bin/RawInput.au3 new file mode 100644 index 0000000..0b8ea73 --- /dev/null +++ b/ReleaseAssets/bin/RawInput.au3 @@ -0,0 +1,52 @@ +#include +#include +;#include +;#include +;#include +;#include +;#include +;#include +;#include +#include +;#include +#include + +Global $g_isRecording = false +Global $g_isCalibratingCPI = false +Global $g_yawbuffer = 0 +Global $g_mousePathBuffer[2] = [0,0] + +Global $g_hForm + +Func RawinputCallback($tRIM) + Local $mouseDelta[2] = [ DllStructGetData($tRIM, 'LastX') , DllStructGetData($tRIM, 'LastY') ] + If $g_isRecording Then + $g_yawbuffer += $mouseDelta[0] + EndIf + If $g_isCalibratingCPI Then + $g_mousePathBuffer[0] += $mouseDelta[0] + $g_mousePathBuffer[1] += $mouseDelta[1] + EndIf +EndFunc + +Func SetupRawinput($l_hForm) + $g_hForm = $l_hForm + Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) + DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls + DllStructSetData($tRID, 'Usage', 0x02) ; Mouse + DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) + DllStructSetData($tRID, 'hTarget', $l_hForm) + _WinAPI_RegisterRawInputDevices($tRID) + GUIRegisterMsg($WM_INPUT, 'WM_INPUT') +EndFunc + +Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) + #forceref $iMsg, $wParam + If $hWnd == $g_hForm Then + Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) + If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then + RawinputCallback($tRIM) + EndIf + EndIf + Return $GUI_RUNDEFMSG +EndFunc diff --git a/ReleaseAssets/bin/RunScript.vbs b/ReleaseAssets/bin/RunScript.vbs deleted file mode 100644 index 7160ded..0000000 --- a/ReleaseAssets/bin/RunScript.vbs +++ /dev/null @@ -1,2 +0,0 @@ -Set WshShell = WScript.CreateObject("WScript.Shell") -WshShell.Run "AutoIt3.exe .\SensitivityMatcher.au3" diff --git a/ReleaseAssets/bin/SensitivityMatcher.au3 b/ReleaseAssets/bin/SensitivityMatcher.au3 index 5c5b18a..ddaddc8 100644 --- a/ReleaseAssets/bin/SensitivityMatcher.au3 +++ b/ReleaseAssets/bin/SensitivityMatcher.au3 @@ -1,24 +1,9 @@ -#NoTrayIcon -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "Header.au3" -If _Singleton("Sensitivity Matcher", 1) == 0 Then - MsgBox(0, "Warning", "An instance of Sensitivity Matcher is already running.") - Exit -EndIf - -Global Const $gPi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116 Global Const $yawQuake = 0.022 Global Const $yawOverwatch = 0.0066 -Global Const $yawReflex = 0.018/$gPi -Global Const $defaultTurnPeriod = 1000 +Global Const $yawReflex = _Degree(0.0001) +Global Const $yawDiabotical = 1/60 Global Const $gSettingIni = "UserSettings.Ini" Global Const $gYawListIni = "CustomYawList.ini" Global $gReportFile = "MeasureReport.csv" @@ -26,19 +11,18 @@ Global $gHotkey[8] = KeybindSetter("initialize") Global $gValid = 1 ; Keeps track of whether all user inputs are valid numbers or not Global $gMode = -1 ; Three states of $gMode: -1, 0, and 1, for halt override, in-progress, and ready. -Global $gSens = 1.0 -Global $gPartition = 127 +Global $gSens = 0.022 +Global $gPartition = 480 Global $gDelay = 10 -Global $gCycle = 20 +Global $gCycle = 22 Global $gResidual = 0.0 ; Residual accumulator Global $gBounds[2] = [0,0] ; Upper/lower bounds of increment - Opt("GUICloseOnESC",0) - MakeGUI() +MakeGUI() Func MakeGUI() - Local $idGUI = GUICreate("Sensitivity Matcher", 295, 235) - + Global $idGUI = GUICreate("Sensitivity Matcher", 295, 235,-1,-1,BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) + GUISetIcon("shell32_16739.ico") GUICtrlCreateLabel( "Select preset yaw:" , 0, 7, 95, 15, $SS_RIGHT ) GUICtrlCreateLabel( "Sens" , 5, 50, 80, 15, $SS_CENTER) GUICtrlCreateLabel( "×" , 85, 33, 15, 15, $SS_CENTER) @@ -46,7 +30,7 @@ Func MakeGUI() GUICtrlCreateLabel( "=" , 195, 33, 15, 15, $SS_CENTER) GUICtrlCreateLabel( "Increment" , 210, 50, 80, 15, $SS_CENTER) GUICtrlCreateGraphic( 5, 70, 285, 2, $SS_SUNKEN) ; horizontal line - GUICtrlCreateLabel( "Optional Testing Parameters" , 5, 80, 285, 15, $SS_CENTER) + GUICtrlCreateLabel( "Repeater Function Options" , 5, 80, 285, 15, $SS_CENTER) GUICtrlCreateLabel( "One Revolution of" , 0, 102, 95, 15, $SS_RIGHT ) GUICtrlCreateLabel( "counts." , 200, 102, 60, 15, $SS_LEFT ) GUICtrlCreateLabel( "Move Partitions of" , 0, 127, 95, 15, $SS_RIGHT ) @@ -59,18 +43,22 @@ Func MakeGUI() Local $sYawPresets = GUICtrlCreateCombo( "" , 100, 5, 110, 20) Local $sSens = GUICtrlCreateInput( "1" , 5, 30, 80, 20) - Local $sYaw = GUICtrlCreateInput( "0.022" , 100, 30, 95, 20) - Local $sIncr = GUICtrlCreateInput( "0.022" , 210, 30, 80, 20) + Local $sYaw = GUICtrlCreateInput( $gSens , 100, 30, 95, 20) + Local $sIncr = GUICtrlCreateInput( $gSens , 210, 30, 80, 20) GUICtrlSendMsg( $sIncr , $EM_SETREADONLY, 1, 0) - Local $sCounts = GUICtrlCreateInput( 360/0.022 , 100, 100, 95, 20) + Local $sCounts = GUICtrlCreateInput( 360/$gSens , 100, 100, 95, 20) GUICtrlSendMsg( $sCounts, $EM_SETREADONLY, 1, 0) - Local $sPartition = GUICtrlCreateInput( "959" , 100, 125, 95, 20) - Local $sTickRate = GUICtrlCreateInput( "60" , 100, 150, 95, 20) - Local $sCycle = GUICtrlCreateInput( "20" , 100, 175, 95, 20) + Local $sPartition = GUICtrlCreateInput( $gPartition , 100, 125, 95, 20) + Local $sTickRate = GUICtrlCreateInput( 1000/$gDelay , 100, 150, 95, 20) + Local $sCycle = GUICtrlCreateInput( $gCycle , 100, 175, 95, 20) Local $idSave = GUICtrlCreateButton("Save to Default", 5, 205, 95, 25) - Local $idHelp = GUICtrlCreateButton("Info" , 100, 205, 95, 25) + Local $idHelp = GUICtrlCreateButton("Instructions" , 100, 205, 95, 25) Local $idCalc = GUICtrlCreateButton("Physical Stats...",195,205,95, 25) +$g_incidental_recordButton = GUICtrlCreateButton("Record", 213, 4, 78, 23) +GUICtrlSetState($g_incidental_recordButton,$GUI_DISABLE) +$g_incidental_measureGUI[9]=$sCounts + Local $hToolTip =_GUIToolTip_Create(0) ; default tooltip _GUIToolTip_SetDelayTime($hToolTip, $TTDT_AUTOPOP, 30000) ; Set the tooltip to last 30 seconds. If I set this to 60 seconds, it seems to go back to 5. @@ -89,24 +77,24 @@ Func MakeGUI() Local $hTickRate = GUICtrlGetHandle($sTickRate) _GUIToolTip_AddTool($hToolTip, 0, "How many times per second to send mouse movements. Make sure this isn't higher than your framerate, especially for non-rawinput games.", $hTickRate) Local $hCycle = GUICtrlGetHandle($sCycle) - _GUIToolTip_AddTool($hToolTip, 0, "How many full revolutions to perform when pressing Alt+].", $hCycle) + _GUIToolTip_AddTool($hToolTip, 0, "How many full revolutions to perform when pressing the multicycle hotkey.", $hCycle) ; Initialize all inputs to ini or hardcoded defaults - GUICtrlSetData($sYawPresets, LoadYawList($gYawListIni) ) - GUICtrlSetdata($sPartition , IniRead($gSettingIni,"Default","part","959" )) - GUICtrlSetdata($sTickRate , IniRead($gSettingIni,"Default","freq","60" )) - GUICtrlSetdata($sCycle , IniRead($gSettingIni,"Default","cycl","20" )) - GUICtrlSetData($sYaw , IniRead($gSettingIni,"Default","yaw" ,"0.022")) - GUICtrlSetData($sSens , IniRead($gSettingIni,"Default","sens","1" )) - GUICtrlSetData($sIncr , _GetNumberFromString(GUICtrlRead($sSens))*_GetNumberFromstring(GUICtrlread($sYaw))) - GUICtrlSetData($sCounts , 360/_GetNumberFromString(GUICtrlRead($sSens))/_GetNumberFromstring(GUICtrlread($sYaw))) + GUICtrlSetData( $sYawPresets , LoadYawList($gYawListIni) ) + GUICtrlSetdata( $sPartition , IniRead( $gSettingIni,"Default","part",GUICtrlRead($sPartition) ) ) + GUICtrlSetdata( $sTickRate , IniRead( $gSettingIni,"Default","freq",GUICtrlRead($sTickRate) ) ) + GUICtrlSetdata( $sCycle , IniRead( $gSettingIni,"Default","cycl",GUICtrlRead($sCycle) ) ) + GUICtrlSetData( $sYaw , IniRead( $gSettingIni,"Default","yaw" ,GUICtrlRead($sYaw) ) ) + GUICtrlSetData( $sSens , IniRead( $gSettingIni,"Default","sens",GUICtrlRead($sSens) ) ) + GUICtrlSetData( $sIncr ,_GetNumberFromstring(GUICtrlread($sYaw))*_GetNumberFromString(GUICtrlRead($sSens)) ) + GUICtrlSetData( $sCounts , 360/_GetNumberFromString(GUICtrlRead($sIncr)) ) _GUICtrlEdit_SetSel($sCounts,0,0) ; Initialize Global Variables to UI Inputs. Once initialized, they are individually self-updating within the main loop $gSens = _GetNumberFromString(GuiCtrlRead($sSens)) * _GetNumberFromString(GuiCtrlRead($sYaw)) - $gDelay = Ceiling( 1000 / _GetNumberFromString( GuiCtrlRead($sTickRate) ) ) + $gDelay = 10 * Ceiling( 100 / _GetNumberFromString( GuiCtrlRead($sTickRate) ) ) $gPartition = _GetNumberFromString(GuiCtrlRead($sPartition)) $gCycle = _GetNumberFromString(GuiCtrlRead($sCycle)) $gResidual = 0.0 @@ -119,36 +107,29 @@ Func MakeGUI() Local $lPartition = $gPartition ; Local copy of user-entered partition value, passed to UpdatePartition to clip the NormalizedPartition result Local $lastgSens = $gSens ; Keeps track of whether there was an event that changed gSens outside of the main loop. This can happen either by hotkeys in Measurement Mode or by tweaking the Physical Sensitivities in the calc window Local $lastYawPresets = GUICtrlRead($sYawPresets) ; Used by Case "" to keep track of yawpreset state prior to the most recent yawpreset event, so that in the event the user cancels after selecting , it restores the yaw preset that was last selected. - Local $lCalculator[7] ; ByRef handles for HandyCalc. Never addressed directly in loop. - + Local $lCalculator[10] ; ByRef handles for HandyCalc. Never addressed directly in loop. + FirstLaunchCheck() + SetupRawinput($idGUI) GUISetState(@SW_SHOW) KeybindSetter("enable","turn") - While 1 - Switch $idMsg[0] - Case $GUI_EVENT_CLOSE - Switch $idMsg[1] - Case $idGUI - Exit - Case $idGUICalc - GUIDelete($idGUICalc) - $idGUICalc="INACTIVE" - EndSwitch - + Do + Switch $idMsg[0] Case $sCycle $gResidual = 0 $gCycle = _GetNumberFromString(GuiCtrlRead($sCycle)) Case $sTickRate $gResidual = 0 - $gDelay = Ceiling(1000/_GetNumberFromString(GuiCtrlRead($sTickRate))) + $gDelay = 10*Ceiling(100/_GetNumberFromString(GuiCtrlRead($sTickRate))) + GUICtrlSetData( $sTickRate , 1000/$gDelay ) Case $sPartition $gResidual = 0 $lPartition = _GetNumberFromString(GuiCtrlRead($sPartition)) $gPartition = $lPartition If $lastYawPresets == "Measure any game" Then - $gPartition = UpdatePartition($gPartition,$gBounds) + $gPartition = UpdatePartition($gPartition,$gSens,$gBounds,$gDelay) EndIf Case $sSens @@ -166,14 +147,16 @@ Func MakeGUI() If $idMsg[0] == $sYawPresets Then $gPartition = $lPartition GUICtrlSetData( $idHelp, YawPresetHandler($lastYawPresets,$sYawPresets,$sYaw,$sSens) ) - ElseIf $lastYawPresets == "Measure any game" Then + ElseIf $lastYawPresets == "Measure any game" Then ; Do nothing if yaw changed during measurement mode - ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawQuake Then + ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawQuake Then _GUICtrlComboBox_SelectString($sYawPresets, "Quake/Source") - ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawOverwatch Then + ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawOverwatch Then _GUICtrlComboBox_SelectString($sYawPresets, "Overwatch") - ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawReflex Then + ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawReflex Then _GUICtrlComboBox_SelectString($sYawPresets, "Rainbow6/Reflex") + ElseIf _GetNumberFromString(GuiCtrlRead($sYaw)) == $yawDiabotical Then + _GUICtrlComboBox_SelectString($sYawPresets, "Diabotical") Else _GUICtrlComboBox_SetEditText($sYawPresets, "Custom") EndIf @@ -207,6 +190,9 @@ Func MakeGUI() $idGUICalc = HandyCalculator("INITIALIZE",$lCalculator,$idMsg) Else GUISetState(@SW_RESTORE,$idGUICalc) + GUIDelete($idGUICalc) + $idGUICalc="INACTIVE" + $g_isCalibratingCPI = false EndIf Case $idHelp @@ -217,6 +203,21 @@ Func MakeGUI() EndIf EndSwitch + + If not ($idGUICalc == "INACTIVE") Then + if $idMsg[0] == $lCalculator[8] then + Local $chatbot_string = InputBox("Chat Bot Command - Click OK to Copy", _ + " ", _ + "My sens is " & _ + 0.001*round(1000*_GetNumberFromString(GUICtrlRead($lCalculator[2]))) & "deg/mm (" & _ + 0.01*round(100*_GetNumberFromString(GUICtrlRead($lCalculator[4]))) & "cm/rev) at " & _ + round(_GetNumberFromString(GUICtrlRead($lCalculator[1]))) & "cpi, <" & _ + GUICtrlRead($sYawPresets) & "> " & GUICtrlRead($sSens), _ + "",495,1) + If $chatbot_string then ClipPut($chatbot_string) + endif + EndIf + If $lastgSens <> $gSens Then $lastgSens = $gSens @@ -229,19 +230,22 @@ Func MakeGUI() _GUICtrlEdit_SetSel( $sIncr , 0, 0 ) _GUICtrlEdit_SetSel( $sSens , 0, 0 ) If $lastYawPresets == "Measure any game" Then - $gPartition = UpdatePartition( $lPartition , $gBounds ) - If $gCycle < GlobalUncertainty("rev") Then - $gCycle = GlobalUncertainty("rev") - GUICtrlSetData($sCycle, $gCycle) - EndIf + $gPartition = UpdatePartition( $lPartition, $gSens, $gBounds, $gDelay) EndIf EndIf HandyCalculator($idGUICalc,$lCalculator,$idMsg) + EventMeasurementStatsWindow($idMsg) $gMode = Abs($gMode) ; if override then ready, if ready or in progress then no change. $gValid = InputsValid($sSens, $sPartition, $sYaw, $sTickRate, $sCycle) - $idMsg = GUIGetMsg(1) - WEnd + Until GetEvent($idMsg) +EndFunc + +Func GetEvent(ByRef $idMsg) + $idMsg = GUIGetMsg(1) + If $idMsg[0] == $GUI_EVENT_CLOSE and $idMsg[1]==$idGUI Then + Return 1 + EndIf EndFunc Func HandyCalculator($idGUICalc, ByRef $sInput, $idMsg) @@ -249,27 +253,29 @@ Func HandyCalculator($idGUICalc, ByRef $sInput, $idMsg) ; do nothing and exit the function Else If $idGUICalc == "INITIALIZE" Then - Local $pos=WinGetPos("Sensitivity Matcher") - $idGUICalc=GUICreate("Physical Sensitivity",200,220,$pos[0]+$pos[2],$pos[1]) - $sInput[0]=GUICtrlCreateInput( $gSens , 85, 6, 80, 20) - GUICtrlSendMsg($sInput[0],$EM_SETREADONLY,1,0) - $sInput[1]=GUICtrlCreateInput( IniRead($gSettingIni,"Default","cpi",800) , 85, 30, 80, 20) - $sInput[2]=GUICtrlCreateInput( _GetNumberFromString(GUICtrlRead($sInput[1]))*$gSens/25.4, 20, 85, 75, 20) - $sInput[3]=GUICtrlCreateInput( _GetNumberFromString(GUICtrlRead($sInput[1]))*$gSens*60 ,105, 85, 75, 20) - $sInput[4]=GUICtrlCreateInput(360/_GetNumberFromString(GUICtrlRead($sInput[1]))/$gSens*2.54, 20,150, 75, 20) - $sInput[5]=GUICtrlCreateInput(360/_GetNumberFromString(GUICtrlRead($sInput[1]))/$gSens ,105,150, 75, 20) - $sInput[6]=GUICtrlCreateCheckbox("Lock physical sensitivity", 35,190,130) - GUICtrlCreateLabel("Virtual factor:",10,9,75,15,$SS_RIGHT) - GUICtrlCreateLabel("Physical factor:",10,33,75,15,$SS_RIGHT) + $idGUICalc=GUICreate("Physical Sensitivity",200,235,293,-49,$WS_CAPTION,BitOR($WS_EX_MDICHILD,$WS_EX_TOOLWINDOW),$idGUI) + GUICtrlCreateLabel("Game (DAC):",10,9,70,15,$SS_RIGHT) + GUICtrlCreateLabel("Mouse (ADC):",10,33,70,15,$SS_RIGHT) GUICtrlCreateLabel("deg",170,9,35,15,$SS_LEFT) GUICtrlCreateLabel("CPI",170,33,35,15,$SS_LEFT) - GUICtrlCreateGraphic(10,55,180,2,$SS_SUNKEN) - GUICtrlCreateLabel("Curvature",10,65,180,15,$SS_CENTER) - GUICtrlCreateLabel("deg/mm",20,105,75,15,$SS_CENTER) - GUICtrlCreateLabel("MPI",105,105,75,15,$SS_CENTER) - GUICtrlCreateLabel("Circumference",10,130,180,15,$SS_CENTER) - GUICtrlCreateLabel("cm/rev",20,170,75,15,$SS_CENTER) - GUICtrlCreateLabel("in/rev",105,170,75,15,$SS_CENTER) + GUICtrlCreateGraphic(10,80,180,2,$SS_SUNKEN) + GUICtrlCreateLabel("Aim Curvature",50,87,100,15,$SS_CENTER) + GUICtrlCreateLabel("deg/mm",20,127,75,15,$SS_CENTER) + GUICtrlCreateLabel("MPI",105,127,75,15,$SS_CENTER) + GUICtrlCreateLabel("Turn Circumference",10,150,180,15,$SS_CENTER) + GUICtrlCreateLabel("cm/rev",20,190,75,15,$SS_CENTER) + GUICtrlCreateLabel("in/rev",105,190,75,15,$SS_CENTER) + $sInput[0]=GUICtrlCreateInput( $gSens , 85, 6, 80, 20) + GUICtrlSendMsg($sInput[0],$EM_SETREADONLY,1,0) + $sInput[1]=GUICtrlCreateInput( IniRead($gSettingIni,"Default","cpi",800) , 85, 30, 80, 20) + $sInput[2]=GUICtrlCreateInput( _GetNumberFromString(GUICtrlRead($sInput[1]))*$gSens/25.4, 20,107, 75, 20) + $sInput[3]=GUICtrlCreateInput( _GetNumberFromString(GUICtrlRead($sInput[1]))*$gSens*60 ,105,107, 75, 20) + $sInput[4]=GUICtrlCreateInput(360/_GetNumberFromString(GUICtrlRead($sInput[1]))/$gSens*2.54, 20,170, 75, 20) + $sInput[5]=GUICtrlCreateInput(360/_GetNumberFromString(GUICtrlRead($sInput[1]))/$gSens ,105,170, 75, 20) + $sInput[6]=GUICtrlCreateCheckbox("Lock physical sensitivity", 35,208,130) + $sInput[7]=GUICtrlCreateButton("Calibrate Mouse CPI", 45,53,110,23) + $sInput[8]=GUICtrlCreateButton("Share",164,74,32,17) + $sInput[9]=GUICtrlCreateLabel("", 10,58,35,15,$SS_RIGHT) Local $hToolTip=_GUIToolTip_Create(0) _GUIToolTip_SetDelayTime($hToolTip, $TTDT_AUTOPOP, 30000) _GUIToolTip_SetDelayTime($hToolTip, $TTDT_RESHOW, 500) @@ -279,23 +285,26 @@ Func HandyCalculator($idGUICalc, ByRef $sInput, $idMsg) Local $hCPI = GUICtrlGetHandle($sInput[1]) _GUIToolTip_AddTool($hToolTip, 0, "Count Per Inch", $hCPI) Local $hDgm = GUICtrlGetHandle($sInput[2]) - _GUIToolTip_AddTool($hToolTip, 0, "Degree Per Millimeter = (incre*CPI)/25.4", $hDgm) + _GUIToolTip_AddTool($hToolTip, 0, "degree per mm = incre*CPI/25.4", $hDgm) Local $hMPI = GUICtrlGetHandle($sInput[3]) - _GUIToolTip_AddTool($hToolTip, 0, "Minute (of arc) Per Inch = (incre*CPI)*60", $hMPI) + _GUIToolTip_AddTool($hToolTip, 0, "Minute[of arc] Per Inch = incre*CPI*60", $hMPI) Local $hCcm = GUICtrlGetHandle($sInput[4]) - _GUIToolTip_AddTool($hToolTip, 0, "Centimeter Per Revolution = rev/(incre*CPI)*2.54", $hCcm) + _GUIToolTip_AddTool($hToolTip, 0, "cm per revolution = 2.54 * 360°/(incre*CPI)", $hCcm) Local $hCin = GUICtrlGetHandle($sInput[5]) - _GUIToolTip_AddTool($hToolTip, 0, "Inch Per Revolution = rev/(incre*CPI)", $hCin) + _GUIToolTip_AddTool($hToolTip, 0, "inch per revolution = 360°/(incre*CPI)", $hCin) + Local $hCal = GUICtrlGetHandle($sInput[7]) + _GUIToolTip_AddTool($hToolTip, 0, "Click to start recording mouse movement, then hit space to end the measurement.", $hCal) + GUICtrlSetState($sInput[1],$GUI_FOCUS) + GUISetState(@SW_SHOW) For $i = 0 to 5 _GUICtrlEdit_SetSel($sInput[$i], 0, 0 ) Next - GUISetState(@SW_SHOW) - GUICtrlSetState($sInput[1],$GUI_FOCUS) EndIf Local $cpi = _GetNumberFromString( GUICtrlRead($sInput[1]) ) Local $lock= GUICtrlRead($sInput[6]) Switch $idMsg[0] Case $sInput[1] + IniWrite($gSettingIni,"Default","cpi",$cpi) If $lock == $GUI_UNCHECKED Then $idMsg[0] = -1 Else @@ -322,6 +331,32 @@ Func HandyCalculator($idGUICalc, ByRef $sInput, $idMsg) For $i = 2 to 5 GUICtrlSendMsg($sInput[$i],$EM_SETREADONLY,$readonly,0) Next + Case $sInput[7] + if $g_isCalibratingCPI then + Local $deltaMouse = $g_mousePathBuffer + Local $calibratedCPI = Sqrt(($deltaMouse[0]*$deltaMouse[0]) + ($deltaMouse[1]*$deltaMouse[1]))/5 + GUICtrlSetData($sInput[7], "Calibrate Mouse CPI") + GUICtrlSetData($sInput[9], "" ) + if $calibratedCPI>0 and MsgBox(260,"", "You moved {" & $deltaMouse[0] & ", " & $deltaMouse[1] & "} counts over 5 inches or 127 mm." & @crlf & @crlf _ + & "This gives " & $calibratedCPI & " CPI." & @crlf & @crlf _ + & "Confirm entry?" ) == 6 then + $cpi=$calibratedCPI + GUICtrlSetData($sInput[1],$cpi) + IniWrite($gSettingIni,"Default","cpi",$cpi) + If $lock == $GUI_UNCHECKED Then + $idMsg[0] = -1 + Else + $gSens = _GetNumberFromString( GUICtrlRead($sInput[3]) ) / $cpi / 60 + EndIf + else + ; restore cpi + endif + else + GUICtrlSetData($sInput[7], "Move 5 inches..." ) + $g_mousePathBuffer[0] = 0 + $g_mousePathBuffer[1] = 0 + endif + $g_isCalibratingCPI = not $g_isCalibratingCPI EndSwitch If $idMsg[0] == -1 Then GUICtrlSetData($sInput[0],String( $gSens )) @@ -337,98 +372,17 @@ Func HandyCalculator($idGUICalc, ByRef $sInput, $idMsg) _GUICtrlEdit_SetSel($sInput[$i], 0, 0 ) Next EndIf + if $g_isCalibratingCPI then + Local $labeldelta = $g_mousePathBuffer + Local $labelCPI = round(Sqrt(($labeldelta[0]*$labeldelta[0]) + ($labeldelta[1]*$labeldelta[1]))/5) + if _GetNumberFromString(GUICtrlRead($sInput[9]))<>$labelCPI then + GUICtrlSetData($sInput[9], $labelCPI ) + endif + endif Return $idGUICalc EndIf EndFunc -Func HelpMessage($mode="default") - If $gValid Then - Local $error = GlobalUncertainty() - Local $time = round($gCycle*$gDelay*(int(360/$gSens/$gPartition)+1)/1000) - If $mode == "measure" Then - MsgBox(0, "Info", "------------------------------------------------------------" & @crlf _ - & "Additional Info:" & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "Key bindings can be changed in UserSettings.ini " & @crlf _ - & @crlf _ - & "Interval: " & $gDelay & " ms (round up to nearest millisec.)" & @crlf _ - & "Estimated Completion Time for " & $gCycle _ - & " cycles: " & $time & " sec" & @crlf _ - & @crlf _ - & "Current Residual Angle: " & $gResidual & "°" & @crlf _ - & "Current Lower Bound: " & $gBounds[0] & "°" & @crlf _ - & "Current Increment: " & $gSens & "°" & @crlf _ - & "Current Upper Bound: " & $gBounds[1] & "°" & @crlf _ - & "Uncertainty: ±" & $error & "° (±"&GlobalUncertainty("%")&"%)"& @crlf _ - & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "Precision Measurements (Advanced):" & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "Under/overshoot drifts can take many cycles to become observable. " _ - & "Slight shifts up to half-increment that snaps back periodically are " _ - & "simply visual artifacts of residual angles that cancels itself out " _ - & "over many rotations. To positively qualify under/overshoots, the " _ - & "deviations must equal or exceed single increment angles. Use the " _ - & "nudge hotkeys in measurement mode to move single increments to check" _ - & " that deviation is at least one count away from origin." & @crlf _ - & @crlf _ - & "Press Alt+' (quotation) to nudge one count to the right" & @crlf _ - & "Press Alt+; (semicolon) to nudge one count to the left" & @crlf _ - & @crlf _ - & "Remember to un-nudge if you wish to continue cycling. To share your " _ - & "measurement results for others to verify, it is recommended that " _ - & "at least two measurement sessions with different non-overlapping " _ - & "initial values be performed on two separate in-game settings, for a " _ - & "total of four MeasureReport files that passes validation for " _ - & "consistency (no contradiction between files) and continuity (no " _ - & "mismatched bound sequence within a file).") - Else - MsgBox(0, "Info", "------------------------------------------------------------" & @crlf _ - & "To match your old sensitivity to a new game:" & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "1) Select the preset/game that you are coming from." & @crlf _ - & "2) Input your sensitivity value from your old game." & @crlf _ - & "3) In your new game, adjust its sens until the test matches." & @crlf _ - & @crlf _ - & "Press Alt+[ to perform one full revolution." & @crlf _ - & "Press Alt+] to perform " & $gCycle & " full revolutions." & @crlf _ - & "Press Alt+\ to halt and/or clear residuals (for realignment)" & @crlf _ - & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "If your old game is not listed/yaw is unknown:" & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "1) Select ''Measure any game'' to enable measurement." & @crlf _ - & "2) Perform rotations in old game to test your estimate." & @crlf _ - & "3) Use the following hotkeys to adjust the estimate." & @crlf _ - & @crlf _ - & "Increase counts with Alt+= if it's undershooting." & @crlf _ - & "Decrease counts with Alt+- if it's overshooting." & @crlf _ - & "Clear all memory with Alt+0 if you made a wrong input." & @crlf _ - & @crlf _ - & "The estimate will converge to your exact sensitivity as you set " _ - & "measurement bounds with hotkeys. You can then use the measured " _ - & "sensitivity and match your new game to it." & @crlf _ - & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "Additional Info:" & @crlf _ - & "------------------------------------------------------------" & @crlf _ - & "Key bindings can be changed in UserSettings.ini " & @crlf _ - & @crlf _ - & "Interval: " & $gDelay & " ms (round up to nearest millisec.)" & @crlf _ - & "Estimated Completion Time for " & $gCycle _ - & " cycles: " & $time & " sec" & @crlf _ - & @crlf _ - & "Current Residual Angle: " & $gResidual & "°" & @crlf _ - & "Current Lower Bound: " & $gBounds[0] & "°" & @crlf _ - & "Current Increment: " & $gSens & "°" & @crlf _ - & "Current Upper Bound: " & $gBounds[1] & "°" & @crlf _ - & "Uncertainty: ±" & $error & "° (±"&GlobalUncertainty("%")&"%)") - EndIf - Else - MsgBox(0, "Error", "Inputs must be positive numbers") - EndIf -EndFunc - Func YawPresetHandler($lastYawPresets, $sYawPresets, $sYaw, $sSens) Local $Preset = GUICtrlRead($sYawPresets) _GUICtrlComboBox_DeleteString($sYawPresets,0) ; indiscriminately set first entry to measure any game @@ -444,17 +398,20 @@ Func YawPresetHandler($lastYawPresets, $sYawPresets, $sYaw, $sSens) GUICtrlSetData($sYaw, String($yawOverwatch)) Case "Rainbow6/Reflex" GUICtrlSetData($sYaw, String($yawReflex)) + Case "Diabotical" + GUICtrlSetData($sYaw, String($yawDiabotical)) Case "Measure any game","< Swap yaw & sens >" KeybindSetter("enable","measure") _GUICtrlComboBox_DeleteString($sYawPresets,0) ; always set first entry to swap when _GUICtrlComboBox_InsertString($sYawPresets,"< Swap yaw & sens >",0) ; measure or swap is selected _GUICtrlComboBox_SetEditText( $sYawPresets,"Measure any game") ; set input box to Measure regardless If $Preset == "< Swap yaw & sens >" Then - $gPartition = UpdatePartition($gPartition,$gBounds) + $gPartition = UpdatePartition($gPartition,$gSens,$gBounds,$gDelay) GUICtrlSetData($sYaw,String(GuiCtrlRead($sSens))) ; set yaw to sens if swap is selected Else ; ElseIf $Preset is Measure any game GUICtrlSetData($sYaw,1) ; set yaw to 1 on measure mode select ClearBounds() ; as well as clearing bounds + MakeMeasurementStatsWindow() EndIf Return "Advanced Info" Case "< Save current yaw >" @@ -462,8 +419,8 @@ Func YawPresetHandler($lastYawPresets, $sYawPresets, $sYaw, $sSens) If GUICtrlRead($sYawPresets) Then ; if user input name is valid IniWrite($gYawListIni,GUICtrlRead($sYawPresets),"yaw" , GUICtrlRead($sYaw) ) If ($gBounds[0]<=$gSens) AND ($gBounds[1]>=$gSens) Then ; write uncertainty and report info if valid bounds - IniWrite($gYawListIni,GUICtrlRead($sYawPresets),"uncrty","+/-"&GlobalUncertainty("%")&"%") - IniWrite($gReportFile,GUICtrlRead($sYawPresets),"uncrty","+/-"&GlobalUncertainty("%")&"%") + IniWrite($gYawListIni,GUICtrlRead($sYawPresets),"uncrty","+/-"&BoundUncertainty($gSens,$gBounds,"%")&"%") + IniWrite($gReportFile,GUICtrlRead($sYawPresets),"uncrty","+/-"&BoundUncertainty($gSens,$gBounds,"%")&"%") IniWrite($gReportFile,GUICtrlRead($sYawPresets),"yaw" , GUICtrlRead($sYaw) ) IniWrite($gReportFile,GUICtrlRead($sYawPresets),"sens" , GUICtrlRead($sSens) ) EndIf @@ -478,298 +435,11 @@ Func YawPresetHandler($lastYawPresets, $sYawPresets, $sYaw, $sSens) _GUICtrlComboBox_InsertString( $sYawPresets, "< Swap yaw & sens >", 0 ) ; set to swap EndIf _GUICtrlComboBox_SetEditText( $sYawPresets, $lastYawPresets ) ; restore box to last selected + Return "Advanced Info" ; restore button label EndIf Case Else GUICtrlSetData($sYaw,String(IniRead($gYawListIni,StringTrimLeft(GUICtrlRead($sYawPresets),2),"yaw",GuiCtrlRead($sYaw)))) EndSwitch - Return "Info" -EndFunc - -Func KeybindSetter($mode,$subset="all") - Local $size = 8 - Local $readval[$size] - Local $default[$size] = [ "!{[}" , "!{]}" , "!{\}" , _ - "!{-}" , "!{=}" , "!{0}" , _ - "!{'}" , "!{;}" ] - Local $keyname[$size] = [ "TurnOnce","TurnAlot","StopTurn", _ - "LessTurn","MoreTurn","ClearMem", _ - "NudgeFwd","NudgeBkd"] - Local $fncname[$size] = [ "SingleCycle", _ - "AutoCycle", _ - "Halt", _ - "DecreasePolygon", _ - "IncreasePolygon", _ - "ClearBounds", _ - "NudgeRight", _ - "NudgeLeft" ] - For $i = 0 to $size-1 - $readval[$i] = IniRead($gSettingIni,"Hotkeys",$keyname[$i],$default[$i]) - Next - Local $start = 0 - Local $end = $size-1 - If $subset = "measure" Then - $start = 3 - ElseIf $subset = "turn" Then - $end = 2 - EndIf - Switch $mode - Case "initialize" - Return $readval - Case "save" - For $i = $start To $end - If $gHotkey[$i] Then - IniWrite($gSettingIni,"Hotkeys",$keyname[$i],$gHotkey[$i]) - EndIf - Next - Case "disable" - For $i = $start to $end - If $gHotkey[$i] Then - HotKeySet($gHotkey[$i]) - EndIf - Next - Case "enable" - For $i = $start to $end - If $gHotkey[$i] Then - HotKeySet($gHotkey[$i],$fncname[$i]) - ElseIf MsgBox(4,"Hotkeys","The hotkey "&$keyname[$i]&" is unbound."&@crlf& _ - "Use default bind of "&$default[$i]&" instead?") == 6 Then - $gHotkey[$i] = $default[$i] - HotKeySet($gHotkey[$i],$fncname[$i]) - EndIf - Next - EndSwitch -EndFunc - -Func TestMouse($cycle) - If $gMode > 0 Then ; three states of $gMode: -1, 0, 1. A 0 means in-progress and exits the command without doing anything. - $gMode = 0 ; -1 means manual override and is checked for before performing every operation, 1 means all is good to go. - - $partition = $gPartition - $delay = $gDelay - $turn = 0.0 - $totalcount = 1 - $grandtotal = (($cycle*360)+$gResidual)/$gSens - - While $cycle > 0 - $cycle = $cycle - 1 - $turn = 360 ; one revolution in deg - $totalcount = ( $turn + $gResidual ) / ( $gSens ) ; partitioned by user-defined increments - $totalcount = Round( $totalcount ) ; round to nearest integer - $gResidual = ( $turn + $gResidual ) - ( $gSens * $totalcount ) ; save the residual angles - While $totalcount > $partition - If $gMode < 0 Then - ExitLoop - EndIf - _MouseMovePlus($partition,0) - $totalcount = $totalcount - $partition - Sleep($delay) - WEnd - If $gMode < 0 Then - ExitLoop - EndIf - _MouseMovePlus($totalcount,0) ; do the leftover - Sleep($delay) - WEnd - - If $gMode == 0 Then - $gMode = 1 - $gResidual = $gSens * ( $grandtotal - round($grandtotal) ) - EndIf - EndIf -EndFunc - -Func DecreasePolygon() - If $gMode>0 Then - $gMode=0 - If $gValid Then - $gResidual = 0 - $gBounds[0] = $gSens - If $gBounds[1] < $gBounds[0] Then - $gBounds[1] = 0 - $gSens = $gBounds[0] * 2 - Else - $gSens =($gBounds[0] + $gBounds[1]) / 2 - EndIf - IniWrite($gReportFile,"Convergence Log", _ - "lwrbnd:,"&$gBounds[0]&",nxtgss:,"&$gSens& _ - ",uncrty:+/-,"&GlobalUncertainty()& _ - ",(+/-"&GlobalUncertainty("%")&"%),mincycl", _ - GlobalUncertainty("rev") ) - Else - HelpMessage() - EndIf - $gMode=1 - EndIf -EndFunc - -Func IncreasePolygon() - If $gMode>0 Then - $gMode=0 - If $gValid Then - $gResidual = 0 - $gBounds[1] = $gSens - If $gBounds[1] < $gBounds[0] Then - $gBounds[0] = 0 - $gSens = $gBounds[1] / 2 - Else - $gSens =($gBounds[0] + $gBounds[1]) / 2 - EndIf - IniWrite($gReportFile,"Convergence Log", _ - "uprbnd:,"&$gBounds[1]&",nxtgss:,"&$gSens& _ - ",uncrty:+/-,"&GlobalUncertainty()& _ - ",(+/-"&GlobalUncertainty("%")&"%),mincycl", _ - GlobalUncertainty("rev") ) - Else - HelpMessage() - EndIf - $gMode=1 - EndIf -EndFunc - -Func ClearBounds() - $gResidual = 0 - $gBounds[0] = 0 - $gBounds[1] = 0 - $gPartition = NormalizedPartition($defaultTurnPeriod) - $gReportFile= CleanupFileName("MeasureReport"&_Now()&".csv") -EndFunc - -Func NudgeLeft() - If $gMode = 1 Then - $gMode = 0 - _MouseMovePlus(-1,0) - $gMode = 1 - EndIf -EndFunc - -Func NudgeRight() - If $gMode = 1 Then - $gMode = 0 - _MouseMovePlus(1,0) - $gMode = 1 - EndIf -EndFunc - -Func SingleCycle() - If $gValid Then - TestMouse(1) - Else - HelpMessage() - EndIf -EndFunc - -Func AutoCycle() - If $gValid Then - TestMouse($gCycle) - Else - HelpMessage() - EndIf -EndFunc - -Func Halt() - If $gMode > -1 Then - $gMode = -1 - $gResidual = 0 - EndIf -EndFunc - -Func UpdatePartition($limit,$bound) - Local $error = 1 - If $bound[1] AND ($bound[1] > $bound[0]) Then - $error = GlobalUncertainty("%") / 100 - EndIf - Local $parti = NormalizedPartition( $defaultTurnPeriod * $error ) - If $parti > $limit Then - $parti = $limit - EndIf - Return $parti -EndFunc - -Func NormalizedPartition($turntime) - Local $incre = $gSens - Local $total = round( 360 / $incre ) - Local $slice = ceiling( $total * $gDelay / $turntime ) - If $slice > $total Then - $slice = $total - EndIf - Return $slice -EndFunc - -Func CleanupFileName($input) - $input = StringReplace( $input, "?", "" ) - $input = StringReplace( $input, ":", "-" ) - $input = StringReplace( $input, "*", "" ) - $input = StringReplace( $input, "|", "" ) - $input = StringReplace( $input, "/", "-" ) - $input = StringReplace( $input, "\", "" ) - $input = StringReplace( $input, "<", "" ) - $input = StringReplace( $input, ">", "" ) - $input = StringReplace( $input, " ", "_" ) - Return $input -EndFunc - -Func InputsValid($sSens, $sPartition, $sYaw, $sTickRate, $sCycle) - return _StringIsNumber(GuiCtrlRead($sYaw)) AND 0<_GetNumberFromString(GuiCtrlRead($sYaw)) _ - AND _StringIsNumber(GuiCtrlRead($sSens)) AND 0<_GetNumberFromString(GuiCtrlRead($sSens)) _ - AND _StringIsNumber(GuiCtrlRead($sCycle)) AND 0<_GetNumberFromString(GuiCtrlRead($sCycle)) _ - AND _StringIsNumber(GuiCtrlRead($sTickrate)) AND 0<_GetNumberFromString(GuiCtrlRead($sTickrate)) _ - AND _StringIsNumber(GuiCtrlRead($sPartition)) AND 0<_GetNumberFromString(GuiCtrlRead($sPartition)) -EndFunc - -Func GlobalUncertainty($mode=".") - Local $output = ($gBounds[1]-$gBounds[0])/2 - If $mode == "%" Then - $output = ($gBounds[1]-$gBounds[0])*50/$gSens - ElseIf $mode == "rev" Then - $output = Ceiling($gSens*$gSens/($gBounds[1]-$gBounds[0])/360) - EndIf - If $output < 0 OR ($gBounds[1]==0) Then - Return "infty" - Else - Return $output - EndIf -EndFunc - -Func LoadYawList($sFilePath) - Local $aYawList = IniReadSectionNames($sFilePath) - Local $sYawList = "Measure any game|" & _ - "Quake/Source|" & _ - "Overwatch|" & _ - "Rainbow6/Reflex|" & _ - "Custom|" - For $i = 1 to UBound($aYawList)-1 - $sYawList = $sYawList & "/ " & $aYawList[$i] & "|" - Next - $sYawList = $sYawList & "< Save current yaw >|" - Return $sYawList -EndFunc - -Func _MouseMovePlus($X = "", $Y = "") - Local $MOUSEEVENTF_MOVE = 0x1 - DllCall("user32.dll", "none", "mouse_event", _ - "long", $MOUSEEVENTF_MOVE, _ - "long", $X, _ - "long", $Y, _ - "long", 0, _ - "long", 0) -EndFunc - -Func _StringIsNumber($input) ; Checks if an input string is a number. -; The default StringIsDigit() function doesn't recognize negatives or decimals. -; "If $input == String(Number($input))" doesn't recognize ".1" since Number(".1") returns 0.1 -; So, here's a regex I pulled from http://www.regular-expressions.info/floatingpoint.html - $array = StringRegExp($input, '^[-+]?([0-9]*\.[0-9]+|[0-9]+)$', 3) - if UBound($array) > 0 Then - Return True - EndIf - Return False -EndFunc - -Func _GetNumberFromString($input) ; uses the above regular expression to pull a proper number -; $array = StringRegExp($input, '^[-+]?([0-9]*\.[0-9]+|[0-9]+)$', 3) ; this didn't return negatives - $array = StringRegExp($input, '^([-+])?(\d*\.\d+|\d+)$', 3) - if UBound($array) > 1 Then - Return Number($array[0] & $array[1]) ; $array[0] is "" or "-", $array[1] is the number. - EndIf - Return "error" + DestroyMeasurementStatsWindow() + Return "Instructions" EndFunc diff --git a/ReleaseAssets/shell32_16739.ico b/ReleaseAssets/bin/shell32_16739.ico similarity index 100% rename from ReleaseAssets/shell32_16739.ico rename to ReleaseAssets/bin/shell32_16739.ico