~ci-train-bot/mir/mir-ubuntu-zesty-2683

1160.1279.1 by Andreas Pokorny
Rebased Input Device Hub and Input Registry
1
/*
1160.1279.56 by Andreas Pokorny
another 2014 copyright fixed
2
 * Copyright © 2014-2015 Canonical Ltd.
1160.1279.1 by Andreas Pokorny
Rebased Input Device Hub and Input Registry
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_INPUT_SINK_H_
21
#define MIR_INPUT_INPUT_SINK_H_
22
23
#include "mir_toolkit/event.h"
1160.1444.16 by Kevin DuBois
merge mir
24
#include "mir/geometry/rectangle.h"
1160.2958.1 by Andreas Pokorny
mirclient: activate touchscreen mapping configuration and make use of it
25
#include "mir/geometry/point.h"
1160.1279.1 by Andreas Pokorny
Rebased Input Device Hub and Input Registry
26
1160.2388.7 by Andreas Pokorny
Basic support for sending input device state events and transfering them through a nested session
27
#include <vector>
1160.2958.17 by Andreas Pokorny
Input Platfrom API: Use a transformation matrix to describe the device to scene mapping
28
#include <array>
1160.2388.7 by Andreas Pokorny
Basic support for sending input device state events and transfering them through a nested session
29
1160.1279.1 by Andreas Pokorny
Rebased Input Device Hub and Input Registry
30
namespace mir
31
{
32
namespace input
33
{
1160.2958.1 by Andreas Pokorny
mirclient: activate touchscreen mapping configuration and make use of it
34
35
struct OutputInfo
36
{
1160.2958.17 by Andreas Pokorny
Input Platfrom API: Use a transformation matrix to describe the device to scene mapping
37
    using Matrix = std::array<float,6>; // 2x3 row major matrix
1160.2958.9 by Andreas Pokorny
build fixes
38
    OutputInfo() {}
1160.2958.17 by Andreas Pokorny
Input Platfrom API: Use a transformation matrix to describe the device to scene mapping
39
    OutputInfo(bool active, geometry::Size size, Matrix const& transformation)
1160.2958.21 by Andreas Pokorny
support for older gcc
40
        : active{active}, output_size{size}, output_to_scene(transformation)
1160.2958.9 by Andreas Pokorny
build fixes
41
    {}
42
1160.2958.1 by Andreas Pokorny
mirclient: activate touchscreen mapping configuration and make use of it
43
    bool active{false};
44
    geometry::Size output_size;
1160.2958.22 by Andreas Pokorny
ensure matrix is always initialized and do not access modes of unconfigured outputs
45
    Matrix output_to_scene{{1,0,0,
46
                            0,1,0}};
1160.2958.17 by Andreas Pokorny
Input Platfrom API: Use a transformation matrix to describe the device to scene mapping
47
48
    inline void transform_to_scene(float& x, float& y) const
49
    {
50
        auto original_x = x;
51
        auto original_y = y;
52
        auto const& mat = output_to_scene;
53
54
        x = mat[0]*original_x + mat[1]*original_y + mat[2]*1;
55
        y = mat[3]*original_x + mat[4]*original_y + mat[5]*1;
56
    }
1160.2958.1 by Andreas Pokorny
mirclient: activate touchscreen mapping configuration and make use of it
57
};
58
1160.1279.1 by Andreas Pokorny
Rebased Input Device Hub and Input Registry
59
class InputSink
60
{
61
public:
62
    InputSink() = default;
63
    virtual ~InputSink() = default;
64
    virtual void handle_input(MirEvent& event) = 0;
1160.1444.16 by Kevin DuBois
merge mir
65
    /**!
66
     * Obtain the bounding rectangle of the destination area for this input sink
67
     */
68
    virtual mir::geometry::Rectangle bounding_rectangle() const = 0;
69
1160.2958.1 by Andreas Pokorny
mirclient: activate touchscreen mapping configuration and make use of it
70
    /**!
71
     * Obtain the output information for a specific ouput.
72
     *
73
     * \param[in] output_id the id of the output
74
     */
75
    virtual OutputInfo output_info(uint32_t output_id) const = 0;
76
1160.2388.7 by Andreas Pokorny
Basic support for sending input device state events and transfering them through a nested session
77
    /**
78
     * \name Device State interface of InputSink
79
     *
1160.2388.28 by Andreas Pokorny
Review findings
80
     * In scenarios in which the system is not capable of receiving all changes as they occur,
1160.2388.7 by Andreas Pokorny
Basic support for sending input device state events and transfering them through a nested session
81
     * these method should be used to update the input device state as needed
82
     * \{
83
     */
84
    /**
85
     * Set all pressed scan codes.
86
     * \param scan_codes currently pressed
87
     */
1160.2388.28 by Andreas Pokorny
Review findings
88
    virtual void key_state(std::vector<uint32_t> const& scan_codes) = 0;
1160.2388.7 by Andreas Pokorny
Basic support for sending input device state events and transfering them through a nested session
89
    /**
90
     * Set button state of a pointing device.
91
     * \param buttons mask of the buttons currently pressed
92
     */
1160.2388.28 by Andreas Pokorny
Review findings
93
    virtual void pointer_state(MirPointerButtons buttons) = 0;
1160.2388.7 by Andreas Pokorny
Basic support for sending input device state events and transfering them through a nested session
94
    /**
95
     * \}
96
     */
1160.1279.1 by Andreas Pokorny
Rebased Input Device Hub and Input Registry
97
private:
98
    InputSink(InputSink const&) = delete;
99
    InputSink& operator=(InputSink const&) = delete;
100
};
101
}
102
}
103
104
#endif