ubit
source.hpp
1 /*************************************************************************
2  *
3  * umssource.hpp: UMS event sources.
4  * Ubit GUI Toolkit - Version 6.0
5  * (C) 2003-2008 Eric Lecolinet / ENST Paris / www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _umssource_hpp_
18 #define _umssource_hpp_
19 #include <vector>
20 
21 /* ==================================================== ======== ======= */
29 struct UMSbutton {
30  UMSbutton(int btn_number, unsigned int mod_mask,
31  unsigned int to_btn_mask, unsigned int to_mod_mask);
32 
33  // input from the device
34  int in_btn_number;
35  unsigned int in_mod_mask; // in_btn_mask not included
36 
37  // output to the event flow
38  unsigned int out_btn_mask;
39  unsigned int out_mod_mask; // out_btn_mask not included
40 };
41 
42 /* ==================================================== ======== ======= */
46 class EventSource {
47 public:
48  EventSource() {fd = -1;}
49  virtual ~EventSource();
50 
51  int filedesc() const {return fd;}
52  bool is_open() const {return fd != -1;}
53 
54  virtual bool read() {return false;}
56 
57  virtual bool canCalibrate() const {return false;}
58  virtual void calibrate() {}
60 
61  UMSbutton* getButton(int btn_number);
62  UMSbutton* getButton(int btn_number, unsigned int mod_mask);
63 
64  void setButton(int btn_number, unsigned int out_btn_mask, unsigned int out_mod_mask);
65  void setButton(int btn_number, unsigned int mod_mask,
66  unsigned int out_btn_mask, unsigned int out_mod_mask);
67 
68 protected:
69  int fd;
70  std::vector<UMSbutton*> button_map;
71 };
72 
73 #endif
74 /* ==================================================== [TheEnd] ======= */
Mouse button mapping specifies the events generated by the buttons of the mouses rule: source_button_...
Definition: source.hpp:29
virtual void calibrate()
calibrates the device (if this device can be calibrated).
Definition: source.hpp:58
virtual bool read()
reads and process incoming data.
Definition: source.hpp:54
UMS event source.
Definition: source.hpp:46