Program Listing for File key_mapper.h

↰ Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/canonical-mir-documentation/checkouts/2.26/include/common/mir/input/key_mapper.h)

/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 2 or 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MIR_INPUT_KEY_MAPPER_H_
#define MIR_INPUT_KEY_MAPPER_H_

#include <mir_toolkit/client_types.h>
#include <mir_toolkit/event.h>
#include <mir/events/xkb_modifiers.h>

#include <vector>
#include <memory>

namespace mir
{
namespace input
{
class Keymap;

class KeyMapper
{
public:
    KeyMapper() = default;
    virtual ~KeyMapper() = default;

    virtual void set_key_state(MirInputDeviceId id, std::vector<uint32_t> const& key_state) = 0;

    virtual void set_keymap_for_device(MirInputDeviceId id, std::shared_ptr<Keymap> map) = 0;

    virtual void clear_keymap_for_device(MirInputDeviceId id) = 0;

    virtual void set_keymap_for_all_devices(std::shared_ptr<Keymap> map) = 0;

    /*
     * Remove all keymap configurations
     *
     * After this call no key code will be evaluated.
     */
    virtual void clear_all_keymaps() = 0;

    virtual void map_event(MirEvent& event) = 0;
    virtual MirInputEventModifiers modifiers() const = 0;
    virtual MirInputEventModifiers device_modifiers(MirInputDeviceId id) const = 0;
    virtual auto xkb_modifiers() const -> MirXkbModifiers = 0;

protected:
    KeyMapper(KeyMapper const&) = delete;
    KeyMapper& operator=(KeyMapper const&) = delete;
};

}
}

#endif