Deadzone, Antideadzone & Curve Manipulation

Documentation, usage tips and configuration guides for Titan Two scripts and bytecodes published by the community users.

Deadzone, Antideadzone & Curve Manipulation

Postby EternalDahaka » Sun Jun 21, 2020 11:05 am

Hello everyone. This is the documentation page for my script. This will give a bit more information than the description and comments do in the file.

NOTICE FOR THOSE EXPERIENCING HIGH CPU USAGE
There are currently 3 versions of the script differing in the amount of options offered. This doc if you see high CPU usage, or experience headphone static, try using the Simple or Super Simple variants. PlayStation controllers poll faster than Xbox controllers, so this may be more noticeable with those and those alternatives might be preferable.

Many of the main script's options are niche, so the super simple version should be plenty for most games.

Overview:
This script can create circular deadzones, counter circular and square deadzones, set an outer deadzone, customization of the acceleration/response curve, ability to restricted diagonals or avoid them, uncap values, and use an alternate set of values when holding a user-defined button. These options exist for both sticks.

This was primarily created for aiming in shooters, but has applications for character and cursor movement where similar issues occur.

Deadzone, Antideadzone & Curve Manipulation v 1.07

Current Options:

    fix32 deadzone:
    This allows the user to create a circular deadzone. This can be used to increased the deadzone if their stick leans too far and they experience drift, or in conjunction with the antideadzone to maintain some deadzone while being able to affect the curve or replace a square deadzone with a circular one.

    Value range: 0.00 to 1.00
    Recommended range: 0.00 to 0.30

    fix32 antiCircularDeadzone:
    This allows the user to reduce or remove a game's circular deadzone. If a game's deadzone is 20%, a value of 0.20 will remove it.
    Most games hover around 15% to 25% deadzones, so values from 0.15 to 0.25 would be recommended.

    Accepted value range: 0.00 to 1.00
    Recommended range: 0.15 to 0.30

    fix32 antiSquareDeadzone:
    This can allow users to counter square/axial deadzones. Square deadzones have a side effect of restricting diagonal movement around the axes in a cross pattern, so this allows you skip those regions as well. Using the deadzone option with this can functionally change a square deadzone into feeling like a circular one. This can also stack with antiCircularDeadzone for games that use both types of deadzones(Destiny and Halo are some examples).
    Games hover around 15% to 25% deadzones, so values from 0.15 to 0.25 would be recommended.

    Accepted value range: 0.00 to 1.00
    Recommended range: 0.15 to 0.30

    fix32 outerDeadzoneIn:

    This value is useful if your stick fails to reach certain thresholds. If that's the case, setting this lower will allow you to output higher/maximum values the stick normally might not be able to reach. The output values are dependent on the outerDeadzoneOut value.

    Default: 1.00
    Accepted value range: 0.00 to 1.00
    Recommended range: 0.80 to 1.00

    fix32 outerDeadzoneOut:
    This caps values within a certain range. This is useful to avoid any "aim/look acceleration" threshold a game might have, and if known can make curve manipulation more accurate. This will scale to match square deadzone thresholds. It's important to note there is some inaccuracy with this option so magnitudes up to 1-2% under/over the threshold is possible, probably because of calculations after initially capping it. It's recommended to slightly raise/lower around the desire value to reliably avoid or trigger thresholds.
    Common outer deadzones range from 85% to 95% so values of 0.85 to 0.95 are recommended.

    Default: 1.00
    Accepted value range: 0.00 to 1.00
    Recommended range: 0.80 to 1.00

    fix32 degree:
    This allows alteration of the stick's response curve following a power function. This can be used to counter a game's curve or build on to it. If a game's curve is a quadratic(x^2), a value of 2.00 will counter it into as linear curve. Broadly higher values will start acceleration faster, and lower values will start it slower. It is recommended to counter the deadzone completely with the antideadzone options(and just set the deadzone to the preferred size) for the most reliable curve calculations.

    Default: 1.00
    Accepted value range: Positive values
    Recommended range: 0.50 to 2.00

    fix32 axialRestrict:

    This value restricts diagonal movement around the axes. This is functionally identical to how a square/axial deadzone restricts diagonal movement, but this does not affect the output stick magnitude at all. This is useful for players that want restricted diagonal movement consistently along the axis, but don't want the magnitude warped by using a normal square deadzone.
    It's important that the deadzone value is at least ~1.42x larger than this value to avoid any issues. Since this doesn't affect the magnitude, you can still see stick movement output within this central square "angle deadzone". This defaults to vertical movement regardless of stick direction within that "deadzone", and keeping the deadzone value larger than it avoids that.

    Default: 0.00
    Accepted value range: 0.00 to 1.00
    Recommended range: 0.00

    fix32 angularRestrict:

    This value restricts diagonal movement around the axes, but based on angle. There are no deadzone restrictions for this method. This method can stack with the axisRestrict value, with this range being offset by it in that amount.

    Default: 0.00
    Accepted value range: 0.00 to 90.00
    Recommended range: 0.00

    fix32 angularAnti:
    This is the opposite option of the previous, and has the stick skip over an angular range around the axes. This is different than the effect of square deadzones, and not too common in this form. This sacks with the offset for square antideadzones. Useful only for some games like DOOM2016/Eternal, Warframe or Red Dead Redemption 1.

    Default: 0.00
    Accepted value range: 0.00 to 90.00
    Recommended range: 0.00

    fix32 diagonalScaleMin/Max:
    These values allow you to scale the output diagonal values scaling from 1.00 at the axes to whatever the user sets when pointing at a perfect diagonal. Mostly useful for games that have inward "clover" like deadzones or thresholds, or games that don't normalize input/require sticks to reach the corners.
    Values lower than 1.00 will pinch the diagonals inward creating a clover shape. Values over 1.00 will begin to square the input so circular motions will output to a squarish range. Values over 1.00 ignore outerDeadzone capping.
    Min and Max values will transition smoothly between each other if set differently based on stick distance.
    Rarely, useful, but some examples I've come across of clover-like deadzones or thresholds are: Crash Bandicoot: N. Sane Trilogy, Prince of Persia: The Sands of Time, classic Halo titles(or MCC with classic aiming).

    Default: 1.00
    Accepted value range: 0.00 to sqrt(2.0) or ~1.4142 is recommended max as input will touch the corners
    Recommended range: 1.00

    bool uncapValues:
    This lets the values beyond the outer deadzone output. Curve calculations are reliable within the outerDeadzone ranges, however beyond that varies.
    Default FALSE should be fine in most cases, but TRUE may be desired if acceleration thresholds are unable to be accessed(can occur if they occur at 100% deflection), or if the game uses square deadzones and they aren't countered with antiSquareDeadzone. Square deadzones push diagonals further outer, and if not countered uncapValues will make full diagonal deflection inaccessible.

    Default: FALSE
    Accepted value range: TRUE or FALSE

    fix32 useAlternate:
    This allows a button input to trigger an alternate set of these values. Replacing this value with the index value of the button will allow you to use that button to switch values while that button is held down. By default this is 50 to avoid any buttons triggering it. You can find the index values by using F1 or going to Help > GPC Input Reference to see the list of buttons and using the numbers on the leftmost column.

    Default: 50
    Accepted value range: 0 to 41(depending on device inputs)


