Class RemoteMapState

Class Documentation

class RemoteMapState

A class to be used in conjunction with a CommandMapping to be placed in the CommandMapper. A particular RemoteMapState is used to capture a sequence of user inputs that must be triggered for a Command to be scheduled.

To use this class, when possible use one of the constructors provided below to create a mapping. We have the ability to map any combination of remote switches, keyboard keys, or mouse buttons to a particular set of Commands. To cover every possible combination, additional initialize functions have been provided to be used in conjunction with class constructors.

See also

CommandMapper for information about adding a RemoteMapState to the CommandMapper.

Note

What is a “neg key”? I frequently will refer to a negKeySet. This can be thought of a key mapping that when matched, no matter what the state of the RemoteMapState is, the RemoteMapState is no longer satisfied.

Public Types

enum class MouseButton

Use to distinguish between the left and mouse button when initializing a RemoteMapState that uses the mouse as input.

Values:

enumerator LEFT

The left mouse button.

enumerator RIGHT

The right mouse button.

Public Functions

RemoteMapState() = default
RemoteMapState(tap::communication::serial::Remote::SwitchState leftss, tap::communication::serial::Remote::SwitchState rightss, const std::list<tap::communication::serial::Remote::Key> &keySet, const std::list<tap::communication::serial::Remote::Key> &negKeySet, bool mouseButtonLeftPressed, bool mouseButtonRightPressed)

Generic constructor that takes all possible remote map state configurations for maximum configurability, initializes the RemoteMapState with all given information.

Note

keySet and negKeySet must be mutally exclusive sets, otherwise the negKeySet will not be properly initialized.

Parameters:
  • leftss[in] The switch state for the left switch. If UNKNOWN, the switch state will not be initialized.

  • rightss[in] The switch state for the right switch. If UNKNOWN, the switch state will not be initialized.

  • keySet[in] The set of keys to use for initialization.

  • negKeySet[in] The set of keys to be used as negations in the RemoteMapState.

  • mouseButtonLeftPressed[in] Initialize the RemoteMapState to match a remote map state when the left mouse button is pressed.

  • mouseButtonRightPressed[in] Initialize the RemoteMapState to match a remote map state when the right mouse button is pressed.

RemoteMapState(tap::communication::serial::Remote::Switch swh, tap::communication::serial::Remote::SwitchState switchState)

Initializes a RemoteMapState with a single switch to the given switch state.

Parameters:
  • swh[in] The switch to use in the map state.

  • switchState[in] The switch state of the given switch.

RemoteMapState(tap::communication::serial::Remote::SwitchState leftss, tap::communication::serial::Remote::SwitchState rightss)

Initializes a RemoteMapState with particular switch states for both remote switches.

Parameters:
  • leftss[in] The switch state for the left switch.

  • rightss[in] The switch state for the right switch.

RemoteMapState(const std::list<tap::communication::serial::Remote::Key> &keySet, const std::list<tap::communication::serial::Remote::Key> &negKeySet = {})

Initializes a RemoteMapState with a particular set of keys and optionally a particular set of negation keys.

Note

keySet and negKeySet must be mutally exclusive sets, otherwise the negKeySet will not be properly initialized.

Parameters:
  • keySet[in] The set of keys to use for initialization.

  • negKeySet[in] The set of keys to be used as negations in the RemoteMapState.

RemoteMapState(RemoteMapState::MouseButton button, const std::list<tap::communication::serial::Remote::Key> &keySet, const std::list<tap::communication::serial::Remote::Key> &negKeySet = {})

Initializes a RemoteMapState with a particular mouse button and set of keys and optionally a particular set of negation keys.

Note

keySet and negKeySet must be mutally exclusive sets, otherwise the negKeySet will not be properly initialized.

Parameters:
  • button[in] The mouse button The button to use for initialization.

  • keySet[in] The set of keys to use for initialization.

  • negKeySet[in] The set of keys to be used as negations in the RemoteMapState.

RemoteMapState(MouseButton button)

Initializes a RemoteMapState that will use the given mouse button (either left or right) in the mapping.

Parameters:

button[in] The MouseButton to use.

void initLSwitch(tap::communication::serial::Remote::SwitchState ss)

Initializes the left switch with the particular Remote::SwitchState provided.

void initRSwitch(tap::communication::serial::Remote::SwitchState ss)

Initializes the right switch with the particular Remote::SwitchState provided.

void initKeys(uint16_t keys)

Initializes the keys to the bit mapped set of keys provided.

Note

keys must be mutally exclusive with any set of negKeys already provided.

void initNegKeys(uint16_t negKeys)

Initializes the neg keys to the bit mapped set of neg keys provided.

Note

negKeys must be mutally exclusive with any set of keys already provided.

void initKeys(const std::list<tap::communication::serial::Remote::Key> &keySet)

See also

initKeys. Interprets the list and passes that on as a bit mapped set of keys.

void initNegKeys(const std::list<tap::communication::serial::Remote::Key> &negKeySet)

See also

initNegKeys. Interprets the list and passes that on as a bit mapped set of keys.

void initLMouseButton()

Initializes the left mouse button to be mapped when clicked.

void initRMouseButton()

Initializes the right mouse button to be mapped when clicked.

bool stateSubsetOf(const RemoteMapState &other) const

Checks if this is a subset of other. this is a subset of other under the following conditions:

  • Either this’s left switch state is UNKNOWN or this’s left switch state is equal to other’s left switch state.

  • Either this’s right switch state is UNKNOWN or this’s right switch state is equal to other’s left switch state.

  • Either this’s left mouse button is not initialized or both this and other’s left mouse buttons are both initialized.

  • Either this’s right mouse button is not initialized or both this and other’s right mouse buttons are both initialized.

  • this’s key set is a subset of other’s key set, i.e. (this.keySet & other.keySet) == this.keySet.

Attention

This function does not use neg keys to determine if the map state is a subset.

Parameters:

[other] – The RemoteMapState to check if this is a subset of.

Returns:

true if this RemoteMapState is a subset of the other RemoteMapState. See above for description of what it means for a RemoteMapState to be a subset of another.

bool friend operator==(const RemoteMapState &rms1, const RemoteMapState &rms2)

Straight equality.

Parameters:
bool friend operator!=(const RemoteMapState &rms1, const RemoteMapState &rms2)

Opposite of operator==.

inline uint16_t getNegKeys() const
Returns:

The negKeys currently being used.

inline bool getNegKeysUsed() const
Returns:

true if the neg key set has been initialized, false otherwise.

inline uint16_t getKeys() const
Returns:

the current keys initialized in the RemoteMapState.

inline bool getLMouseButton() const
inline bool getRMouseButton() const
inline tap::communication::serial::Remote::SwitchState getLSwitch() const
inline tap::communication::serial::Remote::SwitchState getRSwitch() const