Help with mouse randomiser

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

Help with mouse randomiser

Postby pablosscripts » Fri Dec 09, 2022 12:41 am

Hi all! Haven't posted here in a while, I hope you're all doing well. I'm a bit dusty with all of this, I'm trying to make it so my mouse randomly just moves around on a loop. What am I doing wrong?

Code: Select all
 
#include <mouse.gph>
 
 
// INPUT INITIALIZATION
//
// ----------------------------------------------------------------------------------------------------------------
 
#define mousex MOUSE_X                     
#define mousey MOUSE_Y
 
 
// INIT
//
// ----------------------------------------------------------------------------------------------------------------
 
init {
 
    // AUTO OUTPUT PROTOCOL
    //
    // ----------------------------------------------------------------------------------------------------------------
 
    port_connect(PORT_USB_C, PROTOCOL_HID);
 
    keymapping();
       mousemapping();
}
 
 
// THE MAIN SCRIPT
//
// ----------------------------------------------------------------------------------------------------------------
 
main {
 
    // HID PASSTHROUGH
    //
    // ----------------------------------------------------------------------------------------------------------------
 
    key_passthru();
    mouse_passthru();
 
 
    combo_run(move);
 
}
 
 
// COMBOS
//
// ----------------------------------------------------------------------------------------------------------------
 
combo move {
    mouse_set(mousex, irand(5));
 
    mouse_set(mousey, irand(-5));
    wait(100);
}
 
// FUNCTIONS
//
// ----------------------------------------------------------------------------------------------------------------
 
int irand(int scramble) {
    fix32 fraction = (fix32) scramble * 0.01;
    int vmin = scramble - (int) fraction;
    int vmax = scramble + (int) fraction;
    return(((int)(rand() * (fix32)(vmax + 1 - vmin))) + vmin);
}
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 mouse randomiser

Postby Scachi » Fri Dec 09, 2022 8:00 am

User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help with mouse randomiser

Postby pablosscripts » Mon Dec 12, 2022 9:27 pm

Ok thanks for the info
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: Google [Bot] and 170 guests