summaryrefslogtreecommitdiffhomepage
path: root/floormat/events.hpp
blob: 44e54a05ed1ba8ba01d08509f95dd4c94e15341b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <Magnum/Math/Vector2.h>

namespace floormat {

enum mouse_button : unsigned char {
    mouse_button_none   = 0,
    mouse_button_left   = 1 << 0,
    mouse_button_middle = 1 << 1,
    mouse_button_right  = 1 << 3,
    mouse_button_x1     = 1 << 4,
    mouse_button_x2     = 1 << 5,
};

struct mouse_button_event final {
    Vector2i position;
    int mods = 0;
    mouse_button button = mouse_button_none;
    std::uint8_t click_count = 0;
};

struct mouse_move_event final {
    Vector2i position;
    mouse_button buttons = mouse_button_none;
    int mods = 0;
};

struct mouse_scroll_event final {
    Magnum::Vector2 offset;
    Vector2i position;
    int mods = 0;
};

struct text_input_event final {
    Containers::StringView text;
};

struct text_editing_event final {
    Containers::StringView text;
    std::int32_t start = 0, length = 0;
};

struct key_event final {
    int key  = 0;
    int mods = 0;
    std::uint8_t is_repeated = false;
};

union alignas(alignof(void*)) any_event {
    char buf[64];
};

} // namespace floormat