Mir
key_mapper.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:
17  * Andreas Pokorny <andreas.pokorny@canonical.com>
18  */
19 
20 #ifndef MIR_INPUT_KEY_MAPPER_H_
21 #define MIR_INPUT_KEY_MAPPER_H_
22 
24 #include "mir_toolkit/event.h"
25 
26 #include <xkbcommon/xkbcommon.h>
27 #include <vector>
28 #include <memory>
29 
30 struct MirKeyEvent;
31 
32 namespace mir
33 {
34 namespace input
35 {
36 class Keymap;
37 
45 class KeyMapper
46 {
47 public:
48  KeyMapper() = default;
49  virtual ~KeyMapper() = default;
50 
52  virtual void set_key_state(MirInputDeviceId id, std::vector<uint32_t> const& key_state) = 0;
53 
57  virtual void set_keymap_for_device(MirInputDeviceId id, Keymap const& map) = 0;
61  virtual void set_keymap_for_device(MirInputDeviceId id, char const* buffer, size_t len) = 0;
67  virtual void clear_keymap_for_device(MirInputDeviceId id) = 0;
68 
72  virtual void set_keymap_for_all_devices(Keymap const& map) = 0;
76  virtual void set_keymap_for_all_devices(char const* buffer, size_t len) = 0;
77  /*
78  * Remove all keymap configurations
79  *
80  * After this call no key code will be evaluated.
81  */
82  virtual void clear_all_keymaps() = 0;
83 
90  virtual void map_event(MirEvent& event) = 0;
91  virtual MirInputEventModifiers modifiers() const = 0;
92 
93 protected:
94  KeyMapper(KeyMapper const&) = delete;
95  KeyMapper& operator=(KeyMapper const&) = delete;
96 };
97 
98 }
99 }
100 
101 #endif
All things Mir.
Definition: atomic_callback.h:25
virtual void clear_keymap_for_device(MirInputDeviceId id)=0
Remove the specific keymap defined for device identified via the id.
virtual void set_keymap_for_all_devices(Keymap const &map)=0
Set a default keymap for all devices.
KeyMapper & operator=(KeyMapper const &)=delete
virtual void set_key_state(MirInputDeviceId id, std::vector< uint32_t > const &key_state)=0
Update the key state of device id, with the given sequence of pressed scan codes. ...
virtual ~KeyMapper()=default
unsigned int MirInputEventModifiers
Definition: input_event.h:66
The key mapping interface KeyMapper allows configuring a key map for each device individually or a si...
Definition: key_mapper.h:45
Definition: keymap.h:30
int64_t MirInputDeviceId
Definition: input_event.h:35
virtual MirInputEventModifiers modifiers() const =0
virtual void map_event(MirEvent &event)=0
Map the given event based on the key maps configured.
virtual void set_keymap_for_device(MirInputDeviceId id, Keymap const &map)=0
Set a keymap for the device id.
virtual void clear_all_keymaps()=0
Definition: event.h:30

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