Menu

Misc Functions and Constants

 
      Functions that does not fit into others topics.
 
  Related GPC Functions:
 
get_rtime           Returns the elapsed time between iterations
turn_off            Turn off a wireless controller
get_slot            Returns the number of currently loaded slot
check_slot          Check if the specified slot can be loaded
load_slot           Load script from a specified slot (flash memory)
ps4_touchpad        Returns advanced information of the Dualshock 4 touchpad
ps4_set_touchpad    Touches the Dualshock 4 touchpad in a specific (X, Y) position
ps4_authtimeout     Returns the PS4 authentication timeout status
output_protocol     Forces the Titan One to change the output protocol (Output USB)
output_reconnection Forces the Titan One to reconnect on the console (Output USB)
wiir_offscreen      Tests if the IR sensor of Wiimote controller is off screen
get_battery         Returns the battery level of connected controller
get_console         Returns the currently connected console
get_controller      Returns the currently connected controller
get_ctrlbutton      Returns the control button identifier
vm_tctrl            Sets the virtual machine timeout for the next iteration
 
  Special Constants:
 
FALSE:        0
TRUE:         !FALSE
NOT_USE:      0        Used on sensitivity function
ALL_REMAPS:  -1        Used on unmap statement
DZ_CIRCLE:    101      Used on deadzone function
 
PS4T_P1:      Used with ps4_touchpad function
PS4T_P1X:     Used with ps4_touchpad function
PS4T_P1Y:     Used with ps4_touchpad function
PS4T_P2:      Used with ps4_touchpad function
PS4T_P2X:     Used with ps4_touchpad function
PS4T_P2Y:     Used with ps4_touchpad function
 
PIO_PS4:      Returned by get_console and get_controller
PIO_PS3:      Returned by get_console and get_controller
PIO_XB1:      Returned by get_console and get_controller
PIO_XB360:    Returned by get_console and get_controller
PIO_SWITCH:   Returned by get_console and get_controller
PIO_WII:      Returned by get_controller
 

  1. get_rtime

      Returns the elapsed time, in milliseconds, between the current and the previous interaction of the main procedure.
 
  Prototype:
 
int get_rtime (  )
 
  Parameters:
 
None
 
  Return:
 
Elapsed time, in milliseconds
 
  Example:
 
int msecs, secs, mins, hours, days;
 
main {
    msecs = msecs + get_rtime();
    if(msecs >= 1000) {
        msecs = msecs - 1000;
        secs = secs + 1;
        if(secs >= 60) {
            secs = secs - 60;
            mins = mins + 1;
            if(mins >= 60) {
                mins = mins - 60;
                hours = hours + 1;
                if(hours >= 24) {
                    hours = hours - 24;
                    days = days + 1;
                }
            }
        }
    }
    set_val(TRACE_1, secs);
    set_val(TRACE_2, mins);
    set_val(TRACE_3, hours);
    set_val(TRACE_4, days);
}
 

  2. turn_off

      If a wireless controller is in use this command turns it off.
 
  Prototype:
 
turn_off (  )
 
  Parameters:
 
None
 
  Return:
 
None
 
  Example:
 
turn_off();
 

  3. get_slot

      Returns the number of currently loaded slot.
 
  Prototype:
 
int get_slot (  )
 
  Parameters:
 
None
 
  Return:
 
The index number of currently loaded slot. Range: 1~10, where 1 to 9 correspond to device's slots and 10 means the script was loaded by the "Build and Run" command
 
  Example:
 
if(get_slot() != 10) {
    set_pvar(SPVAR_1, 8)
}
 

  4. check_slot

      Check if the specified slot can be loaded.
 
  Prototype:
 
check_slot ( <slot index> )
 
  Parameters:
 
<slot index>  : index of the slot which script should be checked
 
  Return:
 
TRUE if the slot can be loaded, FALSE otherwise
 
  Example:
 
if(check_slot(2)) {
    load_slot(2);
}
 

  5. load_slot

      Ends the execution of current script and loads the script from specified slot.
 
  Prototype:
 
load_slot ( <slot index> )
 
  Parameters:
 
<slot index>  : index of the slot which script should be loaded
 
  Return:
 
None
 
  Example:
 
load_slot(2);
load_slot(0); // this just unload the current script
 

  6. ps4_touchpad

      Returns advanced information of the Dualshock 4 touchpad.
 
  Prototype:
 
int ps4_touchpad ( <info_identifier> )
 
  Parameters:
 
<info_identifier> : a Dualshock 4 touchpad info identifier:
 
PS4T_P1:      Touch point 1 status
PS4T_P1X:     Touch point 1 X value
PS4T_P1Y:     Touch point 1 Y value
 
PS4T_P2:      Touch point 2 status
PS4T_P2X:     Touch point 2 X value
PS4T_P2Y:     Touch point 2 Y value
 
  Return:
 
The value related to the info_identifier supplied
 
  Example:
 
if(ps4_touchpad(PS4T_P1)) {
    set_val(TRACE_1, 100);
    set_val(TRACE_2, ps4_touchpad(PS4T_P1X));
    set_val(TRACE_3, ps4_touchpad(PS4T_P1Y));
} else set_val(TRACE_1, 0);
 
