Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/VirtualKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,21 @@ bool VirtualKeyboard::init() {
return false;
}

std::string VirtualKeyboard::get_uid() const {
std::size_t hash = std::hash<std::string>{}(name);
std::string VirtualKeyboard::make_uid(const char *dev_name, int bus, int vid, int pid, int ver) {
std::size_t hash = std::hash<std::string>{}(dev_name ? dev_name : "");

char buf[64];
std::snprintf(buf, sizeof(buf),
"%04x:%04x:%04x:%04x:%016zx",
bustype, vendor, product, version, hash);
bus, vid, pid, ver, hash);

return buf;
}

std::string VirtualKeyboard::get_uid() const {
return make_uid(name, bustype, vendor, product, version);
}

void VirtualKeyboard::emit_key(int code, int value) {
if (!uidev_) return;

Expand Down
2 changes: 2 additions & 0 deletions src/VirtualKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class VirtualKeyboard {

bool init();

static std::string make_uid(const char *dev_name, int bus, int vid, int pid, int ver);

std::string get_uid() const;

void emit_key(int code, int value);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ bool configure() {
return false;
}

std::string uid = vk.get_uid();
std::string uid = VirtualKeyboard::make_uid(vk.name, vk.bustype, vk.vendor, vk.product, vk.version);
reader.add_to_blacklist(uid);

bool connected;
Expand Down