"Sticky" radial menu script

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

"Sticky" radial menu script

Postby pablosscripts » Sat Jul 24, 2021 4:37 pm

Hi all, I'm pretty sure I've seen this posted before but I can't seem to find it.

Some games require you to hold the analogue stick in a certain direction before letting go of the menu button. I would like to make it so a quick flick of the stick is all I need to do.

Here's my attempt at it but it doesn't work:

Code: Select all
        if(get_val(ZR)) {
                radial_menu_selection_y = (int) get_val(RS_Y);
                radial_menu_selection_x = (int) get_val(RS_X);
            }
 
        set_val(RS_Y, radial_menu_selection_y);
        set_val(RS_X, radial_menu_selection_x);
        if(event_release(ZR)) {
            radial_menu_selection_y = 0;
            radial_menu_selection_x = 0;
        }
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: "Sticky" radial menu script

Postby Scachi » Sat Jul 24, 2021 5:35 pm

welcome back ;-)
give this a try:
Code: Select all
int radial_menu_selection_y, radial_menu_selection_x;
#define ZR BUTTON_9
#define RS_X STICK_1_X
#define RS_Y STICK_1_Y
#define S_MIN 80
 
main {
        if(get_val(ZR)) {
            if (abs(get_val(RS_Y)) > (fix32)S_MIN || abs(get_val(RS_X)) > (fix32)S_MIN) {
                radial_menu_selection_y = (int) get_val(RS_Y);
                radial_menu_selection_x = (int) get_val(RS_X);
            }
        }
 
        set_val(RS_Y, radial_menu_selection_y);
        set_val(RS_X, radial_menu_selection_x);
        if(event_release(ZR)) {
            radial_menu_selection_y = 0;
            radial_menu_selection_x = 0;
        }
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: "Sticky" radial menu script

Postby pablosscripts » Sun Jul 25, 2021 2:37 am

Great to be back! It works great in the menu but after that the stick becomes completely unresponsive. In Device Monitor it seems nothing is making its way through.
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: "Sticky" radial menu script

Postby Scachi » Sun Jul 25, 2021 6:07 am

Sounds like you want that active only as long as you hold down that ZR button:
Code: Select all
int radial_menu_selection_y, radial_menu_selection_x;
#define ZR BUTTON_9
#define RS_X STICK_1_X
#define RS_Y STICK_1_Y
#define S_MIN 80
 
main {
        if(get_val(ZR)) {
            if (abs(get_val(RS_Y)) > (fix32)S_MIN || abs(get_val(RS_X)) > (fix32)S_MIN) {
                radial_menu_selection_y = (int) get_val(RS_Y);
                radial_menu_selection_x = (int) get_val(RS_X);
            }
            set_val(RS_Y, radial_menu_selection_y);
            set_val(RS_X, radial_menu_selection_x);
        }
 
        if(event_release(ZR)) {
            radial_menu_selection_y = 0;
            radial_menu_selection_x = 0;
        }
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: "Sticky" radial menu script

Postby pablosscripts » Sun Jul 25, 2021 6:15 am

That's it 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

Re: "Sticky" radial menu script

Postby pablosscripts » Sun Aug 01, 2021 2:34 am

Is it possible to make it so it's only sticky if you hold the stick at the edge for half a second, otherwise it "dislodges" and goes back to normal? I tried adding using time_active() but I couldn't get it working.
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 100 guests