summaryrefslogtreecommitdiffhomepage
path: root/floormat/events.hpp
blob: 68c2beddffdc760e086d9ffea4e93e8ca7117f0e (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
54
#pragma once
#include <Corrade/Containers/StringView.h>
#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 << 2,
    mouse_button_x1     = 1 << 3,
    mouse_button_x2     = 1 << 4,
};

struct mouse_button_event final {
    Vector2i position;
    int mods = 0;
    mouse_button button = mouse_button_none;
    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 {
    StringView text;
};

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

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

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

} // namespace floormat