g13d: Add in the ability to unbind keys

This allows us to unbind keys and leave them natural in the GUI.
This commit is contained in:
June Tate-Gans 2021-04-28 23:31:29 -05:00
parent b2576707ea
commit b9000dd5a9
2 changed files with 21 additions and 0 deletions

View File

@ -118,6 +118,10 @@ class Actionable {
return _parent_ptr->manager();
}
virtual void clear_action() {
_action.reset();
}
virtual void set_action(const ActionPtr &action) {
_action = action;
}

View File

@ -434,6 +434,23 @@ void Device::_init_commands() {
}
}
G13_DEVICE_COMMAND(unbind) {
std::string keyname = remainder;
try {
if (auto key = _current_profile->find_key(keyname)) {
key->clear_action();
} else if (auto stick_key = _stick.zone(keyname)) {
stick_key->clear_action();
} else {
RETURN_FAIL("unbind key " << keyname << " unknown");
}
G13_LOG(trace, "unbind " << keyname);
} catch (const std::exception &ex) {
RETURN_FAIL("unbind " << keyname
<< " failed : " << ex.what())
}
}
G13_DEVICE_COMMAND(profile) {
switch_to_profile(remainder);
}