https://www.desmos.com/calculator/p58tkkkxbe
This gives a broad look how the output range and curve changes for most of the options.

v.1.08

Minor update

-fixed typo replicating ME.'s CPU fix. Full CPU optimization applied.

- altered diagonalScale implementation. Previously this functioned by changing with the angle, but this was changed to scale with a circular curve. The previous method ballooned or clovered the diagonals outward with values over 1.00, and this could result in some wasted diagonal movement. This change squares values over 1.00 so circular motions output to a square range.
Values under 1.00 still pinch inward in a clover fashion with a small change is shape. Previous values used should still work fine.

v.1.07

- added axial restrict option. Restrict diagonal movement from distance from the axes. Use values between 0.00 and 1.00.

-added angularRestrict option. Restrict diagonal movement around the axes based on the angle. Use values from 0.00 to 90.00.

- Changed useAlternate input. You'll enter the index value to select a button.

v1.06

- Added separate inner and outer diagonal scale options.

-Fixed outerDeadzoneOut not working as intended with antiSquareDeadzone.

- Fixed dumb issue making useAlternate stop working with last update. Moved it outside of main loop so input wasn't repeatedly checked.

- Horizontal stick values close to or 0 could cause jerky angle changes so a very small x value is substituted in those cases to avoid that.


v1.05

Huge CPU load reduction mimicking some optimization methods in ME.'s script rewrite(in comments below).