if(ps4_touchpad(PS4T_P2)) {
    set_val(TRACE_4, 100);
    set_val(TRACE_5, ps4_touchpad(PS4T_P2X));
    set_val(TRACE_6, ps4_touchpad(PS4T_P2Y));
} else set_val(TRACE_4, 0);
 

  7. ps4_set_touchpad

      Touches the Dualshock 4 touchpad in a specific (X, Y) position.
 
  Prototype:
 
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.
 
  Return:
 
None
 
  Example:
 
combo Touch_And_Click_DS4Touchpad {
    ps4_set_touchpad(90, 45);
    set_val(PS4_TOUCH, 100);
    wait(80);
}
 

  8. ps4_authtimeout

      Returns the PS4 authentication timeout status.
 
  Prototype:
 
int ps4_authtimeout (  )
 
  Parameters:
 
None
 
  Return:
 
The PS4 authentication timeout status. The timeout status value is a decedent countdown, where 1 is the last readable value before the authentication timeout.
 
  Example:
 
if(ps4_authtimeout() <= 1) {
    output_reconnection();
}
 

  9. output_protocol

      Forces the Titan One to change the output protocol (Output USB)
 
  Prototype:
 
output_protocol ( <Protocol ID> )
 
  Parameters:
 
<Protocol ID> : A valid output protocol ID: PIO_PS4, PIO_PS3, PIO_XB1 or PIO_XB360.
 
  Return:
 
None
 
  Example:
 
init {
    output_protocol(PIO_XB1);
}

  10. output_reconnection

      Forces the Titan One to reconnect on the console (Output USB). Can be used to reset the PS4 authentication timeout.
 
  Prototype:
 
output_reconnection (  )
 
  Parameters:
 
None
 
  Return:
 
None
 
  Example:
 
int last_ps4_auth_timeout;
 
main {
    // Rumble the controller if the PS4 auth timeout gets below 5.
    if(ps4_authtimeout() < 5) {
        if(last_ps4_auth_timeout != ps4_authtimeout()) {
            last_ps4_auth_timeout = ps4_authtimeout();
            combo_restart(AuthRumbleFeedback);
        }
    }
    // Press OPTIONS + PS to force reconnection and reset auth timeout.
    if(get_val(PS4_OPTIONS) && event_press(PS4_PS)) {
        output_reconnection();
    }
}
 
combo AuthRumbleFeedback {
    set_rumble(RUMBLE_A, 100);
    set_rumble(RUMBLE_B, 100);
    wait(200);
    reset_rumble();
}
 

  11. wiir_offscreen

      Tests if the IR sensor of Wiimote controller is off screen.
 
  Prototype:
 
int wiir_offscreen (  )
 
  Parameters:
 
None
 
  Return:
 
TRUE if Wiimote IR is off screen, FALSE otherwise
 
  Example:
 
if(wiir_offscreen()) {
    // Do something
}
 

  12. get_battery

      Returns the battery level of connected controller, if not applicable the returned value is 10 (Fully Charged).
 
  Prototype:
 
int get_battery (  )
 
  Parameters:
 
None
 
  Return:
 
A value between 0 (dead) and 10 (fully charged)
 
  Example:
 
main {
    if(get_battery() < 3) {
        turn_off(); // Turn off controller
    }
}
 

  13. get_console

      Returns the currently connected console type, or 0 if there is no console connected.
 
  Prototype:
 
int get_console (  )
 
  Parameters:
 
None
 
  Return:
 
0, PIO_PS4, PIO_PS3, PIO_XB1 or PIO_XB360
 
  Example:
 
main {
    if(get_console() == PIO_XB360) {
        // Do something
    }
}
 

  14. get_controller

      Returns the currently connected controller type, or 0 if there is no controller connected.
 
  Prototype:
 
int get_controller (  )
 
  Parameters:
 
None
 
  Return:
 
0, PIO_PS4, PIO_PS3, PIO_XB1, PIO_XB360 or PIO_WII
 
  Example:
 
main {
    if(get_controller() == PIO_PS4) {
        // Do something
    }
}
 

  15. get_ctrlbutton

      Returns the control button identifier. The control button is used to switch memory slots and to configure Gamepacks using the controller.
 
  Prototype:
 
int get_ctrlbutton (  )
 
  Parameters:
 
None
 
  Return:
 
The identifier of a controller entry.
 
  Example:
 
int ctrlbtn;
 
init {
    ctrlbtn = get_ctrlbutton();
}
 

  16. vm_tctrl

      Sets the virtual machine timeout for the next iteration.
 
  Prototype:
 
vm_tctrl ( <Value> )
 
  Parameters:
 
<Value> : Numerical value ranging from -9 to 10. The value is added to the base Virtual Machine time (10ms).
 
  Return:
 
None
 
  Example:
 
main {
    // Run the GPC Virtual Machine every 6ms (10 - 4)
    vm_tctrl(-4);
}
(This work is NOT endorsed by, sponsored by, or affiliated with any game publisher or trademark holder. All trademarks are the property of their respective owners. Some game publishers may restrict the use of third-party peripherals; please refer to the applicable game's Terms of Use. Users are responsible for ensuring their compliance with any applicable game rules or restrictions.)