vitasdk
Documentation of the vitasdk

Detailed Description

Exports for Kernel


Using this library in your project

Include the header file in your project:

#include <psp2kern/ctrl.h>


Link the library to the executable:

SceCtrlForDriver_stub



Functions

int ksceCtrlSetSamplingMode (int mode)
 Set the controller mode. More...
 
int ksceCtrlGetSamplingMode (int *pMode)
 Get the current controller mode. More...
 
int ksceCtrlPeekBufferPositive (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (polling, positive logic). More...
 
int ksceCtrlPeekBufferNegative (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (polling, negative logic). More...
 
int ksceCtrlReadBufferPositive (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (blocking, positive logic). More...
 
int ksceCtrlReadBufferNegative (int port, SceCtrlData *pad_data, int count)
 Get the controller state information (blocking, negative logic). More...
 
int ksceCtrlSetRapidFire (int port, int idx, const SceCtrlRapidFireRule *pRule)
 Set rules for button rapid fire. More...
 
int ksceCtrlClearRapidFire (int port, int idx)
 Clear rules for button rapid fire. More...
 
int ksceCtrlGetControllerPortInfo (SceCtrlPortInfo *info)
 Get controller port information. More...
 
int ksceCtrlSetButtonIntercept (int intercept)
 Sets intercept. More...
 
int ksceCtrlGetButtonIntercept (int *intercept)
 Gets intercept. More...
 
int ksceCtrlSetButtonEmulation (unsigned int port, unsigned char slot, unsigned int userButtons, unsigned int kernelButtons, unsigned int uiMake)
 Emulate buttons for the digital pad. More...
 
int ksceCtrlSetAnalogEmulation (unsigned int port, unsigned char slot, unsigned char user_lX, unsigned char user_lY, unsigned char user_rX, unsigned char user_rY, unsigned char kernel_lX, unsigned char kernel_lY, unsigned char kernel_rX, unsigned char kernel_rY, unsigned int uiMake)
 Emulate values for the analog pad's X- and Y-axis. More...
 
int ksceCtrlRegisterVirtualControllerDriver (SceCtrlVirtualControllerDriver *driver)
 Register virtual controller driver. More...
 
int ksceCtrlUpdateMaskForNonShell (int clear_mask, int set_mask)
 Update ctrl mask for non shell process. More...
 
int ksceCtrlUpdateMaskForAll (int clear_mask, int set_mask)
 Update ctrl mask for all process. More...
 
int ksceCtrlGetMaskForNonShell (uint32_t *mask)
 Get ctrl mask for non shell process. More...
 
int ksceCtrlGetMaskForAll (uint32_t *mask)
 Get ctrl mask for all process. More...
 

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.

Bit mask containing zero or more of ::CtrlButtons.

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.
uint8_t reserved0[4] Reserved.
unsigned char lt Left trigger (L2)
unsigned char rt Right trigger (R2)
uint8_t reserved1[10] 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)

Controller type of each ports.

uint8_t unk[11] Unknown.

◆ SceCtrlVirtualControllerDriver

struct SceCtrlVirtualControllerDriver

Structure to pass as argument to ksceCtrlRegisterVirtualControllerDriver.

Data Fields

int(* readButtons )(int port, SceCtrlData *pad_data, int count)
 
int(* setActuator )(int port, const SceCtrlActuator *pState)
 
int(* getBatteryInfo )(int port, SceUInt8 *batt)
 
int(* disconnect )(int port)
 
int(* setTurnOffInterval )(int port)
 
int(* getActiveControllerPort )(void)
 
int(* changePortAssign )(int port1, int port2)
 
int(* unk0 )(void)
 
int(* getControllerPortInfo )(SceCtrlPortInfo *info)
 
int(* setLightBar )(int port, SceUInt8 r, SceUInt8 g, SceUInt8 b)
 
int(* resetLightBar )(int port)
 
int(* unk1 )(int port)
 
int(* singleControllerMode )(int port)
 

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 
SCE_CTRL_ERROR_INVALID_ARG 
SCE_CTRL_ERROR_PRIV_REQUIRED 
SCE_CTRL_ERROR_FATAL 

◆ SceCtrlButtons

Enumeration for the digital controller buttons.

Note
- L1/R1/L3/R3 only can bind using ::ksceCtrlReadBufferPositiveExt2
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.

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_RTRIGGER 

Right trigger.

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.

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.

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

◆ ksceCtrlSetSamplingMode()

int ksceCtrlSetSamplingMode ( int  mode)

Set the controller mode.

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

◆ ksceCtrlGetSamplingMode()

int ksceCtrlGetSamplingMode ( int *  pMode)

Get the current controller mode.

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

◆ ksceCtrlPeekBufferPositive()

int ksceCtrlPeekBufferPositive ( 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.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ ksceCtrlPeekBufferNegative()

int ksceCtrlPeekBufferNegative ( 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.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ ksceCtrlReadBufferPositive()

int ksceCtrlReadBufferPositive ( 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.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ ksceCtrlReadBufferNegative()

int ksceCtrlReadBufferNegative ( 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.
Returns
Buffers count, between 1 and 'count'. <0 on error.

◆ ksceCtrlSetRapidFire()

int ksceCtrlSetRapidFire ( 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.

◆ ksceCtrlClearRapidFire()

int ksceCtrlClearRapidFire ( 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.

◆ ksceCtrlGetControllerPortInfo()

int ksceCtrlGetControllerPortInfo ( SceCtrlPortInfo info)

Get controller port information.

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

◆ ksceCtrlSetButtonIntercept()

int ksceCtrlSetButtonIntercept ( 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

◆ ksceCtrlGetButtonIntercept()

int ksceCtrlGetButtonIntercept ( int *  intercept)

Gets intercept.

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

◆ ksceCtrlSetButtonEmulation()

int ksceCtrlSetButtonEmulation ( unsigned int  port,
unsigned char  slot,
unsigned int  userButtons,
unsigned int  kernelButtons,
unsigned int  uiMake 
)

Emulate buttons for the digital pad.

Parameters
portUse 0
slotThe slot used to set the custom values. Between 0 - 3. If multiple slots are used, their settings are combined.
userButtonsEmulated user buttons of SceCtrlButtons. You cannot emulate kernel buttons and the emulated buttons will only be applied for applications running in user mode.
kernelButtonsEmulated buttons of SceCtrlButtons (you can emulate both user and kernel buttons). The emulated buttons will only be applied for applications running in kernel mode.
uiMakeSpecifies the duration of the emulation. Measured in sampling counts.
Returns
0 on success.

◆ ksceCtrlSetAnalogEmulation()

int ksceCtrlSetAnalogEmulation ( unsigned int  port,
unsigned char  slot,
unsigned char  user_lX,
unsigned char  user_lY,
unsigned char  user_rX,
unsigned char  user_rY,
unsigned char  kernel_lX,
unsigned char  kernel_lY,
unsigned char  kernel_rX,
unsigned char  kernel_rY,
unsigned int  uiMake 
)

Emulate values for the analog pad's X- and Y-axis.

Parameters
portUse 0
slotThe slot used to set the custom values. Between 0 - 3. If multiple slots are used, their settings are combined.
user_lXNew emulated value for the left joystick's X-axis (userspace). Between 0 - 0xFF.
user_lYNew emulate value for the left joystick's Y-axis (userspace). Between 0 - 0xFF.
user_rXNew emulated value for the right joystick's X-axis (userspace). Between 0 - 0xFF.
user_rYNew emulate value for the right joystick's Y-axis (userspace). Between 0 - 0xFF.
kernel_lXNew emulated value for the left joystick's X-axis (kernelspace). Between 0 - 0xFF.
kernel_lYNew emulate value for the left joystick's Y-axis (kernelspace). Between 0 - 0xFF.
kernel_rXNew emulated value for the right joystick's X-axis (kernelspace). Between 0 - 0xFF.
kernel_rYNew emulate value for the right joystick's Y-axis (kernelspace). Between 0 - 0xFF.
uiMakeSpecifies the duration of the emulation. Measured in sampling counts.
Returns
0 on success.

◆ ksceCtrlRegisterVirtualControllerDriver()

int ksceCtrlRegisterVirtualControllerDriver ( SceCtrlVirtualControllerDriver driver)

Register virtual controller driver.

This function always overwrites global settings and not exist unregister method.

Parameters
[in]driver- See SceCtrlVirtualControllerDriver
Returns
0 on success. <0 on error

◆ ksceCtrlUpdateMaskForNonShell()

int ksceCtrlUpdateMaskForNonShell ( int  clear_mask,
int  set_mask 
)

Update ctrl mask for non shell process.

Parameters
[in]clear_mask- The SceCtrlButtons type value
[in]set_mask- The SceCtrlButtons type value
Returns
always 0.

note - Some values cannot be clear/set.

◆ ksceCtrlUpdateMaskForAll()

int ksceCtrlUpdateMaskForAll ( int  clear_mask,
int  set_mask 
)

Update ctrl mask for all process.

Parameters
[in]clear_mask- The SceCtrlButtons type value
[in]set_mask- The SceCtrlButtons type value
Returns
always 0.

note - Some values cannot be clear/set.

◆ ksceCtrlGetMaskForNonShell()

int ksceCtrlGetMaskForNonShell ( uint32_t *  mask)

Get ctrl mask for non shell process.

Parameters
[out]mask- The pointer of SceCtrlButtons type value output
Returns
0 on success. < 0 on error.

◆ ksceCtrlGetMaskForAll()

int ksceCtrlGetMaskForAll ( uint32_t *  mask)

Get ctrl mask for all process.

Parameters
[out]mask- The pointer of SceCtrlButtons type value output
Returns
0 on success. < 0 on error.
ctrl.h