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. | |
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
|
private |
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
uButtons | Bit mask of "buttons" that could be pressed to start rapid firing. |
uInitialTick | Time in 1/60ths of a second for the initial timer to start rapid firing |
uRepeatTick | Time in 1/60ths of a second for the rapid firing action |
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
uButtons | Bit mask of "buttons" that could be pressed to start rapid firing. |
uInitialTick | Time in 1/60ths of a second for the initial timer to start rapid firing |
uRepeatTick | Time in 1/60ths of a second for the rapid firing action |
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.
uButtons | Bit mask for either a single or group of joystick bits to process |
|
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.
|
private |
Bit field of buttons to test against.
|
private |
Current state flags.
|
private |
Delay for initial joydown in 1/60ths of a second.
|
private |
Delay for repeater in 1/60ths of a second.
|
private |
Internal time mark.