wavelength 1.0.0
Loading...
Searching...
No Matches
JoypadState Class Reference

State of one controller port as the last poll read it. More...

#include <joypad.h>

Public Member Functions

 JoypadState ()
 Clear the buttons, the sticks, and the pressures, and give the port no pad.
void AddStickButtons (int *pButtons, bool bMenu)
 Set the bits of the stick directions pushed past mThreshold.
const JoypadStick * GetSticks () const
const float * GetPressures () const
void SetStick (int nStick, float fX, float fY)
 Set the position of a stick.
void SetPressure (int nButton, float fPressure)
 Set the pressure of a button.
int GetButtons () const
void SetButtons (int nButtons)
int GetPad () const
void SetPad (int nPad)
int GetConnected () const
void SetConnected (int nConnected)
void SetThreshold (float fThreshold)

Detailed Description

State of one controller port as the last poll read it.

The name is inferred. The poll has a table of kJoypadNumPorts at 0x0047fe00.

Constructor & Destructor Documentation

◆ JoypadState()

JoypadState::JoypadState ( )

Clear the buttons, the sticks, and the pressures, and give the port no pad.

mThreshold is not set.

Ghidra address:
NTSC-U/C: 0x0028a5e8
Ghidra address:
PAL: 0x00293de0

Member Function Documentation

◆ AddStickButtons()

void JoypadState::AddStickButtons ( int * pButtons,
bool bMenu )

Set the bits of the stick directions pushed past mThreshold.

Bits kPadLeftStickUp to kPadRightStickLeft follow the two sticks. With bMenu set, the left stick also sets the bits of the directional buttons.

Parameters
pButtonsThe button word to add the bits to.
bMenuWhether the menus receive this controller's input.
Ghidra address:
NTSC-U/C: 0x0028ab30
Ghidra address:
PAL: 0x00294328

◆ GetSticks()

const JoypadStick * JoypadState::GetSticks ( ) const
inline
Returns
The analogue sticks.

◆ GetPressures()

const float * JoypadState::GetPressures ( ) const
inline
Returns
Each button's pressure, from 0 to 1.

◆ SetStick()

void JoypadState::SetStick ( int nStick,
float fX,
float fY )
inline

Set the position of a stick.

Parameters
nStickThe stick.
fXThe horizontal position, -1 to 1.
fYThe vertical position, -1 to 1.

◆ SetPressure()

void JoypadState::SetPressure ( int nButton,
float fPressure )
inline

Set the pressure of a button.

Parameters
nButtonThe button.
fPressureThe pressure, 0 to 1.

◆ GetButtons()

int JoypadState::GetButtons ( ) const
inline
Returns
The buttons pressed, one bit for each JoypadButton.

◆ SetButtons()

void JoypadState::SetButtons ( int nButtons)
inline
Parameters
nButtonsThe buttons pressed, one bit for each JoypadButton.

◆ GetPad()

int JoypadState::GetPad ( ) const
inline
Returns
The player this port serves, or kJoypadNoPad.

◆ SetPad()

void JoypadState::SetPad ( int nPad)
inline
Parameters
nPadThe player this port serves, or kJoypadNoPad.

◆ GetConnected()

int JoypadState::GetConnected ( ) const
inline
Returns
Non-zero while the controller is connected.

◆ SetConnected()

void JoypadState::SetConnected ( int nConnected)
inline
Parameters
nConnectedNon-zero while the controller is connected.

◆ SetThreshold()

void JoypadState::SetThreshold ( float fThreshold)
inline
Parameters
fThresholdHow far a stick moves before its bit is set.

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