vitasdk
Documentation of the vitasdk

Detailed Description

Exports for User.


Using this library in your project

Include the header file in your project:

#include <psp2/ctrl.h>


Link the library to the executable:

SceCtrl_stub




Using this library in your project

Include the header file in your project:



Functions

int sceCtrlSetSamplingMode (SceCtrlPadInputMode mode)
 Set the controller mode. More...
 
int sceCtrlSetSamplingModeExt (SceCtrlPadInputMode mode)
 Set the controller extend mode. More...
 
int sceCtrlGetSamplingMode (SceCtrlPadInputMode *pMode)
 Get the current controller mode. More...
 
int sceCtrlPeekBufferPositive (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (polling, positive logic). More...
 
int sceCtrlPeekBufferPositive2 (int port, SceCtrlData *pad_data, int count)
 Get the wireless controller state information (polling, positive logic). More...
 
int sceCtrlPeekBufferPositiveExt (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (polling, positive logic). More...
 
int sceCtrlPeekBufferPositiveExt2 (int port, SceCtrlData *pad_data, int count)
 Get the wireless controller state information (polling, positive logic). More...
 
int sceCtrlPeekBufferNegative (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (polling, negative logic). More...
 
int sceCtrlPeekBufferNegative2 (int port, SceCtrlData *pad_data, int count)
 Get the wireless controller state information (polling, negative logic). More...
 
int sceCtrlReadBufferPositive (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (blocking, positive logic). More...
 
int sceCtrlReadBufferPositive2 (int port, SceCtrlData *pad_data, int count)
 Get the wireless controller state information (blocking, positive logic). More...
 
int sceCtrlReadBufferPositiveExt (int port, SceCtrlData *pad_data, int count)
 Get the controller extended state information (blocking, positive logic). More...
 
int sceCtrlReadBufferPositiveExt2 (int port, SceCtrlData *pad_data, int count)
 Get the wireless controller extended state information (blocking, positive logic). More...
 
int sceCtrlReadBufferNegative (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (blocking, negative logic). More...
 
int sceCtrlReadBufferNegative2 (int port, SceCtrlData *pad_data, int count)
 Get the wireless controller state information (blocking, negative logic). More...
 
int sceCtrlSetRapidFire (int port, int idx, const SceCtrlRapidFireRule *pRule)
 Set rules for button rapid fire. More...
 
int sceCtrlClearRapidFire (int port, int idx)
 Clear rules for button rapid fire. More...
 
int sceCtrlSetActuator (int port, const SceCtrlActuator *pState)
 Control the actuator (vibrate) on paired controllers. More...
 
int sceCtrlSetLightBar (int port, SceUInt8 r, SceUInt8 g, SceUInt8 b)
 Control the light bar on paired controllers. More...
 
int sceCtrlGetControllerPortInfo (SceCtrlPortInfo *info)
 Get controller port information. More...
 
int sceCtrlGetBatteryInfo (int port, SceUInt8 *batt)
 Get controller battery information. More...
 
int sceCtrlSetButtonIntercept (int intercept)
 Sets intercept. More...
 
int sceCtrlGetButtonIntercept (int *intercept)
 Gets intercept. More...
 
int sceCtrlIsMultiControllerSupported (void)
 Check if multi controller is supported. More...
 
 VITASDK_BUILD_ASSERT_EQ (0x20, SceCtrlData)
 
 VITASDK_BUILD_ASSERT_EQ (0x18, SceCtrlRapidFireRule)
 
 VITASDK_BUILD_ASSERT_EQ (8, SceCtrlActuator)
 
 VITASDK_BUILD_ASSERT_EQ (0x10, SceCtrlPortInfo)
 

Data Structure Documentation

◆ SceCtrlData

struct SceCtrlData

Returned controller data.

Data Fields
uint64_t timeStamp The current read frame.
unsigned int buttons Bit mask containing zero or more of SceCtrlButtons.
unsigned char lx Left analogue stick, X axis.
unsigned char ly Left analogue stick, Y axis.
unsigned char rx Right analogue stick, X axis.
unsigned char ry Right analogue stick, Y axis.
uint8_t up Up button.
uint8_t right Right button.
uint8_t down Down button.
uint8_t left Left button.
uint8_t lt Left trigger (L2)
uint8_t rt Right trigger (R2)
uint8_t l1 Left button (L1)
uint8_t r1 Right button (R1)
uint8_t triangle Triangle button.
uint8_t circle Circle button.
uint8_t cross Cross button.
uint8_t square Square button.
uint8_t reserved[4] Reserved.

◆ SceCtrlRapidFireRule

struct SceCtrlRapidFireRule

Structure to pass as argument to sceCtrlSetRapidFire.

Data Fields
unsigned int Mask
unsigned int Trigger
unsigned int Target
unsigned int Delay
unsigned int Make
unsigned int Break

◆ SceCtrlActuator

struct SceCtrlActuator

Structure to pass as argument to sceCtrlSetActuator.

Data Fields
unsigned char small Vibration strength of the small motor.
unsigned char large Vibration strength of the large motor.
uint8_t unk[6] Unknown.

◆ SceCtrlPortInfo

struct SceCtrlPortInfo

Structure to pass as argument to sceCtrlGetControllerPortInfo.

Data Fields
uint8_t port[5] Controller type of each port (See SceCtrlExternalInputMode)
uint8_t unk[11] Unknown.

Enumeration Type Documentation

◆ SceCtrlErrorCode

Enumerator
SCE_CTRL_ERROR_INVALID_ARG 
SCE_CTRL_ERROR_PRIV_REQUIRED 
SCE_CTRL_ERROR_NO_DEVICE 
SCE_CTRL_ERROR_NOT_SUPPORTED 
SCE_CTRL_ERROR_INVALID_MODE 
SCE_CTRL_ERROR_FATAL 

◆ SceCtrlButtons

Enumeration for the digital controller buttons.

Note
- L1/R1/L3/R3 only can bind using sceCtrlPeekBufferPositiveExt2 and sceCtrlReadBufferPositiveExt2
- Values bigger than 0x00010000 can be intercepted only with shell privileges
- Vita's L Trigger and R Trigger are mapped to L1 and R1 when using sceCtrlPeekBufferPositiveExt2 and sceCtrlReadBufferPositiveExt2
Enumerator
SCE_CTRL_SELECT 

Select button.

SCE_CTRL_L3 

L3 button.

SCE_CTRL_R3 

R3 button.

SCE_CTRL_START 

Start button.

SCE_CTRL_UP 

Up D-Pad button.

SCE_CTRL_RIGHT 

Right D-Pad button.

SCE_CTRL_DOWN 

Down D-Pad button.

SCE_CTRL_LEFT 

Left D-Pad button.

SCE_CTRL_LTRIGGER 

Left trigger.

SCE_CTRL_L2 

L2 button.

SCE_CTRL_RTRIGGER 

Right trigger.

SCE_CTRL_R2 

R2 button.

SCE_CTRL_L1 

L1 button.

SCE_CTRL_R1 

R1 button.

SCE_CTRL_TRIANGLE 

Triangle button.

SCE_CTRL_CIRCLE 

Circle button.

SCE_CTRL_CROSS 

Cross button.

SCE_CTRL_SQUARE 

Square button.

SCE_CTRL_INTERCEPTED 

Input not available because intercepted by another application.

SCE_CTRL_PSBUTTON 

Playstation (Home) button.

SCE_CTRL_HEADPHONE 

Headphone plugged in.

SCE_CTRL_VOLUP 

Volume up button.

SCE_CTRL_VOLDOWN 

Volume down button.

SCE_CTRL_POWER 

Power button.

◆ SceCtrlExternalInputMode

Enumeration for the controller types.

Enumerator
SCE_CTRL_TYPE_UNPAIRED 

Unpaired controller.

SCE_CTRL_TYPE_PHY 

Physical controller for VITA.

SCE_CTRL_TYPE_VIRT 

Virtual controller for PSTV.

SCE_CTRL_TYPE_DS3 

DualShock 3.

SCE_CTRL_TYPE_DS4 

DualShock 4.

◆ SceCtrlPadInputMode

Controller mode.

Enumerator
SCE_CTRL_MODE_DIGITAL 

Digital buttons only.

SCE_CTRL_MODE_ANALOG 

Digital buttons + Analog support.

SCE_CTRL_MODE_ANALOG_WIDE 

Same as SCE_CTRL_MODE_ANALOG, but with larger range for analog sticks.

Function Documentation

◆ sceCtrlSetSamplingMode()

int sceCtrlSetSamplingMode ( SceCtrlPadInputMode  mode)

Set the controller mode.

Parameters
[in]mode- One of SceCtrlPadInputMode.
Returns
The previous mode, <0 on error.

◆ sceCtrlSetSamplingModeExt()

int sceCtrlSetSamplingModeExt ( SceCtrlPadInputMode  mode)

Set the controller extend mode.

Parameters
[in]mode- One of SceCtrlPadInputMode.
Returns
The previous mode, <0 on error.

◆ sceCtrlGetSamplingMode()

int sceCtrlGetSamplingMode ( SceCtrlPadInputMode pMode)

Get the current controller mode.

Parameters
[out]pMode- Return value, see SceCtrlPadInputMode.
Returns
The current mode, <0 on error.

◆ sceCtrlPeekBufferPositive()

int sceCtrlPeekBufferPositive ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the controller state information (polling, positive logic).

Parameters
[in]port- use 0.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlPeekBufferPositive2()

int sceCtrlPeekBufferPositive2 ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the wireless controller state information (polling, positive logic).

This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER

Parameters
[in]port- use 0 - 5.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlPeekBufferPositiveExt()

int sceCtrlPeekBufferPositiveExt ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the controller state information (polling, positive logic).

This function will return button presses, even if they're intercepted by common dialog/IME.

Parameters
[in]port- use 0.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlPeekBufferPositiveExt2()

int sceCtrlPeekBufferPositiveExt2 ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the wireless controller state information (polling, positive logic).

This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER This function will return button presses, even if they're intercepted by common dialog/IME.

Parameters
[in]port- use 0 - 5.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlPeekBufferNegative()

int sceCtrlPeekBufferNegative ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the controller state information (polling, negative logic).

Parameters
[in]port- use 0.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlPeekBufferNegative2()

int sceCtrlPeekBufferNegative2 ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the wireless controller state information (polling, negative logic).

This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER

Parameters
[in]port- use 0-5.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlReadBufferPositive()

int sceCtrlReadBufferPositive ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the controller state information (blocking, positive logic).

Parameters
[in]port- use 0.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlReadBufferPositive2()

int sceCtrlReadBufferPositive2 ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the wireless controller state information (blocking, positive logic).

This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER

Parameters
[in]port- use 0-5.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlReadBufferPositiveExt()

int sceCtrlReadBufferPositiveExt ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the controller extended state information (blocking, positive logic).

This function will return button presses, even if they're intercepted by common dialog/IME.

Parameters
[in]port- use 0.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlReadBufferPositiveExt2()

int sceCtrlReadBufferPositiveExt2 ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the wireless controller extended state information (blocking, positive logic).

This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER This function will return button presses, even if they're intercepted by common dialog/IME.

Parameters
[in]port- use 0-5.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlReadBufferNegative()

int sceCtrlReadBufferNegative ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the controller state information (blocking, negative logic).

Parameters
[in]port- use 0.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlReadBufferNegative2()

int sceCtrlReadBufferNegative2 ( int  port,
SceCtrlData pad_data,
int  count 
)

Get the wireless controller state information (blocking, negative logic).

This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER

Parameters
[in]port- use 0-5.
[out]*pad_data- see SceCtrlData.
[in]count- Buffers count. Up to 64 buffers can be requested.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ sceCtrlSetRapidFire()

int sceCtrlSetRapidFire ( int  port,
int  idx,
const SceCtrlRapidFireRule pRule 
)

Set rules for button rapid fire.

Parameters
[in]port- use 0.
[in]idx- rule index between 0-15
[in]pRule- structure SceCtrlRapidFireRule.
Returns
0, <0 on error.

◆ sceCtrlClearRapidFire()

int sceCtrlClearRapidFire ( int  port,
int  idx 
)

Clear rules for button rapid fire.

Parameters
[in]port- use 0.
[in]idx- rule index between 0-15
Returns
0, <0 on error.

◆ sceCtrlSetActuator()

int sceCtrlSetActuator ( int  port,
const SceCtrlActuator pState 
)

Control the actuator (vibrate) on paired controllers.

Parameters
[in]port- use 1 for the first paired controller, etc.
[in]state- see SceCtrlActuator
Returns
0, <0 on error.

◆ sceCtrlSetLightBar()

int sceCtrlSetLightBar ( int  port,
SceUInt8  r,
SceUInt8  g,
SceUInt8  b 
)

Control the light bar on paired controllers.

Parameters
[in]port- use 1 for the first paired controller, etc.
[in]r- red intensity
[in]g- green intensity
[in]b- blue intensity
Returns
0, <0 on error.

◆ sceCtrlGetControllerPortInfo()

int sceCtrlGetControllerPortInfo ( SceCtrlPortInfo info)

Get controller port information.

Parameters
[out]info- see SceCtrlPortInfo
Returns
0, <0 on error

◆ sceCtrlGetBatteryInfo()

int sceCtrlGetBatteryInfo ( int  port,
SceUInt8 batt 
)

Get controller battery information.

Parameters
[in]port- use 1 for the first paired controller, etc.
[out]batt- battery level, between 0-5, 0xEE charging, 0xEF charged
Returns
0, <0 on error.

◆ sceCtrlSetButtonIntercept()

int sceCtrlSetButtonIntercept ( int  intercept)

Sets intercept.

If true, allows the current thread to intercept controls. The use case might be, for example, a game plugin that wishes to capture input without having the input sent to the game thread.

Parameters
[in]interceptBoolean value
Returns
0, < 0 on error

◆ sceCtrlGetButtonIntercept()

int sceCtrlGetButtonIntercept ( int *  intercept)

Gets intercept.

Parameters
[out]interceptBoolean value
Returns
0, < 0 on error

◆ sceCtrlIsMultiControllerSupported()

int sceCtrlIsMultiControllerSupported ( void  )

Check if multi controller is supported.

Returns
1 if yes, 0 if no

◆ VITASDK_BUILD_ASSERT_EQ() [1/4]

VITASDK_BUILD_ASSERT_EQ ( 0x20  ,
SceCtrlData   
)

◆ VITASDK_BUILD_ASSERT_EQ() [2/4]

VITASDK_BUILD_ASSERT_EQ ( 0x18  ,
SceCtrlRapidFireRule   
)

◆ VITASDK_BUILD_ASSERT_EQ() [3/4]

VITASDK_BUILD_ASSERT_EQ ( ,
SceCtrlActuator   
)

◆ VITASDK_BUILD_ASSERT_EQ() [4/4]

VITASDK_BUILD_ASSERT_EQ ( 0x10  ,
SceCtrlPortInfo   
)