Script side mouse button

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

Script side mouse button

Postby Mimis » Sat Nov 06, 2021 3:06 pm

Hi, I need help with my script.
My setup: Mouse and Keyboard > T2 > PC output protocol Xbox 360.
I use it because I want to have the mouse and keyboard movement allied to the advantages of aim assist.
My script is this:
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
main {
 
    if (mouse_status(MBUTTON_5)) {
            combo_run(Toggle);
            combo_run(pAR); }
mouse_wheel(); }
 
combo Toggle {
    set_val(BUTTON_15,100);
    wait(30);
    wait(30);}
 
combo pAR {
    set_val(BUTTON_7,100);
    wait(30);
    wait(30);
    set_val(BUTTON_7, 0);}
combo cMWheelBack {
set_val(BUTTON_13,100);   
    wait(30);
    wait(30);
set_val(BUTTON_8,100);
    wait(30);
    wait(30);
set_val(BUTTON_15,100);
    wait(30);
    wait(30);
 }
 
void mouse_wheel() {
  int8 wheel;
 
  if (mouse_status(MREPORT_UPDATED)) {
    if (wheel=mouse_status(MOUSE_WHEEL)) {
      if (wheel==-1) combo_run(cMWheelBack);
    }
}}


So I need that when MBUTON_5 pressed, combo_run, and in that combo the combinations BUTTON_15 and then BUTTON_17 happen. For some reason the combo doesn't run when I press MBUTTON_5, so I'd like to better understand what could be going on.
Like mouse_whel, the side buttons are not configured in the input translator because I need them free to run the combo.

Input Translator:Image


For some reason my script code is not working with MBUTTON_5 or MBUTTON_4 to activate combos. They only work in the game when I set them up in the input translator for some function.
User avatar
Mimis
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Tue Dec 01, 2020 10:26 pm

Re: Script side mouse button

Postby Mad » Sat Nov 06, 2021 10:18 pm

Does anything print in the output panel when you press the side buttons?
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
main {
    if (mouse_status(MBUTTON_4) || mouse_status(MBUTTON_5)) {
        combo_run(Toggle);
        combo_run(pAR);
    }
    mouse_wheel();
}
 
combo Toggle {
    printf("Toggle combo running");
    wait(0);
    set_val(BUTTON_15,100);
    wait(30);
    wait(30);}
 
combo pAR {
    printf("pAR combo running");
    wait(0);
    set_val(BUTTON_7,100);
    wait(30);
    wait(30);
    set_val(BUTTON_7, 0);
}
combo cMWheelBack {
    set_val(BUTTON_13,100);   
    wait(30);
    wait(30);
    set_val(BUTTON_8,100);
    wait(30);
    wait(30);
    set_val(BUTTON_15,100);
    wait(30);
    wait(30);
}
 
void mouse_wheel() {
    int8 wheel;
 
    if (mouse_status(MREPORT_UPDATED)) {
        if (wheel=mouse_status(MOUSE_WHEEL)) {
            if (wheel==-1) combo_run(cMWheelBack);
        }
    }
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Script side mouse button

Postby Mimis » Wed Nov 10, 2021 5:52 pm

Mad wrote:Does anything print in the output panel when you press the side buttons?
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
main {
    if (mouse_status(MBUTTON_4) || mouse_status(MBUTTON_5)) {
        combo_run(Toggle);
        combo_run(pAR);
    }
    mouse_wheel();
}
 
combo Toggle {
    printf("Toggle combo running");
    wait(0);
    set_val(BUTTON_15,100);
    wait(30);
    wait(30);}
 
combo pAR {
    printf("pAR combo running");
    wait(0);
    set_val(BUTTON_7,100);
    wait(30);
    wait(30);
    set_val(BUTTON_7, 0);
}
combo cMWheelBack {
    set_val(BUTTON_13,100);   
    wait(30);
    wait(30);
    set_val(BUTTON_8,100);
    wait(30);
    wait(30);
    set_val(BUTTON_15,100);
    wait(30);
    wait(30);
}
 
void mouse_wheel() {
    int8 wheel;
 
    if (mouse_status(MREPORT_UPDATED)) {
        if (wheel=mouse_status(MOUSE_WHEEL)) {
            if (wheel==-1) combo_run(cMWheelBack);
        }
    }
}


Hello mad. Thanks for the quick reply and yes, the message appears on the panel, I was trying to understand what was wrong with the script and I found out, the problem is in the other part that I didn't post here. I'm trying to script Fortnite so that I can use the build function without having to manually go into build mode, so the side mouse buttons would serve to make it work.

My two unsuccessful attempts:
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
int mode;  // "buid mode identifier."
 main {
    if (mode > 1) { mode = 0;}  //IF mode =1 build mode on, IF mode=0, build mode off.
    if (mouse_status(MBUTTON_5) && (mode ==0));{   //If mode = 0 and M5 is pressed, script runs Toggle(BUILD BUTTON) and enters build mode, mode=1.
        combo_run (Toggle);
            combo_run (pAR);           
                mode = 1; }
    if (mouse_status(MBUTTON_4) && (mode ==0));{  //If mode = 0 and M4 is pressed, script runs Toggle(BUILD BUTTON) and enters build mode, mode=1.
         combo_run (Toggle);
         combo_run (SuT);
                 mode = 1; }
    if (mouse_status(MBUTTON_5) && (mode ==1));{    //If mode = 1 and M5 is pressed, script understands that the build mode is already activated and performs only the required combo.
         combo_run (pAR); }
    if (mouse_status(MBUTTON_4) && (mode ==1));{   //If mode = 1 and M4 is pressed, script understands that the build mode is already activated and performs only the required combo.
         combo_run (SuT); }
}
combo Toggle {   // Combo to activate build mode.
set_val(BUTTON_15,100);
set_val(BUTTON_15,0);     }
combo pAR {           //build
set_val(BUTTON_7,100);
set_val(BUTTON_7,100);    }
combo SuT {           //build
set_val(BUTTON_4,100);
set_val(BUTTON_4,100);    }
 
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
bool mode =FALSE;    // "buid mode identifier, FALSE = build OFF, TRUE = build ON.
 main {
    if (mouse_status (MBUTTON_5))  { mode=TRUE; combo_run(Toggle); combo_run(pAR); }  //If M5 is pressed, mode=TRUE and script runs Toggle(BUILD BUTTON) and enters build mode.
    else if (mouse_status (MBUTTON_5) && (mode=TRUE)) {combo_run(pAR); } //If mode = TRUE and M5 is pressed, script understands that the build mode is already activated and performs only the required combo.
    if (mouse_status (MBUTTON_4))  { mode=TRUE;combo_run(Toggle); combo_run(SuT); }  //If M4 is pressed, mode=TRUE and script runs Toggle(BUILD BUTTON) and enters build mode.
    else if (mouse_status (MBUTTON_4) && (mode=TRUE)) {combo_run(SuT); } //If mode = TRUE and M4 is pressed, script understands that the build mode is already activated and performs only the required combo.
}
combo Toggle {   // Combo to activate build mode.
set_val(BUTTON_15,100);
set_val(BUTTON_15,0);   }
combo pAR {      //build
set_val(BUTTON_7,100);
set_val(BUTTON_7,100);    }
combo SuT {      //build
set_val(BUTTON_4,100);
set_val(BUTTON_4,100);    }]