v1.04

Added diagonalScale option. Only useful for games with deadzones that bend inward or outward.

v1.03

Added separate input and output outerDeadzones.

outerDeadzoneOut functions as it did previously.

Having a separate Input can help with those whose sticks can't reach the edge properly still output full movements(much like outer deadzones within games).

v1.02

-applied angle wobble fix offered by Discord user ME. The real MVP.

-fixed outerDeadzone calculation. The previous implementation capped the input, but wasted much of the range of motion. This rescales the normal full range of motion to the restricted range.

v1.01
Reduced some code bloat. Added options to uncap values beyond the outer deadzone and use alternate settings with a button input.
Added/altered options:

-useAlternate replaces enableOn

-uncapValues

Noted issue:
Outside of the small inaccuracy with the outer deadzone, there is a small bug where angles will wobble just around the axes. I'm not sure why this happens. It could be an issue with my angle code or my use of the Atan function. This really isn't noticeable during gameplay, but I'll see if it can be fixed at some point.
Edit: This was solved by ME./DontAtMe

Ending notes:
Hopefully this is useful for some players and lets them find more comfortable settings in various games.

And finally, if the games don't offer options, please offer feedback to developers of the respective games. In-game options can remove the need for scripts and help everyone. Thanks!
Last edited by EternalDahaka on Mon Jun 06, 2022 10:42 pm, edited 10 times in total.
User avatar
EternalDahaka
Staff Sergeant
Staff Sergeant
 
Posts: 15
Joined: Tue Feb 23, 2016 7:12 am

Re: Deadzone, Antideadzone & Curve Manipulation

Postby Mad » Mon Jun 22, 2020 12:29 am

Thanks for sharing with us EternalDahaka and great documentation. :joia:
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: Deadzone, Antideadzone & Curve Manipulation

Postby Scarf » Sun Jul 05, 2020 5:29 pm

Hello, I’m new to the forum. I bought the Titan Two because I can’t stand games with deadzones, aim acceleration and slow response curves. Thanks EternalDahaka for this awesome script!

I have a few questions. I like to play with linear response curve. Apex Legends and Titanfall 2 are the only games that get the controller settings right. I’d like to get every game to feel the same as those games: minimal deadzone, linear response curve, zero aim acceleration and high sensitivity.

1) Is there a way to analyze the deadzones and response curves of each game? EternalDahaka, I’ve seen your posts on reddit about Halo MCC deadzones for example. How did you get all the information? I tried to get rid of the aim acceleration in Halo CE (I used the modern aiming option in the game’s settings) which is awful but I had to remove the Outer Deadzone by 0.40 points which makes the sensitivity too low. I think this affects the response curve, too.

2) If I counter the response curve by lets say 2.0 points, does it automatically make the response curve linear? Or do I need an exact number? If so, how would I know the exact number without knowing what response curve each game uses?

3) Is there a way to make the aiming feel the same in every game? A universal script that replaces the default settings or something. I know that you can use the Input Translator for a mouse but I’m using a controller. On PC there’s a program called reWASD which works great. You can emulate the mouse input and make the analog stick feel just right. But you’ll lose the aim assist which is a must in fast paced games. I know that you can copy the settings from Input Translator to a script but it doesn’t copy the X/Y sensitivity ratio, overall sensitivity or deadzones, only the response curve.

4) Nothing to do this with this thread but is the wired mode more responsive (less laggy) than the wireless mode when using an Xbox One controller v2 with an official Xbox wireless adapter v1 connected to the USB A port on the Titan Two? Both the input and output polling rates are set to 1000Hz. Do the polling rates affect how long the controller’s battery lasts?

Thanks a lot!
User avatar
Scarf
Sergeant
Sergeant
 
Posts: 8
Joined: Sun Jul 05, 2020 4:56 pm

Re: Deadzone, Antideadzone & Curve Manipulation

Postby Scoonix » Sun Jul 26, 2020 2:59 pm

Hi,

Thnks for all the work but... Where can I find your script :)
Kind regards
User avatar
Scoonix
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Sun Jul 26, 2020 2:51 pm

Re: Deadzone, Antideadzone & Curve Manipulation

Postby Mad » Sun Jul 26, 2020 10:03 pm

Scoonix wrote:Hi,

Thnks for all the work but... Where can I find your script :)
Kind regards

