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

Detailed Description

Light gun peripheral.

Note
Light gun only works if SRL_FRAMERATE is set to 2 or higher (>30fps)
Light gun can NOT be connected through multi-tap! It must be connected directly to the console. Only valid ports are port 0 and port 6.
Light gun should be calibrated in game, to ensure correct positional data. Calibration should be done by user and result preferably stored to backup memory.

#include <srl_input.hpp>

Inheritance diagram for SRL::Input::Gun:
SRL::Input::PeripheralGeneric

Public Types

enum  Button { Trigger = 1 << 10 , Start = 1 << 11 }
 Pointer device buttons. More...
 
enum  Player { Player1 = 0 , Player2 = 6 }
 Player port. More...
 

Public Member Functions

 Gun (const Player &player)
 Construct a new light gun peripheral handler.
 
PeripheralFamily GetFamily ()
 Gets connected peripheral type family.
 
virtual SRL::Types::Vector2D GetPosition ()
 Get the hit position.
 
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.
 

Internal function

static void Synchronize ()
 Trigger data synchronization.
 
static void VblankRefresh ()
 Refresh light gun trigger and ID data.
 

Member Enumeration Documentation

◆ Button

Pointer device buttons.

Enumerator
Trigger 

Left pointer button.

Start 

Start button.

◆ Player

Player port.

Enumerator
Player1 

First player on port 0.

Player2 

Second player on port 6.

Constructor & Destructor Documentation

◆ Gun()

SRL::Input::Gun::Gun ( const Player & player)
inline

Construct a new light gun peripheral handler.

Note
Light gun can NOT be connected through multi-tap! It must be connected directly to the console.
Parameters
playerLight gun player

Member Function Documentation

◆ 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

◆ GetPosition()

virtual SRL::Types::Vector2D SRL::Input::Gun::GetPosition ( )
inlinevirtual

Get the hit position.

Returns
Vector2D hit position

◆ 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::Gun::IsConnected ( )
inlineoverridevirtual

Indicates whether peripheral is connected or not.

Returns
true if connected

Reimplemented from SRL::Input::PeripheralGeneric.

◆ IsHeld()

virtual bool SRL::Input::Gun::IsHeld ( const Button & button)
inlinevirtual

Check if user is holding down a button.

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

◆ Synchronize()

static void SRL::Input::Gun::Synchronize ( )
inlinestatic

Trigger data synchronization.

This should be called at the beginning of or at the end of each logic frame

Note
Used internally

◆ VblankRefresh()

static void SRL::Input::Gun::VblankRefresh ( )
inlinestatic

Refresh light gun trigger and ID data.

This should be called at the beginning of every v-blank

Note
Used internally

◆ WasPressed()

virtual bool SRL::Input::Gun::WasPressed ( const Button & button)
inlinevirtual

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::Gun::WasReleased ( const Button & button)
inlinevirtual

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