EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
XBoxDigIn.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_XBOX_DIGIN_HPP_
2 #define ORG_EEROS_XBOX_DIGIN_HPP_
3 
4 #include <eeros/hal/Input.hpp>
5 #include <eeros/hal/XBox.hpp>
6 #include <fstream>
7 #include <string>
8 
9 namespace eeros {
10  namespace hal {
11  class XBoxDigIn : public Input<bool> {
12  public:
13  XBoxDigIn(std::string id, XBox* x) : Input<bool>(id, nullptr), x(x) { }
14  ~XBoxDigIn() { }
15  virtual bool get() {
16  if (getId().compare("XBoxButtonA") == 0) return x->current.button_state[XBoxController::Button::A];
17  if (getId().compare("XBoxButtonB") == 0) return x->current.button_state[XBoxController::Button::B];
18  if (getId().compare("XBoxButtonX") == 0) return x->current.button_state[XBoxController::Button::X];
19  if (getId().compare("XBoxButtonY") == 0) return x->current.button_state[XBoxController::Button::Y];
20  if (getId().compare("XBoxButtonLB") == 0) return x->current.button_state[XBoxController::Button::LB];
21  if (getId().compare("XBoxButtonRB") == 0) return x->current.button_state[XBoxController::Button::RB];
22  if (getId().compare("XBoxButtonBack") == 0) return x->current.button_state[XBoxController::Button::back];
23  if (getId().compare("XBoxButtonStart") == 0) return x->current.button_state[XBoxController::Button::start];
24  return false;
25  }
26 
27  private:
28  XBox* x;
29  };
30 
31  };
32 };
33 
34 #endif /* ORG_EEROS_XBOX_DIGIN_HPP_ */
static constexpr int start
Definition: XBox.hpp:43
Definition: XBoxDigIn.hpp:11
static constexpr int LB
Definition: XBox.hpp:40
static constexpr int A
Definition: XBox.hpp:36
static constexpr int back
Definition: XBox.hpp:42
Definition: Input.hpp:17
XBoxState current
Definition: XBox.hpp:57
Definition: Config.hpp:14
static constexpr int Y
Definition: XBox.hpp:39
XBoxDigIn(std::string id, XBox *x)
Definition: XBoxDigIn.hpp:13
bool button_state[XBOX_BUTTON_COUNT]
Definition: XBox.hpp:17
static constexpr int X
Definition: XBox.hpp:38
~XBoxDigIn()
Definition: XBoxDigIn.hpp:14
virtual std::string getId() const
Definition: Input.hpp:21
static constexpr int B
Definition: XBox.hpp:37
static constexpr int RB
Definition: XBox.hpp:41
Definition: XBox.hpp:47