overlay: setting button as always-on (#671)

## Link to GitHub Issue or related Pull Request, if one exists
n/a

## Description of change

Add a checkbox to the buttons edit dialog that lets you set a device as
"always on", accomplished by setting the device to `Naive`, vkey to
`0xff` (invalid), and `Invert`.

No backend rawinput changes.

## Testing
This commit is contained in:
bicarus
2026-05-02 22:42:36 -07:00
committed by GitHub
parent b6a749e5db
commit c8962a0e77
2 changed files with 26 additions and 6 deletions
+4 -1
View File
@@ -306,7 +306,10 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
std::string vKeyString = fmt::format("{:#x}", vKey); std::string vKeyString = fmt::format("{:#x}", vKey);
// device must be existing // device must be existing
if (this->device_identifier.empty() && vKey == INVALID_VKEY) { if (this->isNaive() && vKey == INVALID_VKEY) {
if (this->getInvert()) {
return "(always on)";
}
return ""; return "";
} }
+22 -5
View File
@@ -2003,6 +2003,7 @@ namespace overlay::windows {
int vKey = button->getVKey(); int vKey = button->getVKey();
if (ImGui::InputInt(button->isNaive() ? "Virtual Key" : "Index", &vKey, 1, 1)) { if (ImGui::InputInt(button->isNaive() ? "Virtual Key" : "Index", &vKey, 1, 1)) {
button->setVKey(vKey); button->setVKey(vKey);
button->setInvert(false);
} }
if (ImGui::IsItemDeactivatedAfterEdit()) { if (ImGui::IsItemDeactivatedAfterEdit()) {
dirty = true; dirty = true;
@@ -2070,11 +2071,27 @@ namespace overlay::windows {
"This setting will add noticable input lag."); "This setting will add noticable input lag.");
} }
// invert // invert (widget hidden for naive + 0xff)
bool invert = button->getInvert(); if (!(button->isNaive() && button->getVKey() == INVALID_VKEY)) {
if (ImGui::Checkbox("Invert Resulting Value", &invert)) { bool invert = button->getInvert();
button->setInvert(invert); if (ImGui::Checkbox("Invert Resulting Value", &invert)) {
dirty = true; button->setInvert(invert);
dirty = true;
}
}
// always on (naive + vkey 0xff + invert)
if (button->isNaive() && alt_index == 0) {
bool always_on = button->isNaive() && button->getVKey() == INVALID_VKEY && button->getInvert();
if (ImGui::Checkbox("Always On", &always_on)) {
if (always_on) {
button->setVKey(INVALID_VKEY);
button->setInvert(true);
} else {
button->setInvert(false);
}
dirty = true;
}
} }
// bat threshold // bat threshold