forked from dgcor/DGEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputEvent.h
More file actions
executable file
·64 lines (53 loc) · 1.91 KB
/
Copy pathInputEvent.h
File metadata and controls
executable file
·64 lines (53 loc) · 1.91 KB
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
55
56
57
58
59
60
61
62
63
64
#pragma once
#include <cstdint>
#include <SFML/Window/Event.hpp>
#include <type_traits>
#include <vector>
struct CompareEvent
{
static bool compare(const sf::Event& obj1, const sf::Event& obj2) noexcept;
size_t operator()(const sf::Event& obj) const noexcept;
bool operator()(const sf::Event& obj1, const sf::Event& obj2) const noexcept;
};
enum class InputType : int32_t
{
Mouse,
Keyboard,
Joystick
};
struct InputEvent
{
InputType type;
int32_t value;
bool isActive() const;
};
struct CompositeInputEvent
{
std::vector<InputEvent> events;
bool isActive() const;
};
enum class InputEventType : int32_t
{
None = 0,
LeftClick = 1,
MiddleClick = 2,
RightClick = 4,
MousePress = 8,
MouseMove = 16,
MouseRelease = 32,
MouseScroll = 64,
KeyPress = 128,
TextEnter = 256,
TouchBegin = 512,
TouchMove = 1024,
TouchEnd = 2048,
All = 0xFFF
};
using T = std::underlying_type_t<InputEventType>;
constexpr InputEventType operator~ (InputEventType a) noexcept { return (InputEventType)~static_cast<T>(a); }
constexpr InputEventType operator| (InputEventType a, InputEventType b) noexcept { return (InputEventType)(static_cast<T>(a) | static_cast<T>(b)); }
constexpr InputEventType operator& (InputEventType a, InputEventType b) noexcept { return (InputEventType)(static_cast<T>(a) & static_cast<T>(b)); }
constexpr InputEventType operator^ (InputEventType a, InputEventType b) noexcept { return (InputEventType)(static_cast<T>(a) ^ static_cast<T>(b)); }
constexpr InputEventType& operator|= (InputEventType& a, InputEventType b) noexcept { a = (InputEventType)(static_cast<T>(a) | static_cast<T>(b)); return a; }
constexpr InputEventType& operator&= (InputEventType& a, InputEventType b) noexcept { a = (InputEventType)(static_cast<T>(a) & static_cast<T>(b)); return a; }
constexpr InputEventType& operator^= (InputEventType& a, InputEventType b) noexcept { a = (InputEventType)(static_cast<T>(a) ^ static_cast<T>(b)); return a; }