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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/*
This file is part of libuInputPlus.
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 LIBUINPUTPLUS_UINPUTSETUP_HPP
#define LIBUINPUTPLUS_UINPUTSETUP_HPP
#include "CommonIncludes.hpp"
namespace uInputPlus {
extern const std::set<int> DefaultEventTypes;
extern const std::set<int> DefaultKeys;
extern const std::set<int> DefaultRels;
extern const std::set<int> DefaultAbss;
class uInputAbsSetup {
public:
uinput_abs_setup setup{};
uint16_t &Code = setup.code;
int32_t &Value = setup.absinfo.value;
int32_t &Min = setup.absinfo.minimum;
int32_t &Max = setup.absinfo.maximum;
int32_t &Resoltion = setup.absinfo.resolution;
int32_t &Fuzz = setup.absinfo.fuzz;
int32_t &Flat = setup.absinfo.flat;
uInputAbsSetup() = default;
uInputAbsSetup(uint16_t code, int32_t max) {
Code = code;
Max = max;
}
uInputAbsSetup(uint16_t code, int32_t max, int32_t resolution) {
Code = code;
Max = max;
Resoltion = resolution;
}
uInputAbsSetup(uint16_t code, int32_t min, int32_t max, int32_t value, int32_t resolution, int32_t fuzz, int32_t flat) {
Code = code;
Min = min;
Max = max;
Value = value;
Resoltion = resolution;
Fuzz = fuzz;
Flat = flat;
}
friend void swap(uInputAbsSetup &first, uInputAbsSetup &second) {
using std::swap;
swap(first.setup, second.setup);
}
uInputAbsSetup(uInputAbsSetup &&other) noexcept : uInputAbsSetup() {
swap(*this, other);
}
uInputAbsSetup& operator= (uInputAbsSetup other) {
swap(*this, other);
return *this;
}
uInputAbsSetup(const uInputAbsSetup &other) {
memcpy(&setup, &(other.setup), sizeof(uinput_abs_setup));
}
};
class uInputDeviceInfo {
public:
uinput_setup usetup{};
uint16_t &BusType = usetup.id.bustype;
uint16_t &Vendor = usetup.id.vendor;
uint16_t &Product = usetup.id.product;
uint16_t &Version = usetup.id.version;
uInputDeviceInfo() = default;
uInputDeviceInfo(const std::string &name, uint16_t bus_type = BUS_USB, uint16_t vid = 0x2333, uint16_t pid = 0x6666, uint16_t version = 23333);
void Name(const std::string &__name);
std::string Name();
friend void swap(uInputDeviceInfo &first, uInputDeviceInfo &second) {
using std::swap;
swap(first.usetup, second.usetup);
}
uInputDeviceInfo(uInputDeviceInfo &&other) noexcept : uInputDeviceInfo() {
swap(*this, other);
}
uInputDeviceInfo& operator= (uInputDeviceInfo other) noexcept {
swap(*this, other);
return *this;
}
uInputDeviceInfo(const uInputDeviceInfo &other) {
memcpy(&usetup, &(other.usetup), sizeof(uinput_setup));
}
};
class uInputSetup {
public:
uInputDeviceInfo DeviceInfo;
std::set<int> Events;
std::set<int> Keys;
std::set<int> Rels;
std::vector<uInputAbsSetup> AbsSetup;
std::set<int> Props;
uInputSetup() = default;
uInputSetup(const uInputDeviceInfo &device_info,
const std::set<int> &events = DefaultEventTypes,
const std::set<int> &keys = DefaultKeys,
const std::set<int> &rels = DefaultRels,
const std::vector<uInputAbsSetup> &abs_setup = {},
const std::set<int> &props = {});
};
}
#endif //LIBUINPUTPLUS_UINPUTSETUP_HPP
|