Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
android_pointer_controller.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_INPUT_ANDROID_POINTER_CONTROLLER_H__
20 #define MIR_INPUT_ANDROID_POINTER_CONTROLLER_H__
21 
23 
25 
26 #include <memory>
27 #include <mutex>
28 
29 namespace mir
30 {
31 namespace input
32 {
33 class InputRegion;
34 namespace android
35 {
36 class PointerController : public DummyPointerController
37 {
38  public:
39  explicit PointerController(std::shared_ptr<InputRegion> const& input_region);
40  explicit PointerController(std::shared_ptr<InputRegion> const& input_region,
41  std::shared_ptr<CursorListener> const& cursor_listener);
42 
43  virtual bool getBounds(float* out_min_x, float* out_min_y, float* out_max_x, float* out_max_y) const;
44  virtual void move(float delta_x, float delta_y);
45  virtual void setButtonState(int32_t button_state);
46  virtual int32_t getButtonState() const;
47  virtual void setPosition(float x, float y);
48  virtual void getPosition(float *out_x, float *out_y) const;
49 
50  private:
51  bool get_bounds_locked(float *out_min_x, float* out_min_y, float* out_max_x, float* out_max_y) const;
52  void notify_listener();
53  // Could be a read/write mutex as this is a latency sensitive class.
54  mutable std::mutex guard;
55  int32_t state;
56  float x, y;
57 
58  std::shared_ptr<InputRegion> const input_region;
59  std::shared_ptr<CursorListener> cursor_listener;
60 };
61 }
62 }
63 }
64 
65 #endif // MIR_INPUT_ANDROID_POINTER_CONTROLLER_H__

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013