libevdevxx 0.5.0
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 static
50 Type
51 parse(std::string_view name,
52 std::size_t* pos = nullptr);
53
54
55 static
56 constexpr
57 Type
59 noexcept
60 {
61 return Type{EV_MAX};
62 }
63
64
65 static
66 constexpr
67 std::uint16_t
69 noexcept
70 {
71 return EV_CNT;
72 }
73
74
75 static const Type syn;
76 static const Type key;
77 static const Type rel;
78 static const Type abs;
79 static const Type msc;
80 static const Type sw;
81 static const Type led;
82 static const Type snd;
83 static const Type rep;
84 static const Type ff;
85 static const Type pwr;
86 static const Type ff_status;
87
88 }; // class Type
89
90
91 inline constexpr const Type Type::syn {EV_SYN};
92 inline constexpr const Type Type::key {EV_KEY};
93 inline constexpr const Type Type::rel {EV_REL};
94 inline constexpr const Type Type::abs {EV_ABS};
95 inline constexpr const Type Type::msc {EV_MSC};
96 inline constexpr const Type Type::sw {EV_SW};
97 inline constexpr const Type Type::led {EV_LED};
98 inline constexpr const Type Type::snd {EV_SND};
99 inline constexpr const Type Type::rep {EV_REP};
100 inline constexpr const Type Type::ff {EV_FF};
101 inline constexpr const Type Type::pwr {EV_PWR};
102 inline constexpr const Type Type::ff_status {EV_FF_STATUS};
103
104
105 std::string
107
108
109 std::ostream&
110 operator <<(std::ostream& out,
111 Type type);
112
113} // namespace evdev
114
115#endif
Definition Type.hpp:26
static const Type syn
Definition Type.hpp:75
static const Type rep
Definition Type.hpp:83
static const Type rel
Definition Type.hpp:77
constexpr Type() noexcept=default
static constexpr Type max() noexcept
Definition Type.hpp:58
static const Type pwr
Definition Type.hpp:85
static const Type key
Definition Type.hpp:76
static Type parse(std::string_view name, std::size_t *pos=nullptr)
static const Type msc
Definition Type.hpp:79
static const Type sw
Definition Type.hpp:80
static const Type ff_status
Definition Type.hpp:86
static const Type led
Definition Type.hpp:81
static const Type ff
Definition Type.hpp:84
static const Type abs
Definition Type.hpp:78
static const Type snd
Definition Type.hpp:82
static constexpr std::uint16_t count() noexcept
Definition Type.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)