Lua Player Plus Vita
Documentation of lpp-vita
Controls

Module that handles physical user input systems. More...

Enumerations

enum  DevType {
  UNPAIRED_DEV, VITA_DEV, VIRTUAL_DEV, DS3_DEV,
  DS4_DEV
}
 Device types. More...
 
enum  Ctrl {
  SCE_CTRL_UP, SCE_CTRL_DOWN, SCE_CTRL_LEFT, SCE_CTRL_RIGHT,
  SCE_CTRL_CROSS, SCE_CTRL_CIRCLE, SCE_CTRL_SQUARE, SCE_CTRL_TRIANGLE,
  SCE_CTRL_LTRIGGER, SCE_CTRL_RTRIGGER, SCE_CTRL_START, SCE_CTRL_SELECT,
  SCE_CTRL_POWER, SCE_CTRL_VOLUP, SCE_CTRL_VOLDOWN, SCE_CTRL_PSBUTTON
}
 Available controls value. More...
 

Functions

int Controls::read (int port)
 Read pressed buttons. More...
 
int[] Controls::readLeftAnalog (int port)
 Read left analog state. More...
 
int[] Controls::readRightAnalog (int port)
 Read right analog state. More...
 
int[] Controls::readTouch (void)
 Read touchscreen state. More...
 
int[] Controls::readRetroTouch (void)
 Read rearpad state. More...
 
bool Controls::check (int bitmask, Ctrl value)
 Check if a button is pressed. More...
 
void Controls::rumble (int port, int small, int large)
 Changes vibration intensity for Dualshock devices. More...
 
void Controls::setLightbar (int port, int color)
 Set lightbar color for Dualshock 4 devices. More...
 
void Controls::lockHomeButton (void)
 Locks default PS button functionality. More...
 
void Controls::unlockHomeButton (void)
 Unlocks default PS button functionality. More...
 
table Controls::getDeviceInfo (void)
 Get info about controllers. More...
 
bool Controls::headsetStatus (void)
 Check if an headset is plugged in. More...
 
Ctrl Controls::getEnterButton (void)
 Return set controller enter button. More...
 
void Controls::enableGyro (void)
 Enable gyroscope sensor. More...
 
void Controls::enableAccel (void)
 Enable accelerometer sensor. More...
 
void Controls::disableGyro (void)
 Disable gyroscope sensor. More...
 
void Controls::disableAccel (void)
 Disable accelerometer sensor. More...
 
number[] Controls::readGyro (void)
 Read gyroscope state. More...
 
number[] Controls::readAccel (void)
 Read accelerometer state. More...
 

Detailed Description

Module that handles physical user input systems.

Enumeration Type Documentation

◆ DevType

enum DevType

Device types.

Possible results of Controls.getDeviceInfo.

Enumerator
UNPAIRED_DEV 

Unpaired device.

VITA_DEV 

PSVITA controller device.

VIRTUAL_DEV 

Virtual controller device.

DS3_DEV 

Dualshock 3 device.

DS4_DEV 

Dualshock 4 device.

◆ Ctrl

enum Ctrl

Available controls value.

Note
SCE_CTRL_VOLUP, SCE_CTRL_VOLDOWN and SCE_CTRL_POWER can be intercepted only with unsafe mode.
Enumerator
SCE_CTRL_UP 

Digital Up button.

SCE_CTRL_DOWN 

Digital Down button.

SCE_CTRL_LEFT 

Digital Left button.

SCE_CTRL_RIGHT 

Digital Right button.

SCE_CTRL_CROSS 

Cross button.

SCE_CTRL_CIRCLE 

Circle button.

SCE_CTRL_SQUARE 

Square button.

SCE_CTRL_TRIANGLE 

Triangle button.

SCE_CTRL_LTRIGGER 

L Trigger button.

SCE_CTRL_RTRIGGER 

R Trigger button.

SCE_CTRL_START 

Start button.

SCE_CTRL_SELECT 

Select button.

SCE_CTRL_POWER 

Power button.

SCE_CTRL_VOLUP 

Volume Up button.

SCE_CTRL_VOLDOWN 

Volume Down button.

SCE_CTRL_PSBUTTON 

PS button.

Function Documentation

◆ read()

int Controls::read ( int  port)

Read pressed buttons.

Usage example:
pad = Controls.read()
Parameters
port- Device port to use (optional).
Returns
Bitmask of the pressed buttons.

◆ readLeftAnalog()

int [] Controls::readLeftAnalog ( int  port)

Read left analog state.

Usage example:
Parameters
port- Device port to use (optional).
Returns
X and Y values of left analog.

◆ readRightAnalog()

int [] Controls::readRightAnalog ( int  port)

Read right analog state.

Usage example:
Parameters
port- Device port to use (optional).
Returns
X and Y values of right analog.

◆ readTouch()

int [] Controls::readTouch ( void  )

Read touchscreen state.

Usage example:
x1, y1, x2, y2 = Controls.readTouch()
Returns
Several sets of X and Y coordinates for every touch report.
Note
A maximum of 6 different touch reports can be detected.