You can find his script in the online resource under the same title as this post: https://www.consoletuner.com/greslib/?w1095
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: Deadzone, Antideadzone & Curve Manipulation

Postby EternalDahaka » Wed Jul 29, 2020 4:11 am

Sorry for the late reply Scarf.

Scarf wrote:1) Is there a way to analyze the deadzones and response curves of each game? EternalDahaka, I’ve seen your posts on reddit about Halo MCC deadzones for example. How did you get all the information? I tried to get rid of the aim acceleration in Halo CE (I used the modern aiming option in the game’s settings) which is awful but I had to remove the Outer Deadzone by 0.40 points which makes the sensitivity too low. I think this affects the response curve, too.


It can be pretty tedious, but I just plot some points. I look at which stick positions start movement and don't, which ones create diagonal movement and don't and which ones see a large jump in acceleration and don't to gauge the thresholds for everything. Straightforward deadzones like square/axial and circular/radial deadzones become obvious after a few confirmed points.

You can put

set_val(STICK_1_Y, xx.xx);
set_val(STICK_1_X, xx.xx);

at the bottom of any script to test a few points yourself to get a feel, or if you can look at the gameplay and device monitor side-by-side. A very quick gauge is looking straight up or down and moving the stick left/right to test diagonals. I basically do this, but be a little more precise with the points.
https://youtu.be/e5fsPRJubOw?t=46

Something like Halo CE uses aim acceleration for most of its turn speed, but you shouldn't need to set the outerdeadzoneOut to less than 0.95 or 0.90 at lowest to avoid it under modern settings. You might also make sure uncapValues is set to FALSE in case I didn't default that in the current version update.

2) If I counter the response curve by lets say 2.0 points, does it automatically make the response curve linear? Or do I need an exact number? If so, how would I know the exact number without knowing what response curve each game uses?


If the game uses a quadratic curve, a degree value of 2.0 should make it linear.

I don't normally test acceleration curves because they're a big pain, but you could record some gameplay of the character spinning at different stick values and find the time it takes to spin between a certain spot for so many revolutions and plot that and you can estimate the curve reasonably accurately.

I just recommend just tossing in values to find something that feels close though. Way too much effort to test it.

3) Is there a way to make the aiming feel the same in every game? A universal script that replaces the default settings or something.


Unfortunately not really. Many games you can get close to feeling the same, but if the game uses smoothing, inconsistent acceleration thresholds, different restricted diagonals methods, or forced sensitivity ratios there's not much you can do about it. Unlike on PC where mouse input is standard for the most part and emulating it gives you free reign to replicate controls consistently, stick settings can vary wildly between games.

You can do a lot to try though. Games with square deadzones you can counter with the antiSquare value, and use the deadzone and degree to make it feel the way you want, and for some games that works well enough. A game like Killing Floor 2, which uses a square deadzone can be messed with to feel comparable to Titanfall without acceleration with the right values. You'll get close in a decent amount of them.

4) Nothing to do this with this thread but is the wired mode more responsive (less laggy) than the wireless mode when using an Xbox One controller v2 with an official Xbox wireless adapter v1 connected to the USB A port on the Titan Two? Both the input and output polling rates are set to 1000Hz. Do the polling rates affect how long the controller’s battery lasts?


Unfortunately I know nothing about that. I only use my controller with a cord so I have no idea how long the battery should last or how the latency is affected.
User avatar
EternalDahaka
Staff Sergeant
Staff Sergeant
 
Posts: 15
Joined: Tue Feb 23, 2016 7:12 am

Re: Deadzone, Antideadzone & Curve Manipulation

Postby Satohei » Thu Aug 27, 2020 3:59 pm

Just aware of the input lag. Since I can see that the CPU load is always exceeded to 100%, will it impact the input lag?
User avatar
Satohei
Private
Private
 
Posts: 1
Joined: Thu Aug 27, 2020 1:06 pm

Re: Deadzone, Antideadzone & Curve Manipulation

Postby Scachi » Thu Aug 27, 2020 4:43 pm

Satohei wrote:Just aware of the input lag. Since I can see that the CPU load is always exceeded to 100%, will it impact the input lag?

CPU with load of 100% or more can cause issues. Especially when using directly connected mouse and keyboard to the T2 as that puts some more load to the cpu than plain gamepad input.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Deadzone, Antideadzone & Curve Manipulation

