Skip to content

KeyboardAPI ​

cpp
#include <VAmiga.h>
cpp
class KeyboardAPI

Defined in VAmiga.h:1589

API of the keyboard.

Public Methods ​

ReturnNameDescription
const KeyboardConfig &getConfig constReturns the component's current configuration.
const KeyboardInfo &getInfo constReturns the component's current state.
const KeyboardInfo &getCachedInfo constReturns the most recent state snapshot recorded by the emulator thread (see getInfo()).
boolisPressed constChecks if a key is currently pressed.
voidpressPresses a key.
voidtoggleToggles a key.
voidreleaseReleases a key.
voidreleaseAllReleases all currently pressed keys.
boolisLocked constChecks if a key is currently locked.
voidlockLocks a key. A locked key stays down until it is unlocked, even if release() is called on it.
voidunlockUnlocks a previously locked key.
voidabortTypingDeletes all pending keyboard events.

getConfig ​

const

cpp
const KeyboardConfig & getConfig() const

Defined in VAmiga.h:1599

Returns the component's current configuration.


getInfo ​

const

cpp
const KeyboardInfo & getInfo() const

Defined in VAmiga.h:1610

Returns the component's current state.

getInfo() reads the live state on the calling thread. The result is only consistent if the emulator is paused or suspended. getCachedInfo() returns the snapshot the emulator thread has recorded most recently, which is the one to use while the emulator runs. Both return references that can be overwritten by a later call or by the emulator thread, so copy the data if you need to keep it.


getCachedInfo ​

const

cpp
const KeyboardInfo & getCachedInfo() const

Defined in VAmiga.h:1612

Returns the most recent state snapshot recorded by the emulator thread (see getInfo()).


isPressed ​

const

cpp
bool isPressed(KeyCode key) const

Defined in VAmiga.h:1617

Checks if a key is currently pressed.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to check.

press ​

cpp
void press(KeyCode key, double delay = 0.0, double duration = 0.0)

Defined in VAmiga.h:1624

Presses a key.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to press.
delaydoubleAn optional delay in seconds until the key is pressed.
durationdoubleIf specified, the key will be automatically released.

toggle ​

cpp
void toggle(KeyCode key, double delay = 0.0, double duration = 0.0)

Defined in VAmiga.h:1631

Toggles a key.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to toggle.
delaydoubleAn optional delay in seconds until the key is toggled.
durationdoubleIf specified, the key will be toggled again after the additional delay.

release ​

cpp
void release(KeyCode key, double delay = 0.0)

Defined in VAmiga.h:1637

Releases a key.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to release.
delaydoubleAn optional delay in seconds.

releaseAll ​

cpp
void releaseAll(double delay = 0.0)

Defined in VAmiga.h:1642

Releases all currently pressed keys.

Parameters ​

ParameterTypeDescription
delaydoubleAn optional delay in seconds.

isLocked ​

const

cpp
bool isLocked(KeyCode key) const

Defined in VAmiga.h:1647

Checks if a key is currently locked.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to check.

lock ​

cpp
void lock(KeyCode key, double delay = 0.0)

Defined in VAmiga.h:1654

Locks a key. A locked key stays down until it is unlocked, even if release() is called on it.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to lock.
delaydoubleAn optional delay in seconds until the key is locked.

unlock ​

cpp
void unlock(KeyCode key, double delay = 0.0)

Defined in VAmiga.h:1660

Unlocks a previously locked key.

Parameters ​

ParameterTypeDescription
keyKeyCodeThe key to unlock.
delaydoubleAn optional delay in seconds until the key is unlocked.

abortTyping ​

cpp
void abortTyping()

Defined in VAmiga.h:1664

Deletes all pending keyboard events.