libevdevxx 0.5.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) 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 static
48 parse(std::string_view name,
49 std::size_t* pos = nullptr);
50
51
52 static
53 inline
54 constexpr
57 noexcept
58 {
59 return Property{INPUT_PROP_MAX};
60 }
61
62
63 static const Property pointer;
64 static const Property direct;
65 static const Property button_pad;
66 static const Property semi_mt;
69 static const Property accelerometer;
70
71
72 }; // class Property
73
74
75 inline constexpr Property Property::pointer {INPUT_PROP_POINTER};
76 inline constexpr Property Property::direct {INPUT_PROP_DIRECT};
77 inline constexpr Property Property::button_pad {INPUT_PROP_BUTTONPAD};
78 inline constexpr Property Property::semi_mt {INPUT_PROP_SEMI_MT};
79 inline constexpr Property Property::top_button_pad {INPUT_PROP_TOPBUTTONPAD};
80 inline constexpr Property Property::pointing_stick {INPUT_PROP_POINTING_STICK};
81 inline constexpr Property Property::accelerometer {INPUT_PROP_ACCELEROMETER};
82
83
84 std::string
86
87
88 std::ostream&
89 operator <<(std::ostream& out,
90 Property prop);
91
92
93 std::istream&
94 operator >>(std::istream& in,
95 Property& prop);
96
97} // namespace evdev
98
99#endif
Definition Property.hpp:25
static constexpr Property max() noexcept
Definition Property.hpp:56
static const Property pointer
Definition Property.hpp:63
static const Property button_pad
Definition Property.hpp:65
static const Property semi_mt
Definition Property.hpp:66
constexpr Property() noexcept=default
static const Property direct
Definition Property.hpp:64
static const Property accelerometer
Definition Property.hpp:69
static const Property top_button_pad
Definition Property.hpp:67
static Property parse(std::string_view name, std::size_t *pos=nullptr)
static const Property pointing_stick
Definition Property.hpp:68
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)