The problem is in the other part of the code, I'm doing something wrong because neither of these two options took effect.
User avatar
Mimis
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Tue Dec 01, 2020 10:26 pm

Re: Script side mouse button

Postby Mimis » Fri Nov 12, 2021 6:46 pm

Okay, I managed to find the reason for the problem using the first method. It might seem obvious to many but I was really having a hard time figuring out why the script didn't work.


The wrong:
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
int mode;  // "buid mode identifier."
 main {
    if (mode > 1) { mode = 0;}  //IF mode =1 build mode on, IF mode=0, build mode off.
    if (mouse_status(MBUTTON_5) && (mode ==0));{   //If mode = 0 and M5 is pressed, script runs Toggle(BUILD BUTTON) and enters build mode, mode=1.
        combo_run (Toggle);
            combo_run (pAR);           
                mode = 1; }
    if (mouse_status(MBUTTON_4) && (mode ==0));{  //If mode = 0 and M4 is pressed, script runs Toggle(BUILD BUTTON) and enters build mode, mode=1.
         combo_run (Toggle);
         combo_run (SuT);
                 mode = 1; }
    if (mouse_status(MBUTTON_5) && (mode ==1));{    //If mode = 1 and M5 is pressed, script understands that the build mode is already activated and performs only the required combo.
         combo_run (pAR); }
    if (mouse_status(MBUTTON_4) && (mode ==1));{   //If mode = 1 and M4 is pressed, script understands that the build mode is already activated and performs only the required combo.
         combo_run (SuT); }
}
combo Toggle {   // Combo to activate build mode.
set_val(BUTTON_15,100);
set_val(BUTTON_15,0);     }
combo pAR {           //build
set_val(BUTTON_7,100);
set_val(BUTTON_7,100);    }
combo SuT {           //build
set_val(BUTTON_4,100);
set_val(BUTTON_4,100);    }
 


The correct:
Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
 
int mode; 
 main {
    if (mode > 1) { mode = 0;}
    if ((mouse_status (MBUTTON_5)) && (mode==0))  { mode=1; combo_run(Toggle); combo_run(pAR); }
    else if ((mouse_status (MBUTTON_5)) && (mode==1)) {combo_run(pAR); }
    if ((mouse_status (MBUTTON_4))  && (mode==0))  { mode=1;combo_run(Toggle); combo_run(SuT); } 
    else if ((mouse_status (MBUTTON_4)) && (mode==1)) {combo_run(SuT); }
}
combo Toggle {
    wait(30);
set_val(BUTTON_15,100);
    wait(40);
set_val(BUTTON_15,0);
    wait(10);     }
combo pAR {     
set_val(BUTTON_7,100);
set_val(BUTTON_7,100);    }
combo SuT {       
set_val(BUTTON_4,100);
set_val(BUTTON_4,100);    }


Were missing some parenthesis and an adequate delay for the combo to work properly, small details.

Thanks to Mad for the quick response. :joia:
User avatar
Mimis
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Tue Dec 01, 2020 10:26 pm

Re: Script side mouse button

Postby Mad » Sat Nov 13, 2021 7:10 am

:joia: :joia:
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 143 guests