GPC Developer Guides
...
Functions
Controller Functions
Core Controller Functions
function name description get val returns the current value of a controller entry get lval returns the previous value of a controller entry get ptime returns the elapsed time of a controller entries state change get controller returns the type of controller currently connected to the input port get battery returns the current status of the battery for a wireless controller event press returns true when a controller entry has been pressed event release returns true when a controller entry has been released get ival gets the input value of a button to check if it has been modified by the script get brtime gets the time the input value has been 0 swap swaps the input values to be sent to the console temporarily block locks the input from being sent to the console for the specified time sensitivity changes the input sensitivity deadzone modifies the inner "deadzone", and essentially pushes the starting value (when not 0) from the center by deadzone x/deadzone y or radius stickize modifies outer deadzone, essentially forces the stick to not be further out than the radius from the inner point ps4 touchpad returns detailed information on the dualshock 4 touchpad state ps4 set touchpad touches the dualshock 4 touchpad in a specific (x, y) position turn off turns off a wireless controller connected to the input port wiir offscreen returns true if the ir sensor on a wiimote is off screen get adt returns the current value of an adaptive trigger entry set adt sets the value of an adaptive trigger entry adt off turns off an adaptive trigger this will also reset any modifications done using set adt adt cmp compares raw adt data with an array that is used with addr addr returns an offset rather than value get val get val returns the current value of a controller entry in the form of an int this value represents a percentage % gpc supports treating an int as a boolean value this means get val can be used to test whether a controller button, trigger, or stick is being pressed or not for example gpc if(get val(ps4 r1)) this conditional statement¹ would return true if r1/rb has a value other than 0 (zero) it can also be used to check for a specific value or value range² for example gpc if(get val(ps4 r2) > 50) would return true if r2/rt was being pressed more than 50% of its total range since get val returns an int, the returned value can be stored in a variable, like so gpc int myvar; main { myvar = get val(xb1 lt); } 🔴 syntax get val ( \<identifier> ); ⚪ parameters \<identifier> the identifier of a controller entry 🔵 returns the current value of the specified identifier can range from 100 to +100 depending on the entry type variables docid\ vnk j2feeytw ux3wym4r notes info ¹a conditional statement is a set of rules performed if a certain condition is met it is sometimes referred to as an if then statement, because if a condition is met, then an action is performed info ²buttons/bumpers, triggers and sticks each have their own range of returned values buttons/bumpers will return either 0 (not pressed) or 100 (pressed) triggers will return a value range of 0 to 100, depending on whether a trigger is not pressed at all (0) or a percentage of how far the trigger is pulled sticks return a value that represents it’s position along an axis (x/y) as such, the return range of a stick is 100 to 100 get lval get lval is similar to get val with the exception that it returns the value of the specified identifier in the previous iteration (run) of the main loop this value is also returned as an int and represents a percentage % however, get lval gets its data from the input report so, unlike get val, is not affected by any code before it for example, if you were to use the set val command to overwrite the output of an identifier, get lval would still return the previous value of the identifier you can see this in action by running the following command on your cronus zen and pressing the right trigger gpc main { set val(xb1 rt, 0); set val(trace 1, get lval(xb1 rt)); set val(trace 2, get val(xb1 rt)); } 🔴 syntax get lval ( \<identifier> ); ⚪ parameters \<identifier> the identifier of a controller entry 🔵 returns the previous value of the specified identifier can range from 100 to +100 depending on the entry type main section docid\ wcdbh9h0ggmrmgwtiyni3 get ptime get ptime returns the value in milliseconds of an identifiers state change in the form of an int what this means is when an identifiers value changes from false to true or vice versa, the counter for get ptimeon that identifier is reset to 0 therefore the clock is always running for this function so it should be used with another command, such as get val for example, using get ptime in an if statement on its own like the example below would give an undesired result as the statement would be true if the button was pressed or not for greater than 200 milliseconds gpc if (get ptime(xb360 a) > 200) using get ptime in combination with the command get val would modify the statement to only return true if the button had been pressed for longer than 200 milliseconds, as shown below; gpc if (get val(xb360 a) && get ptime(xb360 a) > 200) 🔴 syntax get ptime ( \<identifier> ); ⚪ parameters \<identifier> the identifier of a controller entry 🔵 returns the elapsed time of a controller entry state changes the value returned is in milliseconds with a range of 0 to 32767 get controller get controller returns a value in the form of an int which represents the controller type currently connected to the input port of the cronus to save you from having to remember which value relates to the type of controller, the constants have been created gpc main { if(get controller() == pio xb1) { // if the connected device is an xb1 // controller, this will evaluate to true // and code inside will execute } } 🔴 syntax get controller(); ⚪ parameters none 🔵 returns a value representing which type of controller is currently connected get battery get battery returns the battery level, if applicable, of the connected controller in the form of an int ranging from 0 to 11 with 0 being discharged, 10 being fully charged and 11 being charging if no battery is connected, for example, a wired controller is connected, then it returns 10 gpc main { if(get battery() <= 2) { } } 🔴 syntax get battery(); ⚪ parameters none 🔵 returns a value ranging from 0 (discharged) to 10 (fully charged) or 11 if charging event press event press returns true in the main iteration when a control changes from false to true therefore, even if a button is pressed and held down, event press would only return true at the moment it is pressed and not while the button was held this makes it perfect for combos you only wish to run once when a button is pressed for example, if you were playing a first person shooter, using a sniper rifle and you wanted the cronus to automatically scope when you aimed down your sights you could do this gpc main { if(event press(xb1 lt)){ combo run(scope in); } } combo scope in { wait(400); set val(xb1 ls, 100); wait(200); } 🔴 syntax event press ( \<identifier>); ⚪ parameters \<identifier> the identifier of a controller entry 🔵 returns returns true in the main iteration when a control value changes from false to true main section docid\ wcdbh9h0ggmrmgwtiyni3 event release event release is the opposite of event press, it returns true in the main iteration when a control changes from true to false this makes it ideally suited to run code that you only want to run once when a button is released for example, if you were playing a shooter game and wanted the gun to be automatically reloaded whenever you stopped shooting, you could do this; gpc main { if(event release(xb1 rt)){ combo run(reload); } } combo reload { wait(200); set val(xb1 x, 100); wait(200); } 🔴 syntax event release ( \<identifier> ); ⚪ parameters \<identifier> the identifier of a controller entry get ival get ival gets the input value of a button to check if it has been modified by the script gpc main { if(get ival(xb1 a) && get ptime(xb1 a) < 500){ set val(xb1 up,100); } } get brtime get brtime can be used to simplify double pressing a button like so; gpc main{ if (event press(xb1 a) && get brtime(xb1 a) < 300) { / do something / } } that would only trigger when x b1 a has been released less than 300ms (which would happen for a rapid press, release, press cycle)it's a companion to get ptime which gets the press time it works by checking how long it has been since the last time the button was last pressed (meaning, if used with event release it would result in the timings being off from the point of releasing the button) swap swap does as the name implies, it swaps the values of two controller entries this makes it useful for remapping buttons on the fly for example, if you were playing a shooter game that zooms the scope with a right stick click when you aim down the sights but you wished to move that function to the right bumper button so it does not interfere with your aiming, you could do this gpc main { if(get val(xb1 lt)) { // if lt / l2 is pressed swap(xb1 rs, xb1 rb); // swap rs /r3 and rb / r2 } } with the above code, whenever lt / l2 is pressed, rb / r2 will press the right stick click and vice versa 🔴 syntax swap ( \<identifier1> , \<identifier2> ); ⚪ parameters \<identifier1> the identifier of a controller entry \<identifier2> the identifier of a controller entry block block prevents the forwarding of a controller entry for a set period of time which is set in milliseconds this time can range from 20 to 4000 milliseconds it is extremely useful when you wish to get two uses from a single button for example, if you were playing a platform game and wished for the cronus zen to automatically perform a double jump for you if you held the button down, you could do this gpc main { if(get val(xb1 a)){ // if a / cross is held if(event press(xb1 a)){ // when first pressed combo run(single jump); // run combo single jump } block(xb1 a, 500); // block the forwarding of a / cross from the controller for 500 ms } } combo single jump { set val(xb1 a, 100); wait(300); } the above code will run the combo single jump as soon as the button is pressed if the button is released within 500 milliseconds then there is no further output to the console however, if the button is held for longer than 500 milliseconds then the normal output of that button resumes output with a quick tap of the button output when the button is held; 🔴 syntax block ( \<identifier> , \<milliseconds> ); ⚪ parameters \<identifier> the identifier of a controller entry \<milliseconds> length of time in milliseconds to block forwarding for allowed range 20 4000 sensitivity sensitivity adjusts the sensitivity of an analog controller entry, usually, this is an axis the function takes three parameters, the control to be modified, the midpoint, and the sensitivity multiplier midpoint sets the midpoint value of the controller entry the default value is 50% by changing this value, you are setting two sensitivity ranges with a value lower than 50% a high sensitivity range is created closer to the rest position and a low sensitivity range when far from the rest position a value above 50% creates the opposite effect the sensitivity multiplier is the amount the input value is multiplied by the parameter is passed in percentage so 40 would mean multiply by 0 40, 100 means multiply by 1 00, and 140 means multiply by 1 40 how these translate into the difference between the input into the cronus zen and the output to the console can be seen below with a midpoint of 35% and a sensitivity of 100 using the command sensitivity(xb1 lx, 35, 100); with a midpoint of 70% and a sensitivity of 140 using the command sensitivity(xb1 lx, 70, 140); 🔴 syntax sensitivity ( \<identifier> , \<midpoint> , \<sensitivity> ); ⚪ parameters \<identifier> the identifier of a controller entry \<midpoint> sets the midpoint value \<sensitivity> the ratio of the sensitivity adjustment deadzone deadzone adjusts the values of the output to alter the deadzone of two axis the default deadzone programmed into consoles is 20%, which means a console will ignore any signal from an analog stick that is below 20% the cronuszen can adjust the output signals relative to the input for example, if you wished to remove 10% of the deadzone, the cronuszen will output an additional 10% on both axis with the command gpc deadzone(xb1 lx, xb1 ly , 10, 10); with the above command, a physical movement of 10% on the left stick of either the horizontal or vertical axis would output as 20% an additional 10% is added to the output up until 90% any movement from 90% or greater will output 100%, as shown on the graph below the above code will create a square deadzone, which means 10% will be applied to left stick at all times however, the deadzone function can also be used to create a circular deadzone using the predefined constant, dz cirlce (which equals 101) when you use dz circle (or 101) in the third parameter instead of a value, the forth parameter then sets the radius of the circle instead of the value for the y axis example when using the dz circle constant; gpc deadzone(xb1 lx, xb1 ly , dz circle , 10); 🔴 syntax deadzone ( \<identifier x> , \<identifier y> , \<dzone x> / dz circle , \<dzone y> / \<radius> ); ⚪ parameters \<identifier x> a controller entry which represents an x axis \<identifier y> a controller entry which represents a y axis \<dzone x> / dz circle x axis deadzone value / dz circle constant \<dzone y> / \<radius> y axis deadzone value / the radius value of the circle sticksize stickize transforms the values of a wiimote ir or mouse input to an analog stick it does this by setting the radial output of the translation from their movements to the analogue stick as the ps3 has a square output for its analog sticks, we recommend a value of 129 is used on that console the xbox 360, xbox one, and ps4 all use a radial output so we recommend a value of 113 is used on those consoles 🔴 syntax stickize ( \<identifier x> , \<identifier y> , \<radius> ); ⚪ parameters \<identifier x> a controller entry which represents an x axis \<identifier y> a controller entry which represents a y axis \<radius> the radius value of the circle ps4 touchpad ps4 touchpad returns detailed information on the current state of the touchpad like get val, it returns an int ps4 touchpad can give you information on where two fingers are positioned on the touchpad and their x / y coordinates this is done via six constants; ps4t constant value returns ps4t p1 1 true if at least one finger is on the touchpad, false if none ps4t p1x 2 x axis value of the first finger on the touchpad ps4t p1y 3 y axis value of the first finger on the touchpad ps4t p2 16 true if two fingers are on the touchpad, false if less than two ps4t p2x 32 x axis value of the second finger on the touchpad ps4t p2y 48 y axis value of the second finger on the touchpad to get the value of one of the above constants, simply use it in the ps4 touchpad parameter for example, to read the state of all the constants, you could do this gpc main { if(ps4 touchpad(ps4t p1)) { // if at least one finger is on touchpad set val(trace 1, 1); // set trace 1 to 1 set val(trace 2, ps4 touchpad(ps4t p1x)); // set trace 2 to x coordinate of touchpoint 1 set val(trace 3, ps4 touchpad(ps4t p1y)); // set trace 3 to y coordinate of touchpoint 1 } else { // if no fingers are on the touchpad set val(trace 1, 0); // set trace 1 to 0 } if(ps4 touchpad(ps4t p2)) { // if two fingers is on touchpad set val(trace 4, 1); // set trace 4 to 1 set val(trace 5, ps4 touchpad(ps4t p2x)); // set trace 5 to x coordinate of touchpoint 2 set val(trace 6, ps4 touchpad(ps4t p2y)); // set trace 6 to y coordinate of touchpoint 2 } else { // if less than two fingers on the touchpad set val(trace 4, 0); // set trace 4 to 0 } } 🔴 syntax ps4 touchpad ( \<ps4t constant> ); ⚪ parameters \<ps4t constant> a constant from the table above 🔵 returns an int value related to the ps4t constant used ps4 set touchpad ps4 set touchpad will touch the dualshock 4 touchpad in a specific (x, y) position gpc combo touch and click ds4touchpad { ps4 set touchpad(90, 45); set val(ps4 touch, 100); wait(80); } 🔴 syntax ps4 set touchpad ( \<x value>, \<y value> ) ⚪ parameters \<x value> x position in the dualshock 4 touchpad, ranging from 100 to 100 \<y value> y position in the dualshock 4 touchpad, ranging from 100 to 100 🔵 returns none turn off turn off will switch off a wireless controller connected to the cronuszen input port example of usage gpc main { if(event press(xb1 rs)) { // if rs / r3 is pressed turn off(); // turn off wireless controller } } 🔴 syntax turn off ( ); ⚪ parameters none wiir offscreen wii offscreen checks to see if the wiimote controller is pointing off screen example of usage gpc main { if(wii offscreen()) { // do something } } 🔴 syntax wii offscreen ( ); ⚪ parameters none 🔵 returns true if the wiimote ir is pointing off screen, false if it is not get adt get adt returns the current value of an adaptive trigger entry the raw values can also be viewed in device monitor by clicking toggle ps5 adt on the bottom right of the device monitor window get adt can be used to assign a value to the following ps5 adt mode (can be viewed in device monitor) ps5 adt nr ps5 adt cr ps5 adt sr ps5 adt ef1 ps5 adt ef2 ps5 adt off ps5 adt start (can be viewed in device monitor) ps5 adt force1 (can be viewed in device monitor) ps5 adt force2 (can be viewed in device monitor) ps5 adt strength low (can be viewed in device monitor) ps5 adt strength mid (can be viewed in device monitor) ps5 adt strength high (can be viewed in device monitor) ps5 adt freq (can be viewed in device monitor) as seen above not all entries can be viewed in device monitor although entries that can have a more substantial impact are visible example useage gpc if(get adt(ps5 r2, ps5 adt mode) == 0x26) this conditional statement¹ would return true if r2 has a value of 0x26 this is a common value that r2 has when firing a weapon in most shooters such as mwiii it can also be used to check for a specific value or value range² for example gpc if(get adt(ps5 r2, ps5 adt mode)) would return true if r2 has a value other than 0 (zero) however, it is not recommended to do this when reading ps5 adt mode as you will notice a value of 0x05 will be present if connected to a ps5 console when powered on and most shooters such as mwiii will also report a value of 0x25 when r2 is not being pressed below is an example for mwiii where if r2 is not held trace 1 is set to 1 whereas if r2 is held trace 2 is set to 2 gpc main { 	if(get adt(ps5 r2, ps5 adt mode) == 0x25){ set val(trace 1,1); } 	if(get adt(ps5 r2, ps5 adt mode) == 0x26){ set val(trace 1,2); } } 🔴 syntax get adt ( \<trigger>, \<identifier> ); ⚪ parameters \<trigger> adaptive trigger can be either ps5 l2 or ps5 r2 \<identifier> the identifier of an adaptive trigger 🔵 returns the current value of the specified identifier can range from 0 to +255 depending on the entry type variables docid\ vnk j2feeytw ux3wym4r notes info if is important to note for get adt to function correctly you will need adaptive trigger support enabled in the game being played this option can go by a few different names such as adaptive triggers, full haptics etc set adt set adt can set a value of 0 to 255 to any adaptive trigger identifier covered in get adt values to an adaptive trigger will override the rumble feeling felt from a game an example can be seen below where both triggers have all aspects of the trigger set to 0 this can be useful if you need to read adt data from a game but would like to prevent the adaptive triggers from being psychically felt gpc main { 	set adt(ps5 r2, ps5 adt mode,0x00); 	set adt(ps5 r2, ps5 adt start,0x00); 	set adt(ps5 r2, ps5 adt force1,0x00); 	set adt(ps5 r2, ps5 adt force2,0x00); 	set adt(ps5 r2, ps5 adt strength low,0x00); 	set adt(ps5 r2, ps5 adt strength mid,0x00); 	set adt(ps5 r2, ps5 adt strength high,0x00); 	set adt(ps5 r2, ps5 adt freq,0x00); 	 	 	set adt(ps5 l2, ps5 adt mode,0x00); 	set adt(ps5 l2, ps5 adt start,0x00); 	set adt(ps5 l2, ps5 adt force1,0x00); 	set adt(ps5 l2, ps5 adt force2,0x00); 	set adt(ps5 l2, ps5 adt strength low,0x00); 	set adt(ps5 l2, ps5 adt strength mid,0x00); 	set adt(ps5 l2, ps5 adt strength high,0x00); 	set adt(ps5 l2, ps5 adt freq,0x00); } 🔴 syntax set adt ( \<trigger>, \<identifier> ); ⚪ parameters \<trigger> adaptive trigger can be either ps5 l2 or ps5 r2 \<identifier> the identifier of a controller entry 🔵 sets set the output value an an adaptive triggger adt off adt off can be used to turn off the adaptive triggers this will also reset both triggers to their default state the function can be helpful in clearing the effects done to the adaptive triggers using set adt gpc main{ adt off(); // reset l2 and r2 to their default state }