Dead Zone Remover Bug
2 posts
• Page 1 of 1
Dead Zone Remover Bug
I downloaded this deadzone remover gph for the right stick, I wanted to add it to the left stick as well.
But there seems to be a bug, sometimes I cant move to the right with my left stick, it does nothing, I can move forward, backwards and left, but not right. something triggers it, it stays that way till I reset the script.
Does someone know how to fix this bug?
So now im using it only for the right stick.
But there seems to be a bug, sometimes I cant move to the right with my left stick, it does nothing, I can move forward, backwards and left, but not right. something triggers it, it stays that way till I reset the script.
Does someone know how to fix this bug?
- Code: Select all
#pragma METAINFO("CDZ", 1, 0, "<VYV>")
#ifndef DEADZONE_GPC_
#define DEADZONE_GPC_
fix32 minv_l = 7.0;
fix32 minv_r = 7.0; //5.0/7.0/10 adjust so resting position never register.
fix32 DeadZone = 24.3; //24.3// 24.8 for curve1 adjust to your game deadzone must be lower than 40.00
fix32 normalized_dz = DeadZone / 100.00;
fix32 sqrt2 = 1.414213562;
// sensitivity multiplier settings
fix32 X_Sens = 1.0;
fix32 Y_Sens = 1.0;
fix32 X_Sens_Aim = 0.8;
fix32 Y_Sens_Aim = 0.8;
// init
init {
}
// main
main {
polarDZ(STICK_2_X, STICK_2_Y, STICK_1_X, STICK_1_Y, normalized_dz);
}
void polarDZ(uint8 io_lx, uint8 io_ly, uint8 io_rx, uint8 io_ry, fix32 dz){
fix32 lx = get_actual(io_lx);
fix32 ly = get_actual(io_ly);
fix32 rx = get_actual(io_rx);
fix32 ry = get_actual(io_ry);
fix32 lr;
fix32 rr;
fix32 angle_l = atan2(ly,lx);
fix32 radius_l = sqrt(lx*lx + ly*ly);
fix32 angle_r = atan2(ry,rx);
fix32 radius_r = sqrt(rx*rx + ry*ry);
if(radius_l >= minv_l || radius_r >= minv_r){
if (radius_l >= minv_l){
lr = curve_l(radius_l/100.00, dz);
out_of_dz_l(io_lx, io_ly, angle_l, lr, dz);
}
if (radius_r >= minv_r){
rr = curve_r(radius_r/100.00, dz);
out_of_dz_r(io_rx, io_ry, angle_r, rr, dz);
}
} else return;
return;
}
fix32 curve_l(fix32 io_value ,fix32 dz_value){
fix32 s = sin(io_value);
return (1.00-dz_value)*sqrt2 * s *s;
}
fix32 curve_r(fix32 io_value ,fix32 dz_value){
fix32 s = sin(io_value);
return (1.00-dz_value)*sqrt2 * s *s;
}
void out_of_dz_l(uint8 io_lx, uint8 io_ly, fix32 angle_l, fix32 lr, fix32 dz){
fix32 OutLX = cos(angle_l) * (lr + dz ) * 100.00;
fix32 OutLY = sin(angle_l) * (lr + dz ) * 100.00;
set_val(io_lx, clamp(OutLX,-100.00,100.00));
set_val(io_ly, clamp(OutLY,-100.00,100.00));
}
void out_of_dz_r(uint8 io_rx, uint8 io_ry, fix32 angle_r, fix32 rr, fix32 dz){
fix32 OutRX = cos(angle_r) * (rr + dz ) * 100.00;
fix32 OutRY = sin(angle_r) * (rr + dz ) * 100.00;
if(get_actual(BUTTON_8)){
set_val(io_rx, clamp(OutRX,-100.00,100.00) * X_Sens_Aim);
set_val(io_ry, clamp(OutRY,-100.00,100.00) * Y_Sens_Aim);
} else {
set_val(io_rx, clamp(OutRX,-100.00,100.00) * X_Sens);
set_val(io_ry, clamp(OutRY,-100.00,100.00) * Y_Sens);
}
}
#endif
So now im using it only for the right stick.
- Code: Select all
#pragma METAINFO("CDZ", 1, 0, "<VYV>")
#ifndef DEADZONE_GPC_
#define DEADZONE_GPC_
fix32 minv = 10; //5.0/7.0/10 adjust so resting position never register.
fix32 DeadZone = 24.3; //24.3// 24.8 for curve1 adjust to your game deadzone must be lower than 40.00
fix32 normalized_dz = DeadZone / 100.00;
fix32 sqrt2 = 1.414213;
// sensitivity multiplier settings
fix32 X_Sens = 1.0;
fix32 Y_Sens = 0.95;
fix32 X_Sens_Aim = 1.0;
fix32 Y_Sens_Aim = 0.95;
// init
init {
}
// main
main {
polarDZ(STICK_1_X, STICK_1_Y, normalized_dz);
}
void polarDZ(uint8 io_rx, uint8 io_ry, fix32 dz){
fix32 rx = get_actual(io_rx);
fix32 ry = get_actual(io_ry);
fix32 rr;
fix32 angle_r = atan2(ry,rx);
fix32 radius_r = sqrt(rx*rx + ry*ry);
if (radius_r >= minv){
rr = curve(radius_r/100.00, dz);
} else return;
fix32 OutRX = cos(angle_r) * (rr + dz ) * 100.00;
fix32 OutRY = sin(angle_r) * (rr + dz ) * 100.00;
if(get_actual(BUTTON_8)){
set_val(io_rx, clamp(OutRX,-100.00,100.00) * X_Sens_Aim);
set_val(io_ry, clamp(OutRY,-100.00,100.00) * Y_Sens_Aim);
} else {
set_val(io_rx, clamp(OutRX,-100.00,100.00) * X_Sens);
set_val(io_ry, clamp(OutRY,-100.00,100.00) * Y_Sens);
}
return;
}
fix32 curve(fix32 io_value ,fix32 dz_value){
fix32 s = sin(io_value);
return (1.00-dz_value)*sqrt2 * s *s;
}
#endif
-
lorenzostolk - Sergeant First Class
- Posts: 17
- Joined: Mon Nov 09, 2015 8:00 am
Re: Dead Zone Remover Bug
Instead of modifying the function you can just call it twice:
Try that with the original code see if it works for you.
- Code: Select all
main {
polarDZ(STICK_1_X, STICK_1_Y, normalized_dz);
polarDZ(STICK_2_X, STICK_2_Y, normalized_dz);
}
Try that with the original code see if it works for you.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
- Mad
- Major General
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
2 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 51 guests