Postby DontAtMe » Fri Aug 28, 2020 12:50 am

Satohei wrote:Just aware of the input lag. Since I can see that the CPU load is always exceeded to 100%, will it impact the input lag?

Code: Select all
/*
*
*  stick_adjustments.gpc
*
*  This script is heavily based off of Eternal Dahaka's   
*  `Deadzone, Anti-Deadzone and Curve Manipulation` Script.
*
*  Main Improvements:
*   - Optimized code.
*   - Greatly decreased CPU Load.
*   - Added an Interactive Configuration.
*
*/

 
/*^  cfgdesc
<cfgdesc>
 
[Right Stick]
byteoffset  = 0
bitsize     = 16
collapsible = 0
border = 0
group = 1
shortdesc   = <b> Stick Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[right_antiCircleDeadzone]
byteoffset  = 2
bitsize     = 16
group = 1
shortdesc   = <b> Anti-Circle Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[rightAnti-Square Deadzone]
byteoffset  = 4
bitsize     = 16
group = 1
shortdesc   = <b> Anti-Square Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[rightOuter Deadzone]
byteoffset  = 6
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>IN</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[rightOuter Deadzone <i>(Out)</i>]
byteoffset  = 8
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>OUT</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[right_degree]
byteoffset  = 10
bitsize     = 16
group = 1
shortdesc   = <b>Sensitivity
control     = spinboxf
default     = 10
minimum     = 3
maximum     = 30
step        = 1
decimals    = 1
 
[right_angular]
byteoffset  = 12
bitsize     = 16
group = 1
shortdesc  = <b> Angular Deadzone
control     = spinboxf
default     = 1
minimum     = 1
maximum     = 450
step        = 1
decimals    = 1
 
[right_uncap]
byteoffset  = 56
bitsize     = 8
group = 1
control     = checkbox
default     = 0
item = Cap Stick Values To Outer Deadzone (Out)
 
[Right Stick Alternate]
bitsize = 8
byteoffset = 60
collapsible = 2
border = 1
shortdesc = <b>Activate With:
control = combobox
item    = DISABLED
item    = BUTTON_1
item    = BUTTON_2
item    = BUTTON_3
item    = BUTTON_4
item    = BUTTON_5
item    = BUTTON_6
item    = BUTTON_7
item    = BUTTON_8
item    = BUTTON_9
item    = BUTTON_10
item    = BUTTON_11
item    = BUTTON_12
item    = BUTTON_13
item    = BUTTON_14
item    = BUTTON_15
item    = BUTTON_16
item    = BUTTON_17
item    = BUTTON_18
item    = BUTTON_19
item    = BUTTON_20
item    = BUTTON_21
item    = STICK_1_X
item    = STICK_1_Y
item    = STICK_2_X
item    = STICK_2_Y
item    = POINT_1_X
item    = POINT_1_Y
item    = POINT_2_X
item    = POINT_2_Y
item    = ACCEL_1_X
item    = ACCEL_1_Y
item    = ACCEL_1_Z
item    = ACCEL_2_X
item    = ACCEL_2_Y
item    = ACCEL_2_Z
item    = GYRO_1_X
item    = GYRO_1_Y
item    = GYRO_1_Z
item    = PADDLE_1
item    = PADDLE_2
item    = PADDLE_3
item    = PADDLE_3
item    = PADDLE_4
 
[right_deadzoneA]
byteoffset  = 14
bitsize     = 16
group = 1
shortdesc   = <b> Stick Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[right_antiCircleDeadzoneA]
byteoffset  = 16
bitsize     = 16
group = 1
shortdesc   = <b> Anti-Circle Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[rightAnti-Square DeadzoneA]
byteoffset  = 18
bitsize     = 16
group = 1
shortdesc   = <b> Anti-Square Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[rightOuter_DeadzoneA]
byteoffset  = 20
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>IN</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[rightOuter Deadzone <i>(Out)</i>A]
byteoffset  = 22
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>OUT</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[right_degreeA]
byteoffset  = 24
bitsize     = 16
group = 1
shortdesc   = <b> Sensitivity
control     = spinboxf
default     = 10
minimum     = 3
maximum     = 30
step        = 1
decimals    = 1
 
[right_angularA]
byteoffset  = 26
bitsize     = 16
group = 1
shortdesc  = <b> Angular Deadzone
control     = spinboxf
default     = 1
minimum     = 1
maximum     = 450
step        = 1
decimals    = 1
 
[right_uncapA]
byteoffset  = 57
bitsize     = 8
group = 1
control     = checkbox
default     = 0
item = Cap Stick Values To Outer Deadzone (Out)
 
[space]
control = space
default = 20
 
[Left Stick]
byteoffset  = 28
bitsize     = 16
collapsible = 0
border = 0
group = 0
shortdesc   = <b> Stick Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[left_antiCircleDeadzone]
byteoffset  = 30
bitsize     = 16
group = 1
shortdesc   = <b> Anti-Circle Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[leftantiSquare Deadzone]
byteoffset  = 32
bitsize     = 16
group = 1
shortdesc   = <b> Anti-Square Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[leftOuter Deadzone]
byteoffset  = 34
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>IN</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[leftOuter Deadzone <i>(Out)</i>]
byteoffset  = 36
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>OUT</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[left_degree]
byteoffset  = 38
bitsize     = 16
group = 1
shortdesc   = <b>Sensitivity
control     = spinboxf
default     = 10
minimum     = 3
maximum     = 30
step        = 1
decimals    = 1
 
[left_angular]
byteoffset  = 40
bitsize     = 16
group = 1
shortdesc   = <b> Angular Deadzone
control     = spinboxf
default     = 1
minimum     = 1
maximum     = 450
step        = 1
decimals    = 1
 
[left_uncap]
byteoffset  = 58
bitsize     = 8
group = 1
control     = checkbox
default     = 0
item = Cap Stick Values To Outer Deadzone (Out)
 
[Left Stick Alternate]
bitsize = 8
byteoffset = 61
collapsible = 2
border = 1
shortdesc = <b>Activate With:
control = combobox
item    = DISABLED
item    = BUTTON_1
item    = BUTTON_2
item    = BUTTON_3
item    = BUTTON_4
item    = BUTTON_5
item    = BUTTON_6
item    = BUTTON_7
item    = BUTTON_8
item    = BUTTON_9
item    = BUTTON_10
item    = BUTTON_11
item    = BUTTON_12
item    = BUTTON_13
item    = BUTTON_14
item    = BUTTON_15
item    = BUTTON_16
item    = BUTTON_17
item    = BUTTON_18
item    = BUTTON_19
item    = BUTTON_20
item    = BUTTON_21
item    = STICK_1_X
item    = STICK_1_Y
item    = STICK_2_X
item    = STICK_2_Y
item    = POINT_1_X
item    = POINT_1_Y
item    = POINT_2_X
item    = POINT_2_Y
item    = ACCEL_1_X
item    = ACCEL_1_Y
item    = ACCEL_1_Z
item    = ACCEL_2_X
item    = ACCEL_2_Y
item    = ACCEL_2_Z
item    = GYRO_1_X
item    = GYRO_1_Y
item    = GYRO_1_Z
item    = PADDLE_1
item    = PADDLE_2
item    = PADDLE_3
item    = PADDLE_3
item    = PADDLE_4
 
[left_deadzoneA]
byteoffset  = 42
bitsize     = 16
group = 1
shortdesc   = <b> Stick Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[left_antiCircleDeadzoneA]
byteoffset  = 44
bitsize     = 16
group = 1
shortdesc   = <b>Anti-Circle Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[leftantiSquare DeadzoneA]
byteoffset  = 46
bitsize     = 16
group = 1
shortdesc   = <b>Anti-Square Deadzone
control     = spinboxf
default     = 0
minimum     = 0
maximum     = 3000
step        = 100
decimals    = 2
 
[leftOuter DeadzoneA]
byteoffset  = 48
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>IN</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[leftOuter Deadzone <i>(Out)</i>A]
byteoffset  = 50
bitsize     = 16
group = 1
shortdesc   = <b>Outer Deadzone - <i>OUT</i>
control     = spinboxf
default     = 10000
minimum     = 8000
maximum     = 10000
step        = 100
decimals    = 2
 
[left_degreeA]
byteoffset  = 52
bitsize     = 16
group = 1
shortdesc   = <b>Sensitivity
control     = spinboxf
default     = 10
minimum     = 3
maximum     = 30
step        = 1
decimals    = 1
 
[left_angularA]
byteoffset  = 54
bitsize     = 16
group = 1
shortdesc   = <b> Angular Deadzone
control     = spinboxf
default     = 1
minimum     = 1
maximum     = 450
step        = 1
decimals    = 1
 
[left_uncapA]
byteoffset  = 59
bitsize     = 8
group = 1
control     = checkbox
default     = 0
item = Cap Stick Values To Outer Deadzone (Out)
</cfgdesc>*/

 
#pragma METAINFO("Stick adjustments", 1, 0, "DontAtMe")
int right_deadzone;
int right_antiCircleDeadzone;
int right_antiSquareDeadzone;
int right_outerDeadzoneIn;
int right_outerDeadzoneOut;
int right_degree;
int right_angular;
int right_deadzoneA;
int right_antiCircleDeadzoneA;
int right_antiSquareDeadzoneA;
int right_outerDeadzoneInA;
int right_outerDeadzoneOutA;
int right_degreeA;
int right_angularA;
int left_deadzone;
int left_antiCircleDeadzone;
int left_antiSquareDeadzone;
int left_outerDeadzoneIn;
int left_outerDeadzoneOut;
int left_degree;
int left_angular;
int left_deadzoneA;
int left_antiCircleDeadzoneA;
int left_antiSquareDeadzoneA;
int left_outerDeadzoneInA;
int left_outerDeadzoneOutA;
int left_degreeA;
int left_angularA;
bool  right_uncap;
bool  right_uncapA;
bool  left_uncap;
bool  left_uncapA;
uint8 right_alternateButton;
uint8 left_alternateButton;
 
