-
Notifications
You must be signed in to change notification settings - Fork 6
/
InputEvent.hpp
63 lines (46 loc) · 1.36 KB
/
InputEvent.hpp
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
/*
This file is part of libevdevPlus.
Copyright (C) 2018-2021 Reimu NotMoe <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the MIT License.
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.
*/
#pragma once
#include "CommonIncludes.hpp"
namespace evdevPlus {
class InputEvent {
public:
input_event event{};
timeval &Time = event.time;
uint16_t &Type = event.type;
uint16_t &Code = event.code;
int32_t &Value = event.value;
InputEvent() = default;
InputEvent(input_event *__event) {
memcpy(&event, __event, sizeof(input_event));
}
InputEvent(uint16_t type, uint16_t code, uint16_t value, timeval *time = NULL) {
Type = type;
Code = code;
Value = value;
if (time)
memcpy(&event.time, time, sizeof(timeval));
}
friend void swap(InputEvent &first, InputEvent &second) {
using std::swap;
swap(first.event, second.event);
}
InputEvent(InputEvent &&other) noexcept : InputEvent() {
swap(*this, other);
}
InputEvent& operator= (InputEvent other) {
swap(*this, other);
return *this;
}
InputEvent(const InputEvent &other) {
memcpy(&event, &(other.event), sizeof(input_event));
}
};
}