Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 TouchVisualizer;
34 class InputRegion;
35 
36 namespace android
37 {
39 {
40  public:
41  explicit PointerController(std::shared_ptr<InputRegion> const& input_region,
42  std::shared_ptr<CursorListener> const& cursor_listener,
43  std::shared_ptr<TouchVisualizer> const& touch_visualizer);
44 
45  bool getBounds(float* out_min_x, float* out_min_y, float* out_max_x, float* out_max_y) const;
46  void move(float delta_x, float delta_y);
47  void setButtonState(int32_t button_state);
48  int32_t getButtonState() const;
49  void setPosition(float x, float y);
50  void getPosition(float *out_x, float *out_y) const;
51 
52  void setSpots(const droidinput::PointerCoords* spot_coords, uint32_t spot_count);
53  void clearSpots();
54 
55  private:
56  bool get_bounds_locked(float *out_min_x, float* out_min_y, float* out_max_x, float* out_max_y) const;
57  void notify_listener();
58  // Could be a read/write mutex as this is a latency sensitive class.
59  mutable std::mutex guard;
60  int32_t state;
61  float x, y;
62 
63  std::shared_ptr<InputRegion> const input_region;
64  std::shared_ptr<CursorListener> cursor_listener;
65  std::shared_ptr<TouchVisualizer> const touch_visualizer;
66 };
67 }
68 }
69 }
70 
71 #endif // MIR_INPUT_ANDROID_POINTER_CONTROLLER_H__
All things Mir.
Definition: aging_buffer.h:24
void setPosition(float x, float y)
PointerController(std::shared_ptr< InputRegion > const &input_region, std::shared_ptr< CursorListener > const &cursor_listener, std::shared_ptr< TouchVisualizer > const &touch_visualizer)
void setButtonState(int32_t button_state)
void move(float delta_x, float delta_y)
bool getBounds(float *out_min_x, float *out_min_y, float *out_max_x, float *out_max_y) const
Definition: dummy_android_pointer_controller.h:32
void setSpots(const droidinput::PointerCoords *spot_coords, uint32_t spot_count)
Definition: android_pointer_controller.h:38
Definition: android_input_receiver.h:32
void getPosition(float *out_x, float *out_y) const

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014