EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
8 #define MOUSE_BUTTON_COUNT (16)
9 #define MOUSE_AXIS_COUNT (8)
10 
11 namespace eeros {
12  namespace hal {
13 
14  struct MouseState
15  {
16  struct
17  {
18  bool left;
19  bool middle;
20  bool right;
21  } button;
22  struct
23  {
24  signed x;
25  signed y;
26  signed z;
27  signed r;
28  } axis;
29  };
30 
31  class Mouse
32  {
33  public:
34  explicit Mouse();
35  ~Mouse();
36  virtual bool open(const char* device);
37  virtual void close();
38  virtual void loop();
39  virtual void on_event(std::function<void(struct input_event)> action);
40  virtual void on_button(std::function<void(int, bool)> action);
41  virtual void on_axis(std::function<void(int, signed)> action);
42 
43  virtual std::string name();
44 
47 
48  private:
49  int fd;
50  std::function<void(struct input_event)> event_action;
51  std::function<void(int, bool)> button_action;
52  std::function<void(int, signed)> axis_action;
53  };
54  }
55 }
56 
57 #endif // ORG_EEROS_HAL_MOUSE_HPP_
struct eeros::hal::MouseState::@5 button
bool middle
Definition: Mouse.hpp:19
virtual void close()
Definition: Mouse.cpp:35
signed y
Definition: Mouse.hpp:25
Definition: Mouse.hpp:14
signed z
Definition: Mouse.hpp:26
signed r
Definition: Mouse.hpp:27
virtual std::string name()
Definition: Mouse.cpp:40
signed x
Definition: Mouse.hpp:24
struct eeros::hal::MouseState::@6 axis
bool right
Definition: Mouse.hpp:20
Definition: Mouse.hpp:31
bool left
Definition: Mouse.hpp:18
virtual bool open(const char *device)
Definition: Mouse.cpp:29
virtual void on_button(std::function< void(int, bool)> action)
Definition: Mouse.cpp:61
virtual void loop()
Definition: Mouse.cpp:72
Mouse()
Definition: Mouse.cpp:10
MouseState last
Definition: Mouse.hpp:46
~Mouse()
Definition: Mouse.cpp:24
virtual void on_event(std::function< void(struct input_event)> action)
Definition: Mouse.cpp:56
virtual void on_axis(std::function< void(int, signed)> action)
Definition: Mouse.cpp:66
MouseState current
Definition: Mouse.hpp:45