api: dump key binding strings (#606)

Print out human readable text for vKey when dumping bindings.
This commit is contained in:
bicarus
2026-04-03 20:22:24 -07:00
committed by GitHub
parent 1ad6a9412e
commit e0f6cb2cbd
3 changed files with 31 additions and 11 deletions
+2
View File
@@ -278,6 +278,8 @@ std::string Button::getVKeyString() {
return "Left Alt";
case 0xA5:
return "Right Alt";
case INVALID_VKEY:
return "Invalid";
default:
// check win API
+9 -1
View File
@@ -83,12 +83,20 @@ public:
if (this->override_enabled) {
return true;
}
// has a device
if (!this->device_identifier.empty()) {
return true;
}
// naive, and has a valid vKey
if (this->vKey != INVALID_VKEY) {
return true;
}
for (auto &alternative : this->alternatives) {
if (alternative.vKey != INVALID_VKEY) {
if (!alternative.getDeviceIdentifier().empty() ||
alternative.getVKey() != INVALID_VKEY) {
return true;
}
}
+20 -10
View File
@@ -2569,9 +2569,10 @@ void dump_button_bindings(std::vector<Button> *buttons) {
if (button->isNaive()) {
log_misc(
"rawinput", " [{}] dev=Naive, vkey={}",
"rawinput", " [{}] dev=Naive, vkey={} ({})",
button->getName(),
button->getVKey()
button->getVKey(),
button->getVKeyString()
);
} else {
log_misc(
@@ -2584,16 +2585,25 @@ void dump_button_bindings(std::vector<Button> *buttons) {
}
for (auto& alt : button->getAlternatives()) {
if (alt.getVKey() == INVALID_VKEY) {
if (!alt.isValid()) {
continue;
}
log_misc(
"rawinput", " [{}] (alt) dev={}, vkey={}, analogtype={}",
button->getName(),
alt.isNaive() ? "Naive" : alt.getDeviceIdentifier(),
alt.getVKey(),
static_cast<uint32_t>(alt.getAnalogType())
);
if (alt.isNaive()) {
log_misc(
"rawinput", " [{}] (alt) dev=Naive, vkey={} ({})",
alt.getName(),
alt.getVKey(),
alt.getVKeyString()
);
} else {
log_misc(
"rawinput", " [{}] (alt) dev={}, vkey={}, analogtype={}",
alt.getName(),
alt.getDeviceIdentifier(),
alt.getVKey(),
static_cast<uint32_t>(alt.getAnalogType())
);
}
}
}
}