libevdevxx 0.5.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) 2025 Daniel K. O.
5 * SPDX-License-Identifier: MIT
6 */
7
8#ifndef LIBEVDEVXX_CODE_HPP
9#define LIBEVDEVXX_CODE_HPP
10
11#include <cstdint>
12#include <cstddef>
13#include <string>
14#include <string_view>
15#include <utility>
16
17#include "NumberBase.hpp"
18#include "Type.hpp"
19
20
21namespace evdev {
22
29 struct Code :
30 public detail::NumberBase<std::uint16_t, Code> {
31
33
35 using value_type = typename BaseType::Value;
36
37 // expose the BaseType constructors
38 using BaseType::BaseType;
39
40
41 Code(Type type,
42 value_type code_num);
43
44
45 // named constructors
46
53 static
54 std::pair<Type, Code>
55 parse(std::string_view name,
56 std::size_t* pos = nullptr);
57
58
60 static
61 Code
62 max(Type type); // depends on type
63
64 };
65
66
68 std::string
70 Code code);
71
72} // namespace evdev
73
74#endif
Definition Type.hpp:26
Definition NumberBase.hpp:21
std::uint16_t Value
Definition NumberBase.hpp:25
The namespace of libevdevxx.
Definition AbsInfo.hpp:18
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:30
typename BaseType::Value value_type
The underlying value, same as std::uint16_t.
Definition Code.hpp:35
static std::pair< Type, Code > parse(std::string_view name, std::size_t *pos=nullptr)
Parse a Type and Code from a string.
detail::NumberBase< std::uint16_t, Code > BaseType
Definition Code.hpp:32
Code(Type type, value_type code_num)
static Code max(Type type)
Returns the maximum code available for a given type.