init { /*^ Init */
  pmem_load();
  uint8 i;
  do {
    pmem_read(i, &right_deadzone[-(i/2)]);
  } while(i = (i + 2) % 58);
  pmem_read(56,&right_uncap);
  pmem_read(57,&right_uncapA);
  pmem_read(58,&left_uncap);
  pmem_read(59,&left_uncapA);
  pmem_read(60,&right_alternateButton);
  pmem_read(61,&left_alternateButton);
}
 
fix32 stick_1_x, stick_1_y;
fix32 stick_2_x, stick_2_y;
main {  /*^ main */
  static fix32 prev_rx, prev_ry;
  fix32 rx = get_val(STICK_1_X);
  fix32 ry = get_val(STICK_1_Y);
 
  if(prev_rx != rx || prev_ry != ry) {
 
    if(right_alternateButton && get_actual(right_alternateButton-1))
    applyStick(
    (fix32)(right_deadzoneA>>8),
    (fix32)(right_antiCircleDeadzoneA>>8),
    (fix32)(right_antiSquareDeadzoneA>>8),
    (fix32)(right_outerDeadzoneInA>>8),
    (fix32)(right_outerDeadzoneOutA>>8),
    (fix32)(right_degreeA>>8),
    (fix32)(right_angularA>>8),
    !right_uncapA, 2);
    else
    applyStick(
    (fix32)(right_deadzone>>8),
    (fix32)(right_antiCircleDeadzone>>8),
    (fix32)(right_antiSquareDeadzone>>8),
    (fix32)(right_outerDeadzoneIn>>8),
    (fix32)(right_outerDeadzoneOut>>8),
    (fix32)(right_degree>>8),
    (fix32)(right_angular>>8),
    !right_uncap, 2);
 
    prev_ry = ry;
    prev_rx = rx;
  }
 
  set_val(STICK_1_X, stick_1_x);
  set_val(STICK_1_Y, stick_1_y);
 
  static fix32 prev_lx, prev_ly;
  fix32 lx = get_val(STICK_2_X);
  fix32 ly = get_val(STICK_2_Y);
 
  if(prev_lx != lx || prev_ly != ly) {
 
    if(left_alternateButton && get_actual(left_alternateButton-1))
    applyStick(
    (fix32)(left_deadzoneA>>8),
    (fix32)(left_antiCircleDeadzoneA>>8),
    (fix32)(left_antiSquareDeadzoneA>>8),
    (fix32)(left_outerDeadzoneInA>>8),
    (fix32)(left_outerDeadzoneOutA>>8),
    (fix32)(left_degreeA>>8),
    (fix32)(left_angularA>>8),
    !left_uncapA, 4);
    else
    applyStick(
    (fix32)(left_deadzone>>8),
    (fix32)(left_antiCircleDeadzone>>8),
    (fix32)(left_antiSquareDeadzone>>8),
    (fix32)(left_outerDeadzoneIn>>8),
    (fix32)(left_outerDeadzoneOut>>8),
    (fix32)(left_degree>>8),
    (fix32)(left_angular>>8),
    !left_uncap, 4);
 
    prev_ly = ly;
    prev_lx = lx;
  }
 
  set_val(STICK_2_X, stick_2_x);
  set_val(STICK_2_Y, stick_2_y);
 
}
 
