Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Joypad Class Reference
Inheritance diagram for Burger::Joypad:
Collaboration diagram for Burger::Joypad:

Classes

struct  JoypadData_t
 Data record for each joypad. More...
 
struct  JoypadRange_t
 Range for each axis to convert analog data to digital data. More...
 

Public Types

enum  {
  AXIS1MIN = 0x1 , AXIS1MAX = 0x2 , AXIS2MIN = 0x4 , AXIS2MAX = 0x8 ,
  AXIS3MIN = 0x10 , AXIS3MAX = 0x20 , AXIS4MIN = 0x40 , AXIS4MAX = 0x80 ,
  POVLEFT = 0x100 , POVRIGHT = 0x200 , POVUP = 0x400 , POVDOWN = 0x800 ,
  BUTTON1 = 0x1000 , BUTTON2 = 0x2000 , BUTTON3 = 0x4000 , BUTTON4 = 0x8000 ,
  BUTTON5 = 0x10000 , BUTTON6 = 0x20000 , BUTTON7 = 0x40000 , BUTTON8 = 0x80000 ,
  BUTTON9 = 0x100000 , BUTTON10 = 0x200000 , BUTTON11 = 0x400000 , BUTTON12 = 0x800000 ,
  BUTTON13 = 0x1000000 , BUTTON14 = 0x2000000 , BUTTON15 = 0x4000000 , BUTTON16 = 0x8000000 ,
  BUTTON17 = 0x10000000 , BUTTON18 = 0x20000000 , BUTTON19 = 0x40000000 , BUTTON20 = 0x80000000
}
 
enum  {
  MAXAXIS = 6 , MAXJOYSTICKS = 8 , MAXBUTTONS = 20 , MAXPOV = 1 ,
  CENTERAXISVALUE = 32768 , MAXAXISVALUE = 65535 , POVANALOGFORWARD = 0 , POVANALOGRIGHT = 9000 ,
  POVANALOGBACKWARD = 18000 , POVANALOGLEFT = 27000 , MAXPOVVALUE = 36000 , INVALIDPOVVALUE = 0xFFFFFFFF ,
  POV_SLOP = 1500
}
 

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 Joypad (GameApp *pAppInstance) noexcept
 Init joystick services.
 
virtual ~Joypad ()
 Shut down joystick services.
 
uint32_t ReadButtons (uint_t uWhich) const noexcept
 Return the game controller button states.
 
uint_t ReadAbsolute (uint_t uWhich, uint_t uAxis) const noexcept
 Read an analog joystick axis.
 
int ReadDelta (uint_t uWhich, uint_t uAxis) const noexcept
 Read an analog joystick axis as delta.
 
uint_t GetAxisCount (uint_t uWhich) const noexcept
 Return the number of analog axises a gamepad possesses.
 
void SetDigital (uint_t uWhich, uint_t uAxis, uint_t uPercent=20) noexcept
 Set the boundaries for the joystick.
 
uint_t GetDeviceCount (void) const noexcept
 
void AcquireDirectInput (void) noexcept
 Acquire DirectInput joystick devices.
 
void UnacquireDirectInput (void) noexcept
 Unacquire DirectInput joystick devices.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Member Functions

static RunQueue::eReturnCode Poll (void *pData) noexcept
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Private Member Functions

 Joypad (const Joypad &)=delete
 
Joypadoperator= (const Joypad &)=delete
 
 Joypad (Joypad &&)=delete
 
Joypadoperator= (Joypad &&)=delete
 

Private Attributes

GameAppm_pAppInstance
 Application instances.
 
XInputGamePad_t m_XInputGamepads [4]
 Structures for each XInput device.
 
uint_t m_bDirectInputFound
 DirectInput devices found.
 
uint_t m_bXInputFound
 XInput devices found.
 
uint_t m_uDirectInputDevices
 Number of devices found from DirectInput, not managed by XInput.
 
JoypadData_t m_Data [MAXJOYSTICKS]
 Current input data from game devices.
 
uint_t m_uDeviceCount
 Number of game controller drivers found.
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
AXIS1MIN 

Joystick Axis 1 minimum motion button.

AXIS1MAX 

Joystick Axis 1 maximum motion button.

AXIS2MIN 

