libevdevxx 0.5.3
A C++ wrapper for libevdev.
Loading...
Searching...
No Matches
Type.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_TYPE_HPP
9#define LIBEVDEVXX_TYPE_HPP
10
11#include <cstddef>
12#include <cstdint>
13#include <iosfwd>
14#include <stdexcept>
15#include <string>
16#include <string_view>
17
18#include <libevdev/libevdev.h>
19
20#include "NumberBase.hpp"
21
22
23namespace evdev {
24
25 class Type :
26 public detail::NumberBase<std::uint16_t, Type> {
27
29
30 public:
31
32 constexpr
34 noexcept = default;
35
36
37 explicit
38 constexpr
39 Type(std::uint16_t number) :
40 BaseType{number}
41 {
42 if (number > EV_MAX)
43 throw std::invalid_argument{"invalid event type number"};
44 }
45
46
47 // named constructors
48
49 [[nodiscard]]
50 static
51 Type
52 parse(std::string_view name,
53 std::size_t* pos = nullptr);
54
55
56 [[nodiscard]]
57 static
58 constexpr
59 Type
61 noexcept
62 {
63 return Type{EV_MAX};
64 }
65
66
67 [[nodiscard]]
68 static
69 constexpr
70 std::uint16_t
72 noexcept
73 {
74 return EV_CNT;
75 }
76
77
78 static const Type syn;
79 static const Type key;
80 static const Type rel;
81 static const Type abs;
82 static const Type msc;
83 static const Type sw;
84 static const Type led;
85 static const Type snd;
86 static const Type rep;
87 static const Type ff;
88 static const Type pwr;
89 static const Type ff_status;
90
91 }; // class Type
92
93
94 constexpr const Type Type::syn {EV_SYN};
95 constexpr const Type Type::key {EV_KEY};
96 constexpr const Type Type::rel {EV_REL};
97 constexpr const Type Type::abs {EV_ABS};
98 constexpr const Type Type::msc {EV_MSC};
99 constexpr const Type Type::sw {EV_SW};
100 constexpr const Type Type::led {EV_LED};
101 constexpr const Type Type::snd {EV_SND};
102 constexpr const Type Type::rep {EV_REP};
103 constexpr const Type Type::ff {EV_FF};
104 constexpr const Type Type::pwr {EV_PWR};
105 constexpr const Type Type::ff_status {EV_FF_STATUS};
106
107
108 [[nodiscard]]
109 std::string
111
112
113 std::ostream&
114 operator <<(std::ostream& out,
115 Type type);
116
117} // namespace evdev
118
119#endif
Definition Type.hpp:26
static const Type syn
Definition Type.hpp:78
static const Type rep
Definition Type.hpp:86
static const Type rel
Definition Type.hpp:80
constexpr Type() noexcept=default
static constexpr Type max() noexcept
Definition Type.hpp:60
static const Type pwr
Definition Type.hpp:88
static const Type key
Definition Type.hpp:79
static Type parse(std::string_view name, std::size_t *pos=nullptr)
static const Type msc
Definition Type.hpp:82
static const Type sw
Definition Type.hpp:83
static const Type ff_status
Definition Type.hpp:89
static const Type led
Definition Type.hpp:84
static const Type ff
Definition Type.hpp:87
static const Type abs
Definition Type.hpp:81
static const Type snd
Definition Type.hpp:85
static constexpr std::uint16_t count() noexcept
Definition Type.hpp:71
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)