forked from tmackay/g13
-
Notifications
You must be signed in to change notification settings - Fork 0
/
g13_keys.cpp
38 lines (30 loc) · 945 Bytes
/
g13_keys.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* This file contains code for managing keys an profiles
*
*/
// TODO: check out why g13.h needs to be included before libevdev
// clang-format off
#include "g13.hpp"
#include "g13_device.hpp"
#include "g13_keys.hpp"
#include "helper.hpp"
// clang-format on
namespace G13 {
void G13_Key::dump(std::ostream &o) const {
o << G13_Manager::Instance()->FindG13KeyName(index()) << "(" << index()
<< ") : ";
if (action()) {
action()->dump(o);
} else {
o << "(no action)";
}
}
// *************************************************************************
void G13_Key::ParseKey(const unsigned char *byte, G13_Device *g13) {
bool key_is_down = byte[_index.offset] & _index.mask;
auto key_state_changed = g13->update(_index.index, key_is_down);
if (key_state_changed && _action) {
_action->act(*g13, key_is_down);
}
}
// *************************************************************************
} // namespace G13