Menu

API Reference

 
      This section describes functions, data structures and operations of Titan One device API.
 
  Device API Functions:
 
gcapi_IsConnected   Check if the device is connected
gcapi_GetFWVer      Get device firmware version
gcapi_Read          Get/Read a updated input report
gcapi_Write         Write the output states
gcapi_GetTimeVal    Get the current time value
gcapi_CalcPressTime Calculates the pressing time of a entry
 
  Device API Data:
 
GCAPI_REPORT        Data structure of the device current state
Identifiers         Identifiers to index the input and output arrays
 

  1. Device Report Type

      The GCAPI_REPORT structure is defined in gcapi.h. This data structure is intended to inform the plugin or the application about the current state of the device input and output ports, about the parameters set by the console (LED, rumble, battery) and, as well as, about the current values of the buttons, sticks and sensors. Check out gcapi_Read function for see an usage example.
 
  Read-only data structure
 
typedef struct {
    uint8_t console;             // Connected console
    uint8_t controller;          // Connected Controller
    uint8_t led[4];              // Four LED
    uint8_t rumble[2];           // Two rumbles
    uint8_t battery_level;       // Battery level
    struct {
        int8_t value;            // Current value
        int8_t prev_value;       // Previous value
        uint32_t press_tv;       // Pressing time
    } input[GCAPI_INPUT_TOTAL];  // Input structure
} GCAPI_REPORT;
 
      console: Device output port state, indicating the output protocol in use and not necessarily the console model in which the device is plugged.
 
  • CONSOLE_DISCONNECTED
  • CONSOLE_PS4
  • CONSOLE_PS3
  • CONSOLE_XB1
  • CONSOLE_XB360
 
      controller: Device input port state. The four highest bits defines the controller connected into the device, and the lower bits defines the controller extension, if applicable.
 
      High Bits
  • CONTROLLER_DISCONNECTED
  • CONTROLLER_PS4
  • CONTROLLER_PS3
  • CONTROLLER_XB1
  • CONTROLLER_XB360
  • CONTROLLER_WII
 
      Low Bits
  • EXTENSION_NUNCHUK
  • EXTENSION_CLASSIC
 
      led: Controller LED state. Each player LED of the controller can be in one of four states: off, on, blinking rapidly or blinking slowly. These states are consistent with what is expected for the PS3. The Titan One does not reproduce all the possible states for XBox 360 system. When using the Dualshock 4 controller the LED states are translated to colors and light intensity of the light bar.
 
  • LED_OFF
  • LED_ON
  • LED_FAST
  • LED_SLOW
 
      rumble: Currently rumble speed, can range from 0% to 100%.
 
      battery_level: Battery level, can range from 0 to 10, where 0 is empty and 10 is full.
 
      value: Current input value - Range: [-100 ~ 100] %.
 
      prev_value: Previous value - Range: [-100 ~ 100] %.
 
      press_time: Time marker for the button press event.
 
      input: Input structure (for controller entries).
 

  2. gcapi_IsConnected

      Check if the device is connected.
 
  Prototype:
 
uint8_t _stdcall gcapi_IsConnected (  )
 
  Parameters:
 
None
 
  Return:
 
1 if the device is connected, 0 if not
 
  Example:
 
if(gcapi_IsConnected()) {
  // OK, we can get data from device
}
 

  3. gcapi_GetFWVer

      Get device firmware version.
 
  Prototype:
 
uint16_t _stdcall gcapi_GetFWVer (  )
 
  Parameters:
 
None
 
  Return:
 
The firmware version. If the device is not connected this function returns 0x0000
 
  Example:
 
if(gcapi_GetFWVer() < 0x0108) {
  // The FW may not be compatible
}
 

  4. gcapi_Read

      Reads the current state of device and of the connected controller and console.
 
  Prototype:
 
uint8_t _stdcall gcapi_Read ( GCAPI_REPORT *report )
 
  Parameters:
 
<GCAPI_REPORT *> : pointer to GCAPI_REPORT data structure
 
  Return:
 
1 for success and 0 for error
 
  Example:
 
GCAPI_REPORT report;
 
if(!gcapi_Read(&report)) {
  // Error
}
 

  5. gcapi_Write

      Writes the output[GCAPI_OUTPUT_TOTAL] states. In other words: send it to console.
 
  Prototype:
 
uint8_t _stdcall gcapi_Write ( int8_t *output )
 
  Parameters:
 
