libevdevxx 0.4.0
A C++ wrapper for libevdev.
Loading...
Searching...
No Matches
Code.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_CODE_HPP
10#define LIBEVDEVXX_CODE_HPP
11
12
13#include <cstdint>
14#include <cstddef>
15#include <string>
16#include <string_view>
17#include <utility>
18
19#include "detail/NumberBase.hpp"
20#include "Type.hpp"
21
22
23namespace evdev {
24
31 struct Code :
32 public detail::NumberBase<std::uint16_t, Code> {
33
34 using Base = detail::NumberBase<std::uint16_t, Code>;
35
37 using value_type = typename Base::Value;
38
39 // expose the Base constructors
40
41 using Base::Base;
42
43
44 Code(Type type,
45 value_type code_num);
46
47
48 // named constructors
49
56 static
57 std::pair<Type, Code>
58 parse(std::string_view name,
59 std::size_t* pos = nullptr);
60
61
63 static
64 Code
65 max(Type type); // depends on type
66
67 };
68
69
71 std::string
73 Code code);
74
75
76}
77
78
79#endif
Definition: Type.hpp:28
The namespace of libevdevxx.
Definition: AbsInfo.hpp:20
std::string code_to_string(Type type, Code code)
Converts the code to a string representation.
Type-safe class for evdev codes (KEY_*, BTN_*, REL_*, etc).
Definition: Code.hpp:32
detail::NumberBase< std::uint16_t, Code > Base
Definition: Code.hpp:34
typename Base::Value value_type
The underlying value, same as std::uint16_t.
Definition: Code.hpp:37
static std::pair< Type, Code > parse(std::string_view name, std::size_t *pos=nullptr)
Parse a Type and Code from a string.
Code(Type type, value_type code_num)
static Code max(Type type)
Returns the maximum code available for a given type.