Gin
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
GameController Class Reference

Represents a single connected game controller. More...

#include <gin_gamecontroller.h>

Public Types

enum class  Button {
  unknown = 0 , dpadUp , dpadRight , dpadDown ,
  dpadLeft , faceDown , faceRight , faceUp ,
  faceLeft , leftShoulder , rightShoulder , leftTrigger ,
  rightTrigger , select , home , start ,
  leftStick , rightStick , numButtons
}
 
enum class  Axis {
  leftX = 0 , leftY , rightX , rightY ,
  leftTrigger , rightTrigger , numAxes
}
 

Public Member Functions

int getIndex () const noexcept
 Port index (0..maxControllers - 1).
 
const juce::String & getName () const noexcept
 Human-readable product name reported by the platform backend.
 
bool isConnected () const noexcept
 True between a controllerConnected and a controllerDisconnected.
 
bool isButtonDown (Button b) const noexcept
 
float getAxis (Axis a) const noexcept
 Analog axis value.
 

Detailed Description

Represents a single connected game controller.

GameController instances are owned by the GameControllerManager and live for the life of that manager — a disconnect just flips isConnected() to false so pointers held by listeners stay valid until they're reconnected on the same port.

Button and axis layouts are normalised across backends so the same enum value means the same physical control on Xbox, PlayStation, MFi, etc. Face buttons are named by position (faceDown / faceRight / faceUp / faceLeft) rather than letter so the mapping holds regardless of vendor:

Xbox A = PS Cross    = faceDown
Xbox B = PS Circle   = faceRight
Xbox Y = PS Triangle = faceUp
Xbox X = PS Square   = faceLeft

Member Enumeration Documentation

◆ Button

Enumerator
unknown 
dpadUp 
dpadRight 
dpadDown 
dpadLeft 
faceDown 
faceRight 
faceUp 
faceLeft 
leftShoulder 
rightShoulder 
leftTrigger 
rightTrigger 
select 
home 
start 
leftStick 
rightStick 
numButtons 

◆ Axis

Enumerator
leftX 
leftY 
rightX 
rightY 
leftTrigger 
rightTrigger 
numAxes 

Member Function Documentation

◆ getIndex()

int GameController::getIndex ( ) const
noexcept

Port index (0..maxControllers - 1).

Stable across disconnect/reconnect.

◆ getName()

const juce::String & GameController::getName ( ) const
noexcept

Human-readable product name reported by the platform backend.

◆ isConnected()

bool GameController::isConnected ( ) const
noexcept

True between a controllerConnected and a controllerDisconnected.

◆ isButtonDown()

bool GameController::isButtonDown ( Button  b) const
noexcept

◆ getAxis()

float GameController::getAxis ( Axis  a) const
noexcept

Analog axis value.

Sticks: -1..1. Triggers: 0..1.


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