SaturnRingLibrary 0.6
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::Input::Analog Struct Reference

Detailed Description

Generic analog peripheral.

#include <srl_input.hpp>

Inheritance diagram for SRL::Input::Analog:
SRL::Input::Digital SRL::Input::PeripheralGeneric

Public Types

enum  Axis {
  Axis1 = 0 , Axis2 , Axis3 , Axis4 ,
  Axis5 , Axis6
}
 Analog axis. More...
 
enum class  Button : uint16_t {
  Right = 1 << 15 , Left = 1 << 14 , Down = 1 << 13 , Up = 1 << 12 ,
  START = 1 << 11 , A = 1 << 10 , B = 1 << 8 , C = 1 << 9 ,
  X = 1 << 6 , Y = 1 << 5 , Z = 1 << 4 , R = 1 << 7 ,
  L = 1 << 3
}
 Digital gamepad buttons. More...
 

Public Member Functions

 Analog (const uint8_t &port)
 Construct a new analog peripheral handler.
 
virtual uint8_t GetAxis (const Axis axis)
 Get current axis value.
 
PeripheralFamily GetFamily ()
 Gets connected peripheral type family.
 
PeripheralType GetType ()
 Gets connected peripheral type.
 
bool IsConnected () override
 Indicates whether peripheral is connected or not.
 
virtual bool IsHeld (const Button &button)
 Check if user is holding down a button.
 
virtual bool WasPressed (const Button &button)
 Check if user pressed a button.
 
virtual bool WasReleased (const Button &button)
 Check if user released a button.
 

Public Attributes

uint8_t Port = 0
 Port number peripheral is connected to.
 

Protected Member Functions

PerDigital * GetCurrentFrameState ()
 Get state of the peripheral in the current frame.
 
PerDigital * GetPreviousFrameState ()
 Get state of the peripheral in the previous frame.
 

Member Enumeration Documentation

◆ Axis

Analog axis.

Enumerator
Axis1 

First axis.

Axis2 

Second axis.

Axis3 

Third axis.

Axis4 

Fourth axis.

Axis5 

Fifth axis.

Axis6 

Sixth axis.

◆ Button

enum class SRL::Input::Digital::Button : uint16_t
stronginherited

Digital gamepad buttons.

Enumerator
Right 

D-Pad right direction.

Left 

D-Pad left direction.

Down 

D-Pad down direction.

Up 

D-Pad up direction.

START 

Start button.

A button.

B button.

C button.

X button.

Y button.

Z button.

Right trigger.

Left trigger.

Constructor & Destructor Documentation

◆ Analog()

SRL::Input::Analog::Analog ( const uint8_t & port)
inline

Construct a new analog peripheral handler.

Parameters
portAnalog peripheral port

Member Function Documentation

◆ GetAxis()

virtual uint8_t SRL::Input::Analog::GetAxis ( const Axis axis)
inlinevirtual

Get current axis value.

Parameters
axisAnalog axis
Returns
uint8_t value in range of 0 to 256

◆ GetCurrentFrameState()

PerDigital * SRL::Input::PeripheralGeneric::GetCurrentFrameState ( )
inlineprotectedinherited

Get state of the peripheral in the current frame.

Returns
PerDigital* Peripheral data

◆ GetFamily()

PeripheralFamily SRL::Input::PeripheralGeneric::GetFamily ( )
inlineinherited

Gets connected peripheral type family.

Returns
Peripheral type family

◆ GetPreviousFrameState()

PerDigital * SRL::Input::PeripheralGeneric::GetPreviousFrameState ( )
inlineprotectedinherited

Get state of the peripheral in the previous frame.

Returns
PerDigital* Peripheral data

◆ GetType()

PeripheralType SRL::Input::PeripheralGeneric::GetType ( )
inlineinherited

Gets connected peripheral type.

Returns
Peripheral type

◆ IsConnected()

bool SRL::Input::Analog::IsConnected ( )
inlineoverridevirtual

Indicates whether peripheral is connected or not.

Returns
true if connected

Reimplemented from SRL::Input::PeripheralGeneric.

◆ IsHeld()

virtual bool SRL::Input::Digital::IsHeld ( const Button & button)
inlinevirtualinherited

Check if user is holding down a button.

Parameters
buttonButton to check
Returns
true Button was pressed
false Button was not pressed

◆ WasPressed()

virtual bool SRL::Input::Digital::WasPressed ( const Button & button)
inlinevirtualinherited

Check if user pressed a button.

Parameters
buttonButton to check
Returns
true Button was pressed
false Button was not pressed

◆ WasReleased()

virtual bool SRL::Input::Digital::WasReleased ( const Button & button)
inlinevirtualinherited

Check if user released a button.

Parameters
buttonButton to check
Returns
true Button was released
false Button was not released

Member Data Documentation

◆ Port

uint8_t SRL::Input::PeripheralGeneric::Port = 0
inherited

Port number peripheral is connected to.

Note
valid number is 0 to 11, see SRL::Input::MaxPeripherals