libevdevxx 0.4.0
A C++ wrapper for libevdev.
Loading...
Searching...
No Matches
Property.hpp
Go to the documentation of this file.
1/*
2 * libevdevxx - a C++ wrapper for libevdev
3 *
4 * Copyright (C) 2021-2023 Daniel K. O.
5 * SPDX-License-Identifier: MIT
6 */
7
8
9#ifndef LIBEVDEVXX_PROPERTY_HPP
10#define LIBEVDEVXX_PROPERTY_HPP
11
12
13#include <cstddef>
14#include <iosfwd>
15#include <stdexcept>
16#include <string>
17#include <string_view>
18
19#include <libevdev/libevdev.h>
20
21#include "detail/NumberBase.hpp"
22
23
24namespace evdev {
25
26
27 class Property :
28 public detail::NumberBase<unsigned, Property> {
29
30 using Base = detail::NumberBase<unsigned, Property>;
31
32
33 public:
34
35
36 constexpr
38 noexcept = default;
39
40
41 constexpr
42 Property(unsigned val) :
43 Base{val}
44 {
45 if (val > INPUT_PROP_MAX)
46 throw std::invalid_argument{"invalid property number"};
47 }
48
49
50 // named constructors
51 static
53 parse(std::string_view name,
54 std::size_t* pos = nullptr);
55
56
57 static
58 inline
59 constexpr
60 Property max() noexcept
61 {
62 return Property{INPUT_PROP_MAX};
63 }
64
65
66 static const Property pointer;
67 static const Property direct;
68 static const Property button_pad;
69 static const Property semi_mt;
72 static const Property accelerometer;
73
74
75 };
76
77
78 inline constexpr Property Property::pointer {INPUT_PROP_POINTER};
79 inline constexpr Property Property::direct {INPUT_PROP_DIRECT};
80 inline constexpr Property Property::button_pad {INPUT_PROP_BUTTONPAD};
81 inline constexpr Property Property::semi_mt {INPUT_PROP_SEMI_MT};
82 inline constexpr Property Property::top_button_pad {INPUT_PROP_TOPBUTTONPAD};
83 inline constexpr Property Property::pointing_stick {INPUT_PROP_POINTING_STICK};
84 inline constexpr Property Property::accelerometer {INPUT_PROP_ACCELEROMETER};
85
86
87 std::string to_string(Property prop);
88
89
90 std::ostream&
91 operator <<(std::ostream& out,
92 Property prop);
93
94
95 std::istream&
96 operator >>(std::istream& in,
97 Property& prop);
98}
99
100
101#endif
Definition: Property.hpp:28
static constexpr Property max() noexcept
Definition: Property.hpp:60
static const Property pointer
Definition: Property.hpp:66
static const Property button_pad
Definition: Property.hpp:68
static const Property semi_mt
Definition: Property.hpp:69
constexpr Property() noexcept=default
static const Property direct
Definition: Property.hpp:67
static const Property accelerometer
Definition: Property.hpp:72
static const Property top_button_pad
Definition: Property.hpp:70
static Property parse(std::string_view name, std::size_t *pos=nullptr)
static const Property pointing_stick
Definition: Property.hpp:71
The namespace of libevdevxx.
Definition: AbsInfo.hpp:20
std::string to_string(const AbsInfo &info)
std::ostream & operator<<(std::ostream &out, const AbsInfo &info)
std::istream & operator>>(std::istream &in, Property &prop)