Joystick Axis 2 minimum motion button.

AXIS2MAX 

Joystick Axis 2 maximum motion button.

AXIS3MIN 

Joystick Axis 3 minimum motion button.

AXIS3MAX 

Joystick Axis 3 maximum motion button.

AXIS4MIN 

Joystick Axis 4 minimum motion button.

AXIS4MAX 

Joystick Axis 4 maximum motion button.

POVLEFT 

POV left button.

POVRIGHT 

POV right button.

POVUP 

POV up button.

POVDOWN 

POV down button.

BUTTON1 

1st joystick button

BUTTON2 

2nd joystick button

BUTTON3 

3rd joystick button

BUTTON4 

4th joystick button

BUTTON5 

5th joystick button

BUTTON6 

6th joystick button

BUTTON7 

7th joystick button

BUTTON8 

8th joystick button

BUTTON9 

9th joystick button

BUTTON10 

10th joystick button

BUTTON11 

11th joystick button

BUTTON12 

12th joystick button

BUTTON13 

13th joystick button

BUTTON14 

14th joystick button

BUTTON15 

15th joystick button

BUTTON16 

16th joystick button

BUTTON17 

17th joystick button

BUTTON18 

18th joystick button

BUTTON19 

19th joystick button

BUTTON20 

20th joystick button

◆ anonymous enum

anonymous enum
Enumerator
MAXAXIS 

Maximum number of joystick axises.

MAXJOYSTICKS 

Maximum number of simultaneous joysticks.

MAXBUTTONS 

Maximum number of button controls.

MAXPOV 

Maximum number of POV controllers.

CENTERAXISVALUE 

Axis value when centered.

MAXAXISVALUE 

Maximum Axis value.

POVANALOGFORWARD 

POV Forward value.

POVANALOGRIGHT 

POV Right value.

POVANALOGBACKWARD 

POV Backward value.

POVANALOGLEFT 

POV Left value.

MAXPOVVALUE 

Maximum POV value.

INVALIDPOVVALUE 

Invalid POV value.

POV_SLOP 

Slop value for POV to digital conversion (15 degrees)

Constructor & Destructor Documentation

◆ Joypad() [1/3]

Burger::Joypad::Joypad ( const Joypad & )
privatedelete

◆ Joypad() [2/3]

Burger::Joypad::Joypad ( Joypad && )
privatedelete

◆ Joypad() [3/3]

Burger::Joypad::Joypad ( GameApp * pAppInstance)
noexcept

Init joystick services.


Init the joystick services and detect if a joystick(s) is connected. No joystick manager call will operate properly unless this call is issued. You can call ~Joypad() to shut down the operation at any time.

If you call this function again, the joysticks will be rescanned and your configuration may change. This is due to the fact that users could plug in a joystick at any time.

Note
Win95/98/NT uses the multimedia manager to read the joystick. MacOS uses InputSprocket and MS-DOS and GS/OS uses direct joystick drivers. MS-DOS and GS/OS must be calibrated for accurate results.
See also
~Joypad()

◆ ~Joypad()

Burger::Joypad::~Joypad ( )
virtual

Shut down joystick services.


Stop joystick scanning and release all resources attached to reading the joystick. Useful for manual shutdown and restart of joystick services on Win95 and MacOS

Note
Win95/98/NT uses the multimedia manager to read the joystick. MacOS uses InputSprocket and MS-DOS and GS/OS uses direct joystick drivers. MS-DOS and GS/OS must be calibrated for accurate results.
See also
Joypad(GameApp *)

Member Function Documentation

◆ AcquireDirectInput()

void BURGER_API Burger::Joypad::AcquireDirectInput ( void )
noexcept

Acquire DirectInput joystick devices.


When the application gains focus, call this function to acquire the joysticks

Burgerlib does this call automatically.

Note
This is only available on Windows

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::Joypad::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

◆ GetAxisCount()

uint_t BURGER_API Burger::Joypad::GetAxisCount ( uint_t uWhich) const
noexcept

Return the number of analog axises a gamepad possesses.


Return the number of input axis that return analog data. Zero if none are found or there is no device present

Parameters
uWhichWhich joystick device to affect
See also
ReadAbsolute()

◆ GetDeviceCount()

