Program Listing for File remote_map_state.hpp
↰ Return to documentation for file (src/tap/control/remote_map_state.hpp
)
/*
* Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
*
* This file is part of Taproot.
*
* Taproot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Taproot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Taproot. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef TAPROOT_REMOTE_MAP_STATE_HPP_
#define TAPROOT_REMOTE_MAP_STATE_HPP_
#include <cstdint>
#include <list>
#include "tap/communication/serial/remote.hpp"
namespace tap
{
namespace control
{
class RemoteMapState
{
public:
enum class MouseButton
{
LEFT,
RIGHT
};
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);
RemoteMapState(
tap::communication::serial::Remote::Switch swh,
tap::communication::serial::Remote::SwitchState switchState);
RemoteMapState(
tap::communication::serial::Remote::SwitchState leftss,
tap::communication::serial::Remote::SwitchState rightss);
RemoteMapState(
const std::list<tap::communication::serial::Remote::Key> &keySet,
const std::list<tap::communication::serial::Remote::Key> &negKeySet = {});
RemoteMapState(
RemoteMapState::MouseButton button,
const std::list<tap::communication::serial::Remote::Key> &keySet,
const std::list<tap::communication::serial::Remote::Key> &negKeySet = {});
RemoteMapState(MouseButton button);
void initLSwitch(tap::communication::serial::Remote::SwitchState ss);
void initRSwitch(tap::communication::serial::Remote::SwitchState ss);
void initKeys(uint16_t keys);
void initNegKeys(uint16_t negKeys);
void initKeys(const std::list<tap::communication::serial::Remote::Key> &keySet);
void initNegKeys(const std::list<tap::communication::serial::Remote::Key> &negKeySet);
void initLMouseButton();
void initRMouseButton();
bool stateSubsetOf(const RemoteMapState &other) const;
bool friend operator==(const RemoteMapState &rms1, const RemoteMapState &rms2);
bool friend operator!=(const RemoteMapState &rms1, const RemoteMapState &rms2);
uint16_t getNegKeys() const { return negKeys; }
bool getNegKeysUsed() const { return negKeys != 0; }
uint16_t getKeys() const { return keys; }
bool getLMouseButton() const { return lMouseButton; }
bool getRMouseButton() const { return rMouseButton; }
tap::communication::serial::Remote::SwitchState getLSwitch() const { return lSwitch; }
tap::communication::serial::Remote::SwitchState getRSwitch() const { return rSwitch; }
private:
tap::communication::serial::Remote::SwitchState lSwitch =
tap::communication::serial::Remote::SwitchState::UNKNOWN;
tap::communication::serial::Remote::SwitchState rSwitch =
tap::communication::serial::Remote::SwitchState::UNKNOWN;
uint16_t keys = 0;
uint16_t negKeys = 0; // if certain keys are pressed, the remote map will not do mapping
bool lMouseButton = false;
bool rMouseButton = false;
}; // class RemoteState
} // namespace control
} // namespace tap
#endif // TAPROOT_REMOTE_MAP_STATE_HPP_