void applyStick(fix32 stickDeadzone, fix32 antiCDeadzone, fix32 antiSDeadzone, fix32 outerDeadzoneIn,
fix32 outerDeadzoneOut, fix32 deg, fix32 angular, bool uncap, uint8 stick){
 
  fix32 x = get_val(19+stick);
  fix32 y = get_val(20+stick);
 
  if(!x) x = 0.1;
  if(!y) y = 0.1;
 
  fix32 inputMagnitude  = sqrt(sq(x) + sq(y));
 
  fix32 outputMagnitude;
  if(inputMagnitude > stickDeadzone) {
 
    outputMagnitude = (inputMagnitude - stickDeadzone) / (outerDeadzoneIn - stickDeadzone);
    outputMagnitude = pow(outputMagnitude, 1f/deg) * (outerDeadzoneOut - antiCDeadzone) + antiCDeadzone;
 
    if(!uncap) outputMagnitude = min(outerDeadzoneOut, outputMagnitude);
 
    fix32 temp = deg2rad(angular/2.0);
    fix32 angle = abs(atan(y/x));
 
    angle =  (0.785522 * angle - angle * temp + 0.785522 * temp) / 0.785522;
    if(x < 0.0 && y > 0.0) angle = -angle + PI;
    else if(x > 0.0 && y < 0.0) angle = -angle;
    else if(x < 0.0 && y < 0.0) angle =  angle + PI;
 
    fix32 newX = cos(angle);
    fix32 newY = sin(angle);
 
    if (angle > 0.785522 && angle < 3.92761) {
      newX = sin(1.5708 - angle);
      newY = cos(1.5708 - angle);
    }
 
    newX = abs(newX * outputMagnitude) * (1.0 - antiSDeadzone/100f) + antiSDeadzone;
    if(x < 0.0) newX *= -1.0;
    newY = abs(newY * outputMagnitude) * (1.0 - antiSDeadzone/100f) + antiSDeadzone;
    if(y < 0.0) newY *= -1.0;
 
    newX = clamp(newX, -outerDeadzoneOut, outerDeadzoneOut);
    newY = clamp(newY, -outerDeadzoneOut, outerDeadzoneOut);
 
    if(stick == 2){
      stick_1_x = newX;
      stick_1_y = newY;
    }
    else{
      stick_2_x = newX;
      stick_2_y = newY;
    }
  }
  else {
    if(stick == 2){
      stick_1_x = 0.0;
      stick_1_y = 0.0;
    }
    else {
      stick_2_x = 0.0;
      stick_2_y = 0.0;
    }
  }
}

