Double Flick Joystick with other keys active

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

Double Flick Joystick with other keys active

Postby RobExe » Thu Feb 14, 2019 2:57 pm

Hey, just grabbed me a Titan Two yesterday and been up all night and morning trying to learn the language for creating a simple script. I'm trying to automate a "W+W" double tap that triggers in a single keystroke of "P" that loops over and over while holding my mouse button on my g502. I guess W+W would mean flicking Left Joystick upwards twice quickly. My mouse button on the g502 is configured as "P" through logitech's software.

I have my setup in this order:
KB/M -> T2 & Xbox One Controller -> Apex -> Console

I had some difficulty getting a script working in-game but I finally got something by reading the guides here on the website. I used the BunnyHop script template, added some KB/M lines and finally had some progress.

Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
init {
    keymapping();
    mousemapping();
}
 
main {
    key_passthru();
    mouse_passthru();
  if(key_status(KEY_P)) { combo_run(cBunnyHop); }
  else {combo_stop(cBunnyHop);}
 }
 
combo cBunnyHop {
  set_val(STICK_2_Y,0)
  wait(100);             
  set_val(STICK_2_Y,-100);
  wait(100);             
}


Now the part I'm stuck at is.. I need my mouse button "P" to work at the same time while holding other keys like WASD (LeftJoystick) E,F,Q,Spacebar and Left Shift. How it currently stands, If I'm holding W to move forward and then hold "P" to dash, nothing will happen. I'll just continue running forward without any dash.

Should I just make a macro of W+W and then put it in a script? How should I go about this? Any help is appreciated, thanks.
User avatar
RobExe
Private First Class
Private First Class
 
Posts: 2
Joined: Thu Feb 14, 2019 2:13 pm

Re: Double Flick Joystick with other keys active

Postby J2Kbr » Tue Feb 19, 2019 9:44 am

RobExe wrote:Should I just make a macro of W+W and then put it in a script? How should I go about this? Any help is appreciated, thanks.

This code will double press W when P is pressed, even if W is already being pressed in the keyboard. :smile0517:
Code: Select all
#include <keyboard.gph>
 
main {
    static bool key_p_event;
    if(key_status(KEY_P)) {
        if(!key_p_event) {
            key_p_event = TRUE;
            combo_run(DoubleW);
        }
    } else key_p_event = FALSE;
}
 
combo DoubleW {
    key_set(KEY_W, 1);
    wait(50);
    key_set(KEY_W, 0);
    wait(50);
    key_set(KEY_W, 1);
    wait(50);
    key_set(KEY_W, key_status(KEY_W));
}
 
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: Double Flick Joystick with other keys active

Postby RobExe » Sat Feb 23, 2019 11:55 am

Thanks a ton J2Kbr! My game ended beta a few days ago, so I'll have to wait a few more days for launch so I can test out the script. In the meantime, could you help me with another issue? I'd like to have keyboard keys

L + A = LeftShift + A
L + D = LeftShift + D
L + S = LeftShift + S
L + W = W + F

Pretty much want the 'L' key mapped on my mouse button to do different keystrokes depending on the combination of keys I press it with. 'L' would become Left Shift if used with 'A' 'D' or 'S'. and 'L' would become F if used with 'W'.

If possible I'd want it to function the same as it would function normally pressing the W+F & LShift+ASD keys on a keyboard.. they'll stay activated until released. Also L should be able to be pressed both before or after the other key.

WASD are movement keys in my game. So for example if I'm holding down 'A' which is left movement and then press 'L', it'll be the same as holding down 'A' and then pressing 'Left Shift' and if I'm holding down 'L' first, it obviously wouldn't have any function by itself, but as soon as i hit 'A', the function of "Left Shift + A" triggers. Same would go for "W + F". I hope I'm explaining it correctly. I'm not sure if it's simpler to write the script then I'm making it out to be :whistling:

I really hope that wouldn't be too much trouble.. I'm still trying to wrap my head around the scripting part.. Feels like I'm in school again lol. I'm gonna take a closer look at the script you just gave me and see if I can figure out how you made it, I really wanna learn this stuff :smile0202: Thanks again

-EDIT-
I think I got something working.. I'll test it further and post again if it does
User avatar
RobExe
Private First Class
Private First Class
 
Posts: 2
Joined: Thu Feb 14, 2019 2:13 pm

Re: Double Flick Joystick with other keys active

Postby J2Kbr » Mon Feb 25, 2019 2:07 pm

RobExe wrote:-EDIT- I think I got something working.. I'll test it further and post again if it does

: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


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 125 guests