MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
PS2X Class Reference

Class to interface with the MJ2 or PS2 controller. More...

#include <MiniR4PS2X_lib.h>

Public Member Functions

boolean Button (uint16_t)
 Checks if a button is currently pressed.
 
unsigned int ButtonDataByte ()
 Reads the button data byte.
 
boolean NewButtonState ()
 Checks for new button state.
 
boolean NewButtonState (unsigned int)
 Checks for new button state for a specific button.
 
boolean ButtonPressed (unsigned int)
 Checks if a button was just pressed.
 
boolean ButtonReleased (unsigned int)
 Checks if a button was just released.
 
void read_gamepad ()
 Reads the gamepad state.
 
boolean read_gamepad (boolean, byte)
 Reads the gamepad state with options.
 
byte readType ()
 Returns the controller type.
 
byte config_gamepad (uint8_t, uint8_t, uint8_t, uint8_t)
 Configures the gamepad.
 
byte config_gamepad (uint8_t, uint8_t, uint8_t, uint8_t, bool, bool)
 Configures the gamepad with additional options.
 
void enableRumble ()
 Enables rumble functionality on the controller.
 
bool enablePressures ()
 Enables pressure sensitivity on the controller.
 
byte Analog (byte)
 Reads the analog value from the specified analog stick.
 
void reconfig_gamepad ()
 Reconfigures the gamepad.
 

Detailed Description

Class to interface with the MJ2 or PS2 controller.

Once you call MiniR4.begin(), PS2X will auto begin. Note: Please Connect 4p wire to D2 (Left: DAT, Right: CMD, V, G), 2p wire to D3 (Left: CSS/SET, Right: CLK)

This class provides methods to read button states, configure the controller, and handle analog inputs.

Definition at line 180 of file MiniR4PS2X_lib.h.

Member Function Documentation

◆ Analog()

byte PS2X::Analog ( byte button)

Reads the analog value from the specified analog stick.

Parameters
stickThe analog stick identifier.
Returns
The analog value.

Definition at line 62 of file MiniR4PS2X_lib.cpp.

◆ Button()

boolean PS2X::Button ( uint16_t button)

Checks if a button is currently pressed.

Parameters
buttonThe button constant to check.
Returns
true if the button is being pressed, false otherwise.

Definition at line 50 of file MiniR4PS2X_lib.cpp.

◆ ButtonDataByte()

unsigned int PS2X::ButtonDataByte ( )

Reads the button data byte.

Returns
The button data byte.

Definition at line 56 of file MiniR4PS2X_lib.cpp.

◆ ButtonPressed()

boolean PS2X::ButtonPressed ( unsigned int button)

Checks if a button was just pressed.

Parameters
buttonThe button constant to check.
Returns
true if the button was just pressed, false otherwise.

Definition at line 38 of file MiniR4PS2X_lib.cpp.

◆ ButtonReleased()

boolean PS2X::ButtonReleased ( unsigned int button)

Checks if a button was just released.

Parameters
buttonThe button constant to check.
Returns
true if the button was just released, false otherwise.

Definition at line 44 of file MiniR4PS2X_lib.cpp.

◆ config_gamepad() [1/2]

byte PS2X::config_gamepad ( uint8_t clk,
uint8_t cmd,
uint8_t att,
uint8_t dat )

Configures the gamepad.

Parameters
clkPin for clock.
cmdPin for command.
attPin for attention.
datPin for data.
Returns
Status byte.

Definition at line 178 of file MiniR4PS2X_lib.cpp.

◆ config_gamepad() [2/2]

byte PS2X::config_gamepad ( uint8_t clk,
uint8_t cmd,
uint8_t att,
uint8_t dat,
bool pressures,
bool rumble )

Configures the gamepad with additional options.

Parameters
clkPin for clock.
cmdPin for command.
attPin for attention.
datPin for data.
pressuresEnable pressure sensitivity. (MJ2 not avaiable)
rumbleEnable rumble functionality. (MJ2 not avaiable)
Returns
Status byte.

Definition at line 184 of file MiniR4PS2X_lib.cpp.

◆ enablePressures()

bool PS2X::enablePressures ( )

Enables pressure sensitivity on the controller.

Returns
true if pressures are enabled, false otherwise.

Definition at line 360 of file MiniR4PS2X_lib.cpp.

◆ enableRumble()

void PS2X::enableRumble ( )

Enables rumble functionality on the controller.

Definition at line 351 of file MiniR4PS2X_lib.cpp.

◆ NewButtonState() [1/2]

boolean PS2X::NewButtonState ( )

Checks for new button state.

Returns
true if there is a new button state, false otherwise.

Definition at line 26 of file MiniR4PS2X_lib.cpp.

◆ NewButtonState() [2/2]

boolean PS2X::NewButtonState ( unsigned int button)

Checks for new button state for a specific button.

Parameters
buttonThe button constant to check.
Returns
true if the button was just pressed or released, false otherwise.

Definition at line 32 of file MiniR4PS2X_lib.cpp.

◆ read_gamepad() [1/2]

void PS2X::read_gamepad ( )

Reads the gamepad state.

Definition at line 94 of file MiniR4PS2X_lib.cpp.

◆ read_gamepad() [2/2]

boolean PS2X::read_gamepad ( boolean motor1,
byte motor2 )

Reads the gamepad state with options.

Parameters
motor1Motor1.
motor2Motor2.
Returns
true if the read was successful.

Definition at line 100 of file MiniR4PS2X_lib.cpp.

◆ readType()

byte PS2X::readType ( )

Returns the controller type.

Returns
The controller type byte.

Definition at line 308 of file MiniR4PS2X_lib.cpp.

◆ reconfig_gamepad()

void PS2X::reconfig_gamepad ( )

Reconfigures the gamepad.

Definition at line 376 of file MiniR4PS2X_lib.cpp.


The documentation for this class was generated from the following files: