SaturnRingLibrary 0.9.1
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 () const
 Gets connected peripheral type family.
 
virtual SRL::Math::Types::Vector2D GetPosition () const
 Get the hit position.
 
PeripheralType GetType () const
 Gets connected peripheral type.
 
bool IsConnected () const override
 Indicates whether peripheral is connected or not.
 
virtual bool IsHeld (const Button &button) const
 Check if user is holding down a button.
 
virtual bool WasPressed (const Button &button) const
 Check if user pressed a button.
 
virtual bool WasReleased (const Button &button) const
 Check if user released a button.
 

Static Public Member Functions

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

Public Attributes

uint8_t Port = 0
 Port number peripheral is connected to.
 

Protected Member Functions

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