Mir
input_device_state_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: Andreas Pokorny <andreas.pokorny@canonical.com>
17  */
18 
19 #ifndef MIR_COMMON_INPUT_DEVICE_STATE_EVENT_H_
20 #define MIR_COMMON_INPUT_DEVICE_STATE_EVENT_H_
21 
22 #include <chrono>
23 #include <limits>
24 
25 #include "mir/events/event.h"
26 
28 {
30 
33 
34  float pointer_axis(MirPointerAxis axis) const;
35  void set_pointer_axis(MirPointerButtons axis, float value);
36 
37  std::chrono::nanoseconds when() const;
38  void set_when(std::chrono::nanoseconds const& when);
39 
41  void set_modifiers(MirInputEventModifiers modifiers);
42 
43  uint32_t device_count() const;
44  MirInputDeviceId device_id(size_t index) const;
45  MirPointerButtons device_pointer_buttons(size_t index) const;
46  uint32_t const* device_pressed_keys(size_t index) const;
47  uint32_t device_pressed_keys_count(size_t index) const;
48 
49  static mir::EventUPtr deserialize(std::string const& bytes);
50  static std::string serialize(MirEvent const* event);
51  MirEvent* clone() const;
52 
53  void add_device(MirInputDeviceId id, std::vector<uint32_t> && pressed_keys, MirPointerButtons pointer_buttons);
54 
55 private:
56  std::chrono::nanoseconds when_{0};
57  MirPointerButtons pointer_buttons_{0};
58  MirInputEventModifiers modifiers_{0};
59 
60  float pointer_x{0.0f};
61  float pointer_y{0.0f};
62 
63  struct DeviceState
64  {
65  DeviceState(MirInputDeviceId id, std::vector<uint32_t> && pressed_keys, MirPointerButtons buttons)
66  : id{id}, pressed_keys{std::move(pressed_keys)}, pointer_buttons{buttons}
67  {}
69  std::vector<uint32_t> pressed_keys;
71  };
72  std::vector<DeviceState> devices;
73 };
74 
75 #endif /* MIR_COMMON_INPUT_DEVICE_STATE_EVENT_H_*/
void add_device(MirInputDeviceId id, std::vector< uint32_t > &&pressed_keys, MirPointerButtons pointer_buttons)
Definition: input_device_state_event.cpp:86
MirInputEventModifiers modifiers() const
Definition: input_device_state_event.cpp:76
void set_modifiers(MirInputEventModifiers modifiers)
Definition: input_device_state_event.cpp:81
MirPointerButtons pointer_buttons() const
Definition: input_device_state_event.cpp:28
uint32_t device_pressed_keys_count(size_t index) const
Definition: input_device_state_event.cpp:106
Definition: input_device_state_event.h:27
uint32_t device_count() const
Definition: input_device_state_event.cpp:91
unsigned int MirInputEventModifiers
Definition: input_event.h:66
int64_t MirInputDeviceId
Definition: input_event.h:35
MirInputDeviceStateEvent()
Definition: input_device_state_event.cpp:23
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: seat.h:32
MirInputDeviceId device_id(size_t index) const
Definition: input_device_state_event.cpp:96
void set_when(std::chrono::nanoseconds const &when)
Definition: input_device_state_event.cpp:71
unsigned int MirPointerButtons
Definition: pointer_event.h:85
float pointer_axis(MirPointerAxis axis) const
Definition: input_device_state_event.cpp:38
MirPointerButtons device_pointer_buttons(size_t index) const
Definition: input_device_state_event.cpp:111
MirEvent * clone() const
Definition: input_device_state_event.cpp:219
void set_pointer_buttons(MirPointerButtons buttons)
Definition: input_device_state_event.cpp:33
std::chrono::nanoseconds when() const
Definition: input_device_state_event.cpp:66
static mir::EventUPtr deserialize(std::string const &bytes)
Definition: input_device_state_event.cpp:129
MirPointerAxis
Identifiers for pointer axis.
Definition: pointer_event.h:56
void set_pointer_axis(MirPointerButtons axis, float value)
Definition: input_device_state_event.cpp:51
Definition: event.h:30
static std::string serialize(MirEvent const *event)
Definition: input_device_state_event.cpp:181
uint32_t const * device_pressed_keys(size_t index) const
Definition: input_device_state_event.cpp:101

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