2
* Copyright © 2016 Canonical Ltd.
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.
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.
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/>.
17
* Andreas Pokorny <andreas.pokorny@canonical.com>
20
#ifndef MIR_INPUT_KEY_MAPPER_H_
21
#define MIR_INPUT_KEY_MAPPER_H_
23
#include "mir_toolkit/client_types.h"
24
#include "mir_toolkit/event.h"
26
#include <xkbcommon/xkbcommon.h>
39
* The key mapping interface KeyMapper allows configuring a key map for each device individually or a single
40
* key map shared by all devices.
42
* The key mapping tables can either be provided as xkbcommon text buffers in the XKB_KEYMAP_FORMAT_TEXT_V1 format, or
43
* as xkbcommon configuration tuples using the mir::input::Keymap structure.
48
KeyMapper() = default;
49
virtual ~KeyMapper() = default;
51
/// Update the key state of device \a id, with the given sequence of pressed scan codes.
52
virtual void set_key_state(MirInputDeviceId id, std::vector<uint32_t> const& key_state) = 0;
55
* Set a keymap for the device \a id
57
virtual void set_keymap_for_device(MirInputDeviceId id, Keymap const& map) = 0;
59
* Set a keymap for the device \a id
61
virtual void set_keymap_for_device(MirInputDeviceId id, char const* buffer, size_t len) = 0;
63
* Remove the specific keymap defined for device identified via the \a id.
65
* After this call key codes in events processed for device \a id will not be evaluated.
67
virtual void clear_keymap_for_device(MirInputDeviceId id) = 0;
70
* Set a default keymap for all devices.
72
virtual void set_keymap_for_all_devices(Keymap const& map) = 0;
74
* Set a default keymap for all devices.
76
virtual void set_keymap_for_all_devices(char const* buffer, size_t len) = 0;
78
* Remove all keymap configurations
80
* After this call no key code will be evaluated.
82
virtual void clear_all_keymaps() = 0;
85
* Map the given event based on the key maps configured.
87
* This includes mapping scan codes in key events onto the respective key code, and also replacing modifier
88
* masks in input events with the modifier mask evaluated by this Keymapper.
90
virtual void map_event(MirEvent& event) = 0;
91
virtual MirInputEventModifiers modifiers() const = 0;
94
KeyMapper(KeyMapper const&) = delete;
95
KeyMapper& operator=(KeyMapper const&) = delete;