Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
Burger::AutoRepeat Class Reference

Autorepeat a joystick. More...

Public Member Functions

 AutoRepeat (uint32_t uButtons, uint32_t uInitialTick, uint32_t uRepeatTick)
 Default constructor.
 
void Init (uint32_t uButtons, uint32_t uInitialTick, uint32_t uRepeatTick)
 Change constants for the class.
 
void Reset (void)
 Reset the timer.
 
uint_t IsItRepeating (uint32_t uButtons)
 Autorepeat a joystick.
 

Private Types

enum  { HELDDOWNBEFORE =1 , SECONDDELAY =2 , WAITFORKEYUP =4 , INITIALIZED =8 }
 

Private Attributes

uint32_t m_uButtons
 Bit field of buttons to test against.
 
uint32_t m_uInitialTick
 Delay for initial joydown in 1/60ths of a second.
 
uint32_t m_uRepeatTick
 Delay for repeater in 1/60ths of a second.
 
uint32_t m_uTimeMark
 Internal time mark.
 
uint_t m_uFlags
 Current state flags.
 

Detailed Description

Autorepeat a joystick.


Sometimes it would be good to simulate an autorepeat feature in a joystick fire button. For each event that can have this feature, create a Burger::AutoRepeat and initialize it with the constructor and you can later change it with Init(). Then call this function with data read from Burger::Joypad::ReadButtons(). If TRUE is returned, then process the joystick button press. This is useful for rapid fire games.

The structure needs to have constants set for the number of ticks to wait before auto firing and the time for the firing rate. These values are in 1/60th of a second and are compared to the call ReadTick(). Finally a bit mask of the joypad fire button bits of interest for this instance

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
HELDDOWNBEFORE 

TRUE if the button(s) were previously held down

SECONDDELAY 

TRUE if secondary delay is active

WAITFORKEYUP 

TRUE if pending a key up due to button down on launch

INITIALIZED 

TRUE if initialized

Constructor & Destructor Documentation

◆ AutoRepeat()

Burger::AutoRepeat::AutoRepeat ( uint32_t uButtons,
uint32_t uInitialTick,
uint32_t uRepeatTick )

Default constructor.


Create the class with the joypad bits of interest, the initial time delay in 1/60ths of a second and the repeat time delay in 1/60s of a second

Parameters
uButtonsBit mask of "buttons" that could be pressed to start rapid firing.
uInitialTickTime in 1/60ths of a second for the initial timer to start rapid firing
uRepeatTickTime in 1/60ths of a second for the rapid firing action

Member Function Documentation

◆ Init()

void Burger::AutoRepeat::Init ( uint32_t uButtons,
uint32_t uInitialTick,
uint32_t uRepeatTick )

Change constants for the class.


Like the constructor, this function will set the class with the joypad bits of interest, the initial time delay in 1/60ths of a second and the repeat time delay in 1/60s of a second.

This will supercede any precious settings

Parameters
uButtonsBit mask of "buttons" that could be pressed to start rapid firing.
uInitialTickTime in 1/60ths of a second for the initial timer to start rapid firing
uRepeatTickTime in 1/60ths of a second for the rapid firing action

◆ IsItRepeating()

uint_t Burger::AutoRepeat::IsItRepeating ( uint32_t uButtons)

Autorepeat a joystick.


Sometimes it would be good to simulate an autorepeat feature in a joystick fire button. For each event that can have this feature, allocate an Burger::AutoRepeat and initialize it with zero. Then call this function with data read from Burger::Joypad::ReadButtons() masked with just the bits for the event. If TRUE is returned, then process the joystick button press. This is useful for rapid fire games.

The structure needs to have these constants set. InitialTick has the number of ticks to wait before auto firing and RepeatTick has the firing rate.

Parameters
uButtonsBit mask for either a single or group of joystick bits to process
Returns
Returns TRUE if the keydown should be processed by the application
See also
Reset(), Init() and Burger::Joypad::ReadButtons()

◆ Reset()

Burger::AutoRepeat::Reset ( void )
inline

Reset the timer.


Reset the class to a "power up" state. Will not allow "firing" until the joypad bits are clear to prevent starting with firing enabled.

Member Data Documentation

◆ m_uButtons

uint32_t Burger::AutoRepeat::m_uButtons
private

Bit field of buttons to test against.

◆ m_uFlags

uint_t Burger::AutoRepeat::m_uFlags
private

Current state flags.

◆ m_uInitialTick

uint32_t Burger::AutoRepeat::m_uInitialTick
private

Delay for initial joydown in 1/60ths of a second.

◆ m_uRepeatTick

uint32_t Burger::AutoRepeat::m_uRepeatTick
private

Delay for repeater in 1/60ths of a second.

◆ m_uTimeMark

uint32_t Burger::AutoRepeat::m_uTimeMark
private

Internal time mark.