<int8_t *> : pointer to output data structure
 
  Return:
 
1 for success and 0 for error
 
  Example:
 
int8_t output[GCAPI_OUTPUT_TOTAL] = {0};
 
output[PS3_CROSS] = 100;
output[PS3_LX] = -45;
 
if(!gcapi_Write(output)) {
  // Error
}
 

  6. gcapi_GetTimeVal

      Get the current time value.
 
  Prototype:
 
uint32_t _stdcall gcapi_GetTimeVal (  )
 
  Parameters:
 
None
 
  Return:
 
The current time value
 
  Example:
 
GCAPI_REPORT report;
 
gcapi_Read(&report);
 
if(gcapi_GetTimeVal() - report.input[XB360_A].press_tv > 2000) {
  // Button A is being pressed for more than 2 seconds
}
 

  7. gcapi_CalcPressTime

      Calculates the pressing time of a entry.
 
  Prototype:
 
uint32_t _stdcall gcapi_CalcPressTime ( uint32_t press_tv )
 
  Parameters:
 
<uint32_t> : the entry time reference
 
  Return:
 
The amount of time, in milliseconds, that an entry is out of its rest position
 
  Example:
 
GCAPI_REPORT report;
 
gcapi_Read(&report);
 
if(gcapi_CalcPressTime(report.input[PS3_TRIANGLE].press_tv) > 800) {
  // Button TRIANGLE is being pressed for more than 800 milliseconds
}
 

  12. Identifiers

0   PS4_PS        PS3_PS        XB1_XBOX   XB360_XBOX   WII_HOME   WII_HOME
1   PS4_SHARE     PS3_SELECT    XB1_VIEW   XB360_BACK   WII_MINUS  WII_MINUS
2   PS4_OPTIONS   PS3_START     XB1_MENU   XB360_START  WII_PLUS   WII_PLUS
3   PS4_R1        PS3_R1        XB1_RB     XB360_RB                WII_RT
4   PS4_R2        PS3_R2        XB1_RT     XB360_RT                WII_ZR
5   PS4_R3        PS3_R3        XB1_RS     XB360_RS     WII_ONE
6   PS4_L1        PS3_L1        XB1_LB     XB360_LB     WII_C      WII_LT
7   PS4_L2        PS3_L2        XB1_LT     XB360_LT     WII_Z      WII_ZL
8   PS4_L3        PS3_L3        XB1_LS     XB360_LS     WII_TWO
9   PS4_RX        PS3_RX        XB1_RX     XB360_RX                WII_RX
10  PS4_RY        PS3_RY        XB1_RY     XB360_RY                WII_RY
11  PS4_LX        PS3_LX        XB1_LX     XB360_LX     WII_NX     WII_LX
12  PS4_LY        PS3_LY        XB1_LY     XB360_LY     WII_NY     WII_LY
13  PS4_UP        PS3_UP        XB1_UP     XB360_UP     WII_UP     WII_UP
14  PS4_DOWN      PS3_DOWN      XB1_DOWN   XB360_DOWN   WII_DOWN   WII_DOWN
15  PS4_LEFT      PS3_LEFT      XB1_LEFT   XB360_LEFT   WII_LEFT   WII_LEFT
16  PS4_RIGHT     PS3_RIGHT     XB1_RIGHT  XB360_RIGHT  WII_RIGHT  WII_RIGHT
17  PS4_TRIANGLE  PS3_TRIANGLE  XB1_Y      XB360_Y                 WII_X
18  PS4_CIRCLE    PS3_CIRCLE    XB1_B      XB360_B      WII_B      WII_B
19  PS4_CROSS     PS3_CROSS     XB1_A      XB360_A      WII_A      WII_A
20  PS4_SQUARE    PS3_SQUARE    XB1_X      XB360_X                 WII_Y
21  PS4_ACCX      PS3_ACCX                              WII_ACCX
22  PS4_ACCY      PS3_ACCY                              WII_ACCY
23  PS4_ACCZ      PS3_ACCZ                              WII_ACCZ
24  PS4_GYROX     PS3_GYRO
25  PS4_GYROY                                           WII_ACCNX
26  PS4_GYROZ                                           WII_ACCNY
27  PS4_TOUCH                                           WII_ACCNZ
28  PS4_TOUCHX                                          WII_IRX
29  PS4_TOUCHY                                          WII_IRY