The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LXBoxController Class Reference

The XBox 360 controller class. More...

#include <Controller.h>

Public Member Functions

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

Protected Member Functions

const bool ButtonDown (DWORD) const
 Check button state. More...
 

Protected Attributes

XINPUT_STATE m_strState
 Controller's 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 whether buttons have toggled (were up and went down) since the last frame.

Member Function Documentation

◆ ButtonDown()

const bool LXBoxController::ButtonDown ( DWORD  button) const
protected
Parameters
buttonIndex of a button.
Returns
true if that button is down.

◆ GetButtonAToggle()

const bool LXBoxController::GetButtonAToggle ( )

true if button A was toggled.

◆ GetButtonBToggle()

const bool LXBoxController::GetButtonBToggle ( )

true if button B was toggled.

◆ GetButtonLSToggle()

const bool LXBoxController::GetButtonLSToggle ( )

true if left shoulder button was toggled.

◆ GetButtonRSToggle()

const bool LXBoxController::GetButtonRSToggle ( )

true if right shoulder button was toggled.

◆ GetButtonXToggle()

const bool LXBoxController::GetButtonXToggle ( )

true if button X was toggled.

◆ GetButtonYToggle()

const bool LXBoxController::GetButtonYToggle ( )

true if button Y was toggled.

◆ GetDPadDown()

const bool LXBoxController::GetDPadDown ( ) const
Returns
true if digital pad down button is down.

◆ GetDPadLeft()

const bool LXBoxController::GetDPadLeft ( ) const
Returns
true if digital pad left button is down.

◆ GetDPadRight()

const bool LXBoxController::GetDPadRight ( ) const
Returns
true if digital pad right button is down.

◆ GetDPadUp()

const bool LXBoxController::GetDPadUp ( ) const
Returns
true if digital pad up button is down.

◆ GetLThumb()

const Vector2 LXBoxController::GetLThumb ( ) const
Returns
Normalized left thumb stick position.

◆ GetLTrigger()

const float LXBoxController::GetLTrigger ( ) const
Returns
Left trigger position as a float between 0 and 1.

◆ GetRThumb()

const Vector2 LXBoxController::GetRThumb ( ) const
Returns
Normalized right thumb stick position.

◆ GetRTrigger()

const float LXBoxController::GetRTrigger ( ) const
Returns
Right trigger position as a float between 0 and 1.

◆ GetState()

void LXBoxController::GetState ( )

This function should be called once per frame.

◆ IsConnected()

bool LXBoxController::IsConnected ( )
Returns
true if there is a controller connected.

◆ Vibrate()

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

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.