SAGE
A Simple Academic Game Engine
Loading...
Searching...
No Matches
Sage::CController Class Reference

The controller class. More...

#include <SageController.h>

Public Member Functions

void GetState ()
 Get controller's current state.
 
bool IsConnected ()
 Query whether controller is connected.
 
void Vibrate (WORD=0, WORD=0)
 Set left and right rumble.
 
const Vector2 GetRThumb () const
 Get position of right thumb stick.
 
const Vector2 GetLThumb () const
 Get position of left thumb stick.
 
const float GetRTrigger () const
 Get position of right trigger.
 
const float GetLTrigger () const
 Get position of left trigger.
 
const bool GetButtonAToggle ()
 Get button A toggle state.
 
const bool GetButtonBToggle ()
 Get button B toggle state.
 
const bool GetButtonXToggle ()
 Get button X toggle state.
 
const bool GetButtonYToggle ()
 Get button Y toggle state.
 
const bool GetButtonADown ()
 Get button A state.
 
const bool GetButtonBDown ()
 Get button B state.
 
const bool GetButtonXDown ()
 Get button X state.
 
const bool GetButtonYDown ()
 Get button Y state.
 
const bool GetDPadRight () const
 Get digital pad right button state.
 
const bool GetDPadLeft () const
 Get digital pad left button state.
 
const bool GetDPadUp () const
 Get digital pad up button state.
 
const bool GetDPadDown () const
 Get digital pad down button state.
 
const bool GetButtonRSToggle ()
 Get right shoulder button toggle.
 
const bool GetButtonLSToggle ()
 Get left shoulder button toggle.
 

Protected Member Functions

const bool ButtonDown (DWORD) const
 Check button state.
 

Protected Attributes

XINPUT_STATE m_strState
 Current state (polled each frame).
 
bool m_bButtonADown = false
 A button is down.
 
bool m_bButtonBDown = false
 B button is down.
 
bool m_bButtonXDown = false
 X button is down.
 
bool m_bButtonYDown = false
 Y button is down.
 
bool m_bButtonLSDown = false
 Left shoulder button is down.
 
bool m_bButtonRSDown = false
 Right shoulder button is down.
 

Detailed Description

Polled controller class providing access to control states and whether buttons have toggled (were up and went down) since the last frame.

Member Function Documentation

◆ ButtonDown()

const bool CController::ButtonDown ( DWORD button) const
protected

Test whether a button is currently down.

Parameters
buttonIndex of a button.
Returns
true if that button is down.
Here is the caller graph for this function:

◆ GetButtonADown()

const bool CController::GetButtonADown ( )

Test whether button A is down.

Returns
true if button A is down.
Here is the call graph for this function:

◆ GetButtonAToggle()

const bool CController::GetButtonAToggle ( )

Get button A toggle status. Uses m_bButtonADown to store previous button state.

Returns
true if button A was up and is now down.

◆ GetButtonBDown()

const bool CController::GetButtonBDown ( )

Test whether button B is down.

Returns
true if button B is down.
Here is the call graph for this function:

◆ GetButtonBToggle()

const bool CController::GetButtonBToggle ( )

Get button B toggle status. Uses m_bButtonBDown to store previous button state.

Returns
true if button B was up and is now down.

◆ GetButtonLSToggle()

const bool CController::GetButtonLSToggle ( )

Get left shoulder button toggle status. Uses m_bButtonLSDown to store previous button state.

Returns
true if left shoulder button was up and is now down.

◆ GetButtonRSToggle()

const bool CController::GetButtonRSToggle ( )

Get right shoulder button toggle status. Uses m_bButtonRSDown to store previous button state.

Returns
true if right shoulder button was up and is now down.

◆ GetButtonXDown()

const bool CController::GetButtonXDown ( )

Test whether button X is down.

Returns
true if button X is down.
Here is the call graph for this function:

◆ GetButtonXToggle()

const bool CController::GetButtonXToggle ( )

Get button X toggle status. Uses m_bButtonXDown to store previous button state.

Returns
true if button X was up and is now down.

◆ GetButtonYDown()

const bool CController::GetButtonYDown ( )

Test whether button Y is down.

Returns
true if button Y is down.
Here is the call graph for this function:

◆ GetButtonYToggle()

const bool CController::GetButtonYToggle ( )

Get button Y toggle status. Uses m_bButtonYDown to store previous button state.

Returns
true if button Y was up and is now down.

◆ GetDPadDown()

const bool CController::GetDPadDown ( ) const

Test whether the digital pad down button is currently down.

Returns
true if digital pad down button is down.
Here is the call graph for this function:

◆ GetDPadLeft()

const bool CController::GetDPadLeft ( ) const

Test whether the digital pad left button is currently down.

Returns
true if digital pad left button is down.
Here is the call graph for this function:

◆ GetDPadRight()

const bool CController::GetDPadRight ( ) const

Test whether the digital pad right button is currently down.

Returns
true if digital pad right button is down.
Here is the call graph for this function:

◆ GetDPadUp()

const bool CController::GetDPadUp ( ) const

Test whether the digital pad up button is currently down.

Returns
true if digital pad up button is down.
Here is the call graph for this function:

◆ GetLThumb()

const Vector2 CController::GetLThumb ( ) const

Get left thumb stick position.

Returns
Normalized left thumb stick position.
Here is the call graph for this function:

◆ GetLTrigger()

const float CController::GetLTrigger ( ) const

Get left trigger position.

Returns
Left trigger position as a float between 0 and 1.

◆ GetRThumb()

const Vector2 CController::GetRThumb ( ) const

Get right thumb stick position.

Returns
Normalized right thumb stick position.
Here is the call graph for this function:

◆ GetRTrigger()

const float CController::GetRTrigger ( ) const

Get right trigger position.

Returns
Right trigger position as a float between 0 and 1.

◆ GetState()

void CController::GetState ( )

Poll the controller and get its current state into m_strState. This function should be called once per frame.

◆ IsConnected()

bool CController::IsConnected ( )

Test whether there is a controller connected.

Returns
true if there is a controller connected.

◆ Vibrate()

void CController::Vibrate ( WORD leftVal = 0,
WORD rightVal = 0 )

Set controller's left and right vibration level. Note: calling this function with no parameters defaults to all stop.

Parameters
leftValLeft vibrate speed from zero to max unsigned short.
rightValRight vibrate speed from zero to max unsigned short.