DUDS
Distributed Update of Data from Something
EventTypeCode.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2020 Jeff Jackowski
9  */
11 #include <libevdev/libevdev.h>
12 
13 #ifdef linux
14 // !@?!#?!#?
15 #undef linux
16 #endif
17 
18 namespace duds { namespace os { namespace linux {
19 
20 std::string EventTypeCode::typeName() const noexcept {
21  return typeName(std::string());
22 }
23 
24 std::string EventTypeCode::typeName(const std::string &unknown) const noexcept {
25  const char *str = libevdev_event_type_get_name(type);
26  if (str) {
27  return str;
28  } else {
29  return unknown;
30  }
31 }
32 
33 std::string EventTypeCode::codeName() const noexcept {
34  return codeName(std::string());
35 }
36 
37 std::string EventTypeCode::codeName(const std::string &unknown) const noexcept {
38  const char *str = libevdev_event_code_get_name(type, code);
39  if (str) {
40  return str;
41  } else {
42  return unknown;
43  }
44 }
45 
46 } } }
std::string codeName() const noexcept
Returns a string of the macro name for the event code, such as "REL_Y", or an empty string if the cod...
std::uint16_t code
An event code, such as KEY_A, ABS_X, or REL_Y.
std::uint16_t type
An event type, such as EV_KEY, EV_ABS, or EV_REL.
std::string typeName() const noexcept
Returns a string of the macro name for the event type, such as "EV_KEY", or an empty string if the ty...