◆ readRetroTouch()

int [] Controls::readRetroTouch ( void  )

Read rearpad state.

Usage example:
x1, y1, x2, y2 = Controls.readRetroTouch()
Returns
Several sets of X and Y coordinates for every touch report.
Note
A maximum of 4 different touch reports can be detected.

◆ check()

bool Controls::check ( int  bitmask,
Ctrl  value 
)

Check if a button is pressed.

Usage example:
pad = Controls.read()
pressed = true
end
Parameters
bitmask- A controls bitmask returned by Controls.read.
value- A control value to check.
Returns
true if pressed, false otherwise.

◆ rumble()

void Controls::rumble ( int  port,
int  small,
int  large 
)

Changes vibration intensity for Dualshock devices.

Usage example:
Controls.rumble(0, 100, 100)
Parameters
port- Device port to use.
small- Intensity for small sensor.
large- Intensity for large sensor.

◆ setLightbar()

void Controls::setLightbar ( int  port,
int  color 
)

Set lightbar color for Dualshock 4 devices.

Usage example:
Controls.setLightbar(0, Color.new(255, 255, 255))
Parameters
port- Device port to use.
color- An RGBA color value (See Color).

◆ lockHomeButton()

void Controls::lockHomeButton ( void  )

Locks default PS button functionality.

Usage example:

◆ unlockHomeButton()

void Controls::unlockHomeButton ( void  )

Unlocks default PS button functionality.

Usage example:

◆ getDeviceInfo()

table Controls::getDeviceInfo ( void  )

Get info about controllers.

Usage example:
ctrl_type = ctrl[1].type
Returns
A table showing info about the 5 available controllers (See the example above).

◆ headsetStatus()

bool Controls::headsetStatus ( void  )

Check if an headset is plugged in.

Usage example:
headset = true
end
Returns
true if plugged in, false otherwise.
Note
This function is available only in unsafe mode.

◆ getEnterButton()

Ctrl Controls::getEnterButton ( void  )

Return set controller enter button.

Usage example:
pad = Controls.read()
SCE_CTRL_CONFIRM = Controls.getEnterButton()
if Controls.check(pad, SCE_CTRL_CONFIRM) then
accepted = yes
end
Returns
SCE_CTRL_CROSS or SCE_CTRL_CIRCLE.

◆ enableGyro()

void Controls::enableGyro ( void  )

Enable gyroscope sensor.

Usage example:

◆ enableAccel()

void Controls::enableAccel ( void  )

Enable accelerometer sensor.

Usage example:

◆ disableGyro()

void Controls::disableGyro ( void  )

Disable gyroscope sensor.

Usage example:

◆ disableAccel()

void Controls::disableAccel ( void  )

Disable accelerometer sensor.

Usage example:

◆ readGyro()

number [] Controls::readGyro ( void  )

Read gyroscope state.

Usage example:
x, y, z = Controls.readGyro()
Returns
X, Y and Z value of gyroscope state.

◆ readAccel()

number [] Controls::readAccel ( void  )

Read accelerometer state.

Usage example:
x, y, z = Controls.readAccel()
Returns
X, Y and Z value of accelerometer state.
Controls::getDeviceInfo
table getDeviceInfo(void)
Get info about controllers.
SCE_CTRL_CROSS
@ SCE_CTRL_CROSS
Cross button.
Definition: luaControls.cpp:29
Color
Definition: luaColor.cpp:6
Controls::rumble
void rumble(int port, int small, int large)
Changes vibration intensity for Dualshock devices.
Color::new
int new(int r, int g, int b, int a)
Create a new color.
Controls::setLightbar
void setLightbar(int port, int color)
Set lightbar color for Dualshock 4 devices.
Controls::check
bool check(int bitmask, Ctrl value)
Check if a button is pressed.
Controls::readRetroTouch
int[] readRetroTouch(void)
Read rearpad state.
Controls::lockHomeButton
void lockHomeButton(void)
Locks default PS button functionality.
Controls::enableAccel
void enableAccel(void)
Enable accelerometer sensor.
Controls::readAccel
number[] readAccel(void)
Read accelerometer state.
Controls::getEnterButton
Ctrl getEnterButton(void)
Return set controller enter button.
Controls::disableGyro
void disableGyro(void)
Disable gyroscope sensor.
Controls::readGyro
number[] readGyro(void)
Read gyroscope state.
Controls::disableAccel
void disableAccel(void)
Disable accelerometer sensor.
Controls::readTouch
int[] readTouch(void)
Read touchscreen state.
Controls::headsetStatus
bool headsetStatus(void)
Check if an headset is plugged in.
Controls::readRightAnalog
int[] readRightAnalog(int port)
Read right analog state.
Controls::enableGyro
void enableGyro(void)
Enable gyroscope sensor.
Controls::readLeftAnalog
int[] readLeftAnalog(int port)
Read left analog state.
Controls
Definition: luaControls.cpp:43
Controls::read
int read(int port)
Read pressed buttons.