EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
Mouse.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_HAL_MOUSE_HPP_
2 #define ORG_EEROS_HAL_MOUSE_HPP_
3 
4 #include <string>
5 #include <functional>
6 #include <linux/input.h>
7 #include <eeros/hal/Input.hpp>
8 #include <eeros/core/Thread.hpp>
9 
10 #define MOUSE_BUTTON_COUNT (16)
11 #define MOUSE_AXIS_COUNT (8)
12 
13 namespace eeros {
14  namespace hal {
15 
16  struct MouseState {
17  struct {
18  bool left;
19  bool middle;
20  bool right;
21  } button;
22  struct {
23  signed x;
24  signed y;
25  signed z;
26  signed r;
27  } axis;
28  };
29 
30  class Mouse : public eeros::Thread {
31  public:
32  explicit Mouse(std::string dev);
33  ~Mouse();
34  virtual void on_event(std::function<void(struct input_event)> action);
35  virtual void on_button(std::function<void(int, bool)> action);
36  virtual void on_axis(std::function<void(int, signed)> action);
37  virtual std::string name();
38 
41 
42  private:
43  virtual void run();
44  virtual bool open(const char* device);
45  virtual void close();
46  int fd;
47  bool running;
48  std::function<void(struct input_event)> event_action;
49  std::function<void(int, bool)> button_action;
50  std::function<void(int, signed)> axis_action;
54  };
55  }
56 }
57 
58 #endif // ORG_EEROS_HAL_MOUSE_HPP_
bool middle
Definition: Mouse.hpp:19
signed y
Definition: Mouse.hpp:24
Definition: Mouse.hpp:16
signed z
Definition: Mouse.hpp:25
Definition: Config.hpp:14
signed r
Definition: Mouse.hpp:26
signed x
Definition: Mouse.hpp:23
bool right
Definition: Mouse.hpp:20
struct eeros::hal::MouseState::@1 button
Definition: Mouse.hpp:30
bool left
Definition: Mouse.hpp:18
Definition: Thread.hpp:12
volatile bool running
Definition: Executor.cpp:25
MouseState last
Definition: Mouse.hpp:40
struct eeros::hal::MouseState::@2 axis
MouseState current
Definition: Mouse.hpp:39