MCPcopy Create free account
hub / github.com/MeisApps/pcbu-desktop / Start

Method Start

common/src/handler/KeyScanner.cpp:64–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void KeyScanner::Start() {
65#ifdef LINUX
66 if(m_IsRunning)
67 return;
68
69 m_IsRunning = true;
70 for(const auto &keyboard : GetKeyboards()) {
71 int kbd = open(keyboard.c_str(), O_RDONLY);
72 if(kbd == -1) {
73 spdlog::error("Keyboard open() failed. (Code={})", errno);
74 continue;
75 }
76 int flags = fcntl(kbd, F_GETFL, 0);
77 if(flags == -1) {
78 spdlog::error("Keyboard fcntl() failed. (Code={})", errno);
79 continue;
80 }
81 if(fcntl(kbd, F_SETFL, flags | O_NONBLOCK) == -1) {
82 spdlog::error("Keyboard fcntl(O_NONBLOCK) failed. (Code={})", errno);
83 continue;
84 }
85 m_KeyboardFds.push_back(kbd);
86 }
87 if(m_KeyboardFds.empty()) {
88 spdlog::error("No keyboards found.");
89 return;
90 }
91 m_KeyMaps.clear();
92 for(int i = 0; i < m_KeyboardFds.size(); i++) {
93 m_KeyMaps.emplace_back();
94 m_ScanThreads.emplace_back(&KeyScanner::ScanThread, this, i);
95 }
96#endif
97}
98
99void KeyScanner::Stop() {
100#ifdef LINUX

Callers 3

UpdateStepFormMethod · 0.45
GetResultMethod · 0.45
RunServerMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected