Mir
seat_input_device_tracker.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 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:
17  * Andreas Pokorny <andreas.pokorny@canonical.com>
18  */
19 
20 #ifndef MIR_INPUT_SEAT_INPUT_DEVICE_TRACKER_H
21 #define MIR_INPUT_SEAT_INPUT_DEVICE_TRACKER_H
22 
24 #include "mir/geometry/point.h"
25 #include "mir_toolkit/event.h"
26 #include <unordered_map>
27 #include <memory>
28 
29 namespace mir
30 {
31 namespace input
32 {
33 class CursorListener;
34 class InputRegion;
35 class InputDispatcher;
36 
37 /*
38  * The SeatInputDeviceTracker bundles the input device properties of a group of devices defined by a seat:
39  * - a single cursor position,
40  * - modifier key states (i.e alt, ctrl ..)
41  * - a single mouse button state for all pointing devices
42  * - visible touch spots
43  */
45 {
46 public:
47  SeatInputDeviceTracker(std::shared_ptr<InputDispatcher> const& dispatcher,
48  std::shared_ptr<TouchVisualizer> const& touch_visualizer,
49  std::shared_ptr<CursorListener> const& cursor_listener,
50  std::shared_ptr<InputRegion> const& input_region);
53 
54  void dispatch(MirEvent & event);
55 
60 private:
61  void update_seat_properties(MirInputEvent const* event);
62  void update_cursor(MirPointerEvent const* event);
63  void update_spots();
64  void update_states();
65 
66  std::shared_ptr<InputDispatcher> const dispatcher;
67  std::shared_ptr<TouchVisualizer> const touch_visualizer;
68  std::shared_ptr<CursorListener> const cursor_listener;
69  std::shared_ptr<InputRegion> const input_region;
70 
71  struct DeviceData
72  {
73  DeviceData() {}
74  bool update_modifier(MirKeyboardAction action, int scan_code);
75  bool update_button_state(MirPointerButtons button_state);
76  bool update_spots(MirTouchEvent const* event);
77 
79  MirPointerButtons buttons{0};
80  std::vector<TouchVisualizer::Spot> spots;
81  };
82 
83  mir::geometry::Point cursor_pos;
84  MirInputEventModifiers modifier;
85  MirPointerButtons buttons;
86  std::unordered_map<MirInputDeviceId, DeviceData> device_data;
87  std::vector<TouchVisualizer::Spot> spots;
88 };
89 
90 }
91 }
92 
93 #endif
All things Mir.
Definition: atomic_callback.h:25
MirInputEventModifiers event_modifier() const
Definition: seat_input_device_tracker.cpp:92
MirPointerButtons button_state() const
Definition: seat_input_device_tracker.cpp:206
Definition: point.h:30
struct MirPointerEvent MirPointerEvent
An event type describing a change in pointer device state.
Definition: pointer_event.h:35
MirKeyboardAction
Possible actions for changing key state.
Definition: keyboard_event.h:46
unsigned int MirInputEventModifiers
Definition: input_event.h:66
Definition: seat_input_device_tracker.h:44
struct MirTouchEvent MirTouchEvent
An event type describing a change in touch device state.
Definition: touch_event.h:33
SeatInputDeviceTracker(std::shared_ptr< InputDispatcher > const &dispatcher, std::shared_ptr< TouchVisualizer > const &touch_visualizer, std::shared_ptr< CursorListener > const &cursor_listener, std::shared_ptr< InputRegion > const &input_region)
Definition: seat_input_device_tracker.cpp:40
int64_t MirInputDeviceId
Definition: input_event.h:35
unsigned int MirPointerButtons
Definition: pointer_event.h:85
void remove_device(MirInputDeviceId)
Definition: seat_input_device_tracker.cpp:54
struct MirInputEvent MirInputEvent
Definition: event.h:56
Definition: event_private.h:181
geometry::Point cursor_position() const
Definition: seat_input_device_tracker.cpp:201
void dispatch(MirEvent &event)
Definition: seat_input_device_tracker.cpp:73
void add_device(MirInputDeviceId)
Definition: seat_input_device_tracker.cpp:49

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016