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