uint_t Burger::Joypad::GetDeviceCount ( void ) const
inlinenoexcept

◆ operator=() [1/2]

Joypad & Burger::Joypad::operator= ( const Joypad & )
privatedelete

◆ operator=() [2/2]

Joypad & Burger::Joypad::operator= ( Joypad && )
privatedelete

◆ Poll()

Burger::RunQueue::eReturnCode BURGER_API Burger::Joypad::Poll ( void * pData)
staticnoexcept

◆ ReadAbsolute()

uint_t BURGER_API Burger::Joypad::ReadAbsolute ( uint_t uWhich,
uint_t uAxis ) const
noexcept

Read an analog joystick axis.


Get information from the device and axis of a joystick and return the value of the axis at this moment in time. The value returned is 0 to 65535 with 0 being left/up and 65535 being right/down.

Since reading a joystick may be slow, the function Poll() will actually perform the read and keep all the data in a cache so that the subsequent calls will have very little overhead. If you must be certain that data is freshly read, call Poll() before this call to make sure the data is fresh.

Parameters
uAxisAnalog axis for the joystick
uWhichWhich joystick device to read
Note
Win95/98/NT uses the multimedia manager to read the joystick. MacOS uses InputSprocket and MS-DOS and GS/OS uses direct joystick drivers. MS-DOS and GS/OS must be calibrated for accurate results.
See also
ReadDelta(), ReadButtons(), Poll(uint_t)

◆ ReadButtons()

uint32_t BURGER_API Burger::Joypad::ReadButtons ( uint_t uWhich) const
noexcept

Return the game controller button states.


Return the current state of all the input buttons

Returns
32 bit value containing the true/false state of the buttons

◆ ReadDelta()

int BURGER_API Burger::Joypad::ReadDelta ( uint_t uWhich,
uint_t uAxis ) const
noexcept

Read an analog joystick axis as delta.


Get information from the device and axis of a joystick and return the value of the axis at this moment in time. The value returned is -32768 to 32767 with -32768 being left/up and 32767 being right/down.

Since reading a joystick may be slow, the function Poll(uint_t) will actually perform the read and keep all the data in a cache so that the subsequent calls will have very little overhead. If you must be certain that data is freshly read, call Poll(uint_t) before this call to make sure the data is fresh.

Parameters
uAxisAnalog axis for the joystick
uWhichWhich joystick device to read
See also
ReadAbsolute(), ReadButtons(), Poll(uint_t)

◆ SetDigital()

void BURGER_API Burger::Joypad::SetDigital ( uint_t uWhich,
uint_t uAxis,
uint_t uPercent = 20 )
noexcept

Set the boundaries for the joystick.


To simulate a digital joypad with a analog joystick, you need to define a bounds rect that has the dead area for digital motion. Burgerlib has an acceptable default but you can override it with this call.

Parameters
uWhichWhich joystick device to affect
uAxisWhich analog axis to affect
uPercentPercentage from center point for dead zone (20% is normal)
See also
ReadButtons()

◆ UnacquireDirectInput()

void BURGER_API Burger::Joypad::UnacquireDirectInput ( void )
noexcept

Unacquire DirectInput joystick devices.


When the application loses focus, call this function to release the joysticks

Burgerlib does this call automatically.

Note
This is only available on Windows

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::Joypad::g_StaticRTTI
static

◆ m_bDirectInputFound

uint_t Burger::Joypad::m_bDirectInputFound
private

DirectInput devices found.

◆ m_bXInputFound

uint_t Burger::Joypad::m_bXInputFound
private

XInput devices found.

◆ m_Data

JoypadData_t Burger::Joypad::m_Data[MAXJOYSTICKS]
private

Current input data from game devices.

◆ m_pAppInstance

GameApp* Burger::Joypad::m_pAppInstance
private

Application instances.

◆ m_uDeviceCount

uint_t Burger::Joypad::m_uDeviceCount
private

Number of game controller drivers found.

◆ m_uDirectInputDevices

uint_t Burger::Joypad::m_uDirectInputDevices
private

Number of devices found from DirectInput, not managed by XInput.

◆ m_XInputGamepads

XInputGamePad_t Burger::Joypad::m_XInputGamepads[4]
private

Structures for each XInput device.