Class RemoteMapState
Defined in File remote_map_state.hpp
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
RemoteMapStateto 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.
-
enumerator LEFT
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
keySetandnegKeySetmust be mutally exclusive sets, otherwise thenegKeySetwill 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
keySetandnegKeySetmust be mutally exclusive sets, otherwise thenegKeySetwill 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
keySetandnegKeySetmust be mutally exclusive sets, otherwise thenegKeySetwill 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::SwitchStateprovided.
-
void initRSwitch(tap::communication::serial::Remote::SwitchState ss)
Initializes the right switch with the particular
Remote::SwitchStateprovided.
-
void initKeys(uint16_t keys)
Initializes the keys to the bit mapped set of keys provided.
Note
keysmust be mutally exclusive with any set ofnegKeysalready provided.
-
void initNegKeys(uint16_t negKeys)
Initializes the neg keys to the bit mapped set of neg keys provided.
Note
negKeysmust be mutally exclusive with any set ofkeysalready 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
thisis a subset ofother.thisis a subset ofotherunder the following conditions:Either
this’s left switch state isUNKNOWNorthis’s left switch state is equal toother’s left switch state.Either
this’s right switch state isUNKNOWNorthis’s right switch state is equal toother’s left switch state.Either
this’s left mouse button is not initialized or boththisandother’s left mouse buttons are both initialized.Either
this’s right mouse button is not initialized or boththisandother’s right mouse buttons are both initialized.this’s key set is a subset ofother’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
thisis a subset of.- Returns:
trueifthisRemoteMapState is a subset of theotherRemoteMapState. See above for description of what it means for aRemoteMapStateto be a subset of another.
-
bool friend operator==(const RemoteMapState &rms1, const RemoteMapState &rms2)
Straight equality.
- Parameters:
rms1 – [in] The first RemoteMapState to check equality for.
rms1 – [in] The second RemoteMapState to check equality for.
-
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:
trueif the neg key set has been initialized,falseotherwise.
-
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
-
enum class MouseButton