Register keys for keypress only when needed

there seems to be an issue that with too many registered events some window
manager cannot recognize the device as input device with systemd 247.

PixlOne#166
This commit is contained in:
max
2020-12-14 20:02:44 +01:00
parent 911e91eeeb
commit f8eb77cad7
3 changed files with 16 additions and 6 deletions

View File

@@ -64,9 +64,11 @@ KeypressAction::Config::Config(Device* device, libconfig::Setting& config) :
auto& key = keys[i];
if(key.isNumber()) {
_keys.push_back(key);
virtual_input->registerKey(key);
} else if(key.getType() == libconfig::Setting::TypeString) {
try {
_keys.push_back(virtual_input->toKeyCode(key));
virtual_input->registerKey(virtual_input->toKeyCode(key));
} catch(InputDevice::InvalidEventCode& e) {
logPrintf(WARN, "Line %d: Invalid keycode %s, skipping."
, key.getSourceLine(), key.c_str());