CPU load fixed with this version.
Also included an interactive config.
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am

Re: Deadzone, Antideadzone & Curve Manipulation

Postby EternalDahaka » Mon Aug 31, 2020 1:06 am

DontAtMe with a wholesale improvement this time, AND a flex with the interactive config. :innocent_smile_1:
I hadn't noticed the CPU load until recently when using it with a headset and noticing the static. I was planning on asking about optimization but it's already been addressed.

That optimization is too big-brained for me, so I'm not sure I could integrate or make future minor option updates off that, but everything important is already covered so your version can now be the go-to version. Thanks for creating it.

Edit: Is there some way to edit the code to make the sensitivity(curve value) a float of some kind? I know it's to optimize, but it only seems possible to make large edits since it floors them to the integer so there's not granular customization or ability to slow down the curve. Sorry for the bother.

Edit2: The bulk of it seemed to be just checking if the current values were the same as the previous loop's. I thought maybe the data types or set_val calls might be the main thing, but that seems to have done it. There's still changes I don't understand, but that's something I'm able to replicate and get's the load ~3% without the other changes which fixes this issue.
Thanks again for for the help DontAtMe.

Edit3: Updated!
User avatar
EternalDahaka
Staff Sergeant
Staff Sergeant
 
Posts: 15
Joined: Tue Feb 23, 2016 7:12 am

Next

Return to User's Script Documentation

Who is online

Users browsing this forum: No registered users and 84 guests