Mir
motion_event.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17  */
18 
19 #ifndef MIR_COMMON_MOTION_EVENT_H_
20 #define MIR_COMMON_MOTION_EVENT_H_
21 
22 /* TODO: To the moon. */
23 #define MIR_INPUT_EVENT_MAX_POINTER_COUNT 16
24 
25 #include <chrono>
26 #include <cstdint>
27 
28 #include "mir/events/input_event.h"
29 #include "mir/cookie/blob.h"
30 
32 {
33  int id;
34  float x;
35  float y;
36  float dx;
37  float dy;
38  float touch_major;
39  float touch_minor;
40  float size;
41  float pressure;
42  float orientation;
43  float vscroll;
44  float hscroll;
46 
47  // TODO: We would like to store this as a MirTouchAction but we still encode pointer actions
48  // here as well.
49  int action;
50 };
51 
53 {
55 
56  int32_t device_id() const;
57  void set_device_id(int32_t id);
58 
59  int32_t source_id() const;
60  void set_source_id(int32_t id);
61 
62  MirInputEventModifiers modifiers() const;
63  void set_modifiers(MirInputEventModifiers modifiers);
64 
65  MirPointerButtons buttons() const;
66  void set_buttons(MirPointerButtons buttons);
67 
68  std::chrono::nanoseconds event_time() const;
69  void set_event_time(std::chrono::nanoseconds const& event_time);
70 
71  mir::cookie::Blob cookie() const;
72  void set_cookie(mir::cookie::Blob const& blob);
73 
74  size_t pointer_count() const;
75  void set_pointer_count(size_t count);
76 
77  int id(size_t index) const;
78  void set_id(size_t index, int id);
79 
80  float x(size_t index) const;
81  void set_x(size_t index, float x);
82 
83  float y(size_t index) const;
84  void set_y(size_t index, float y);
85 
86  float dx(size_t index) const;
87  void set_dx(size_t index, float dx);
88 
89  float dy(size_t index) const;
90  void set_dy(size_t index, float dy);
91 
92  float touch_major(size_t index) const;
93  void set_touch_major(size_t index, float major);
94 
95  float touch_minor(size_t index) const;
96  void set_touch_minor(size_t index, float minor);
97 
98  float size(size_t index) const;
99  void set_size(size_t index, float size);
100 
101  float pressure(size_t index) const;
102  void set_pressure(size_t index, float pressure);
103 
104  float orientation(size_t index) const;
105  void set_orientation(size_t index, float orientation);
106 
107  float vscroll(size_t index) const;
108  void set_vscroll(size_t index, float vscroll);
109 
110  float hscroll(size_t index) const;
111  void set_hscroll(size_t index, float hscroll);
112 
113  MirTouchTooltype tool_type(size_t index) const;
114  void set_tool_type(size_t index, MirTouchTooltype tool_type);
115 
116  int action(size_t index) const;
117  void set_action(size_t index, int action);
118 
119  MirTouchEvent* to_touch();
120  MirTouchEvent const* to_touch() const;
121 
122  MirPointerEvent* to_pointer();
123  MirPointerEvent const* to_pointer() const;
124 
125 private:
126  int32_t device_id_{-1};
127  int32_t source_id_{-1};
128 
129  MirInputEventModifiers modifiers_{0};
130 
131  MirPointerButtons buttons_{0};
132  std::chrono::nanoseconds event_time_{0};
133  mir::cookie::Blob cookie_;
134 
135  size_t pointer_count_{0};
137  /* "_coordinates" is a misnomer here because there's plenty more info than
138  just coordinates, but renaming it accurately would be an API break */
139 };
140 
141 // These are left empty as they are just aliases for a MirMotionEvent,
142 // but nice to be implicit cast to the base class
144 {
145 };
146 
148 {
149 };
150 
151 #endif /* MIR_COMMON_MOTION_EVENT_H_ */
float hscroll
Definition: motion_event.h:44
#define MIR_INPUT_EVENT_MAX_POINTER_COUNT
Definition: motion_event.h:23
float touch_major
Definition: motion_event.h:38
Definition: motion_event.h:143
float touch_minor
Definition: motion_event.h:39
float size
Definition: motion_event.h:40
float pressure
Definition: motion_event.h:41
std::array< uint8_t, default_blob_size > Blob
Definition: blob.h:29
unsigned int MirInputEventModifiers
Definition: input_event.h:66
Definition: motion_event.h:31
float dy
Definition: motion_event.h:37
float x
Definition: motion_event.h:34
MirTouchTooltype
Identifiers for per-touch tool types.
Definition: touch_event.h:78
unsigned int MirPointerButtons
Definition: pointer_event.h:85
float orientation
Definition: motion_event.h:42
MirTouchTooltype tool_type
Definition: motion_event.h:45
float y
Definition: motion_event.h:35
Definition: input_event.h:24
int id
Definition: motion_event.h:33
struct MirMotionEvent MirMotionEvent
Definition: event.h:28
int action
Definition: motion_event.h:49
Definition: motion_event.h:52
float vscroll
Definition: motion_event.h:43
Definition: motion_event.h:147
float dx
Definition: motion_event.h:36

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016