Skip to content

JoystickAPI ​

cpp
#include <VirtualC64.h>
cpp
class JoystickAPI

Defined in VirtualC64.h:987

Joystick Public API

Public Methods ​

ReturnNameDescription
const JoystickConfig &getConfig constReturns the component's current configuration.
const JoystickInfo &getInfo constReturns the component's current state.
const JoystickInfo &getCachedInfo constReturns the most recent state snapshot recorded by the emulator thread (see getInfo()).
voidtriggerTriggers a joystick action.
voidtriggerSets the complete joystick state.

getConfig ​

const

cpp
const JoystickConfig & getConfig() const

Defined in VirtualC64.h:997

Returns the component's current configuration.


getInfo ​

const

cpp
const JoystickInfo & getInfo() const

Defined in VirtualC64.h:1008

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 JoystickInfo & getCachedInfo() const

Defined in VirtualC64.h:1010

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


trigger ​

cpp
void trigger(GamePadAction event)

Defined in VirtualC64.h:1014

Triggers a joystick action.


trigger ​

cpp
void trigger(const std::array< bool, 5 > & state, const std::array< bool, 5 > & previous)

Defined in VirtualC64.h:1026

Sets the complete joystick state.

The states are ordered up, down, left, right, fire. The directions are applied as given, which is harmless to repeat. The fire button is only forwarded if it differs in 'previous', because pressing it again would toggle autofire. Pass the state that was reported by the previous call.

Parameters ​

ParameterTypeDescription
stateconst std::array< bool, 5 > &The new states of up, down, left, right, and fire.
previousconst std::array< bool, 5 > &The previous states.