Help with deadzones

GPC2 script programming for Titan Two. Code examples, questions, requests.

Help with deadzones

Postby pablosscripts » Mon Sep 17, 2018 12:25 am

I have the following code:

Code: Select all
    if(get_val(LS_Y) <= sprint_threshold) {
        run_flag = !run_flag;
    } else if(event_release(LS_Y) > sprint_threshold_int) {
        run_flag = !run_flag;
        last_button_pressed_jump = FALSE;
        last_button_pressed_crouch = FALSE;
    }


And the bottom part (else) triggers when I let go of the stick. It used to work perfectly but now that I've had deadzones develop, it's become very inconsistent. Is there anyway to improve the reliability of this now that I have bad deadzones?
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: Help with deadzones

Postby J2Kbr » Mon Sep 17, 2018 3:18 pm

The event_release() with sticks is triggered when the value cross the 20% mark, going to the rest position. Please give more details about the deadzone adjustments you are doing.

Also, the first conditional if(get_val(LS_Y) <= sprint_threshold) evaluates as TRUE whenever the LS_Y value is lower then sprint_threshold, which would make run_flag to toggle over and over. Maybe the inconsistency you are experiencing is related to this.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Help with deadzones

Postby pablosscripts » Mon Sep 17, 2018 3:25 pm

I'm not even sure if it's the deadzone, but I just have a strong feeling it is. The reason is I'm using the Nintendo Joy-Cons which are known for having really bad deadzones, and it was working fine yesterday but now it's acting very inconsistent so that leads me to think it's somehow deadzone related.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: Help with deadzones

Postby pablosscripts » Tue Sep 18, 2018 3:31 am

I solved it, but I still don't know how...

The variable sprint_threshold_int is set to 50. This is really inconsistent. It never works reliably.

But when I change it from a variable to a hardcoded value it works perfectly, so changing it from this:

Code: Select all
  if(get_val(LS_Y) <= sprint_threshold) {
        run_flag = !run_flag;
    } else if(event_release(LS_Y) > sprint_threshold_int) {
        run_flag = !run_flag;
        last_button_pressed_jump = FALSE;
        last_button_pressed_crouch = FALSE;
    }


To this:

Code: Select all
  if(get_val(LS_Y) <= sprint_threshold) {
        run_flag = !run_flag;
    } else if(event_release(LS_Y) > 50) {
        run_flag = !run_flag;
        last_button_pressed_jump = FALSE;
        last_button_pressed_crouch = FALSE;
    }


Seemed to fix it. I've been testing it a lot and it seems rock solid now. Any idea why?
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: Help with deadzones

Postby J2Kbr » Tue Sep 18, 2018 6:44 am

pablosscripts wrote:Any idea why?

I just noticed something I missed when replied you yesterday, this part
Code: Select all
} else if(event_release(LS_Y) > 50) {
will never evaluate as TRUE. Because event_release() returns a boolean value (0 or 1), which will never be greater than 50.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Help with deadzones

Postby pablosscripts » Tue Sep 18, 2018 7:41 am

Hum interesting, ok so the correct way to code this would be:

Code: Select all
} else if(event_release(LS_Y) == TRUE) {
 
 
or I guess this is the same:
 
} else if(event_release(LS_Y)) {


Is that right?

And is this the same as GPC1? I simply ported some T1 code over, or was the original code flawed as well?
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: Help with deadzones

Postby J2Kbr » Tue Sep 18, 2018 9:13 am

both options are correct, but the second one
Code: Select all
} else if(event_release(LS_Y)) {
is better optimized (speed and bytecode size). This is also valid for the Titan One scripts. :smile0517:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Help with deadzones

Postby pablosscripts » Wed Sep 19, 2018 2:41 am

awesome thank you
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 49 guests