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 65 66 67 68 69 70
|
/*
This file is part of libevdevPlus.
Copyright (C) 2018 YukiWorkshop
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.
*/
#ifndef LIBEVDEVPLUS_INPUTEVENT_HPP
#define LIBEVDEVPLUS_INPUTEVENT_HPP
#include "CommonIncludes.hpp"
namespace evdevPlus {
class InputEvent {
public:
input_event event{};
#if 0
timeval &Time = event.time;
#endif
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)
{
event.input_event_sec = time->tv_sec;
event.input_event_usec = time->tv_usec;
}
}
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));
}
};
}
#endif //LIBEVDEVPLUS_INPUTEVENT_HPP
|