mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
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:
@@ -306,7 +306,10 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
|
||||
std::string vKeyString = fmt::format("{:#x}", vKey);
|
||||
|
||||
// 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 "";
|
||||
}
|
||||
|
||||
|
||||
@@ -2003,6 +2003,7 @@ namespace overlay::windows {
|
||||
int vKey = button->getVKey();
|
||||
if (ImGui::InputInt(button->isNaive() ? "Virtual Key" : "Index", &vKey, 1, 1)) {
|
||||
button->setVKey(vKey);
|
||||
button->setInvert(false);
|
||||
}
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()) {
|
||||
dirty = true;
|
||||
@@ -2070,11 +2071,27 @@ namespace overlay::windows {
|
||||
"This setting will add noticable input lag.");
|
||||
}
|
||||
|
||||
// invert
|
||||
bool invert = button->getInvert();
|
||||
if (ImGui::Checkbox("Invert Resulting Value", &invert)) {
|
||||
button->setInvert(invert);
|
||||
dirty = true;
|
||||
// invert (widget hidden for naive + 0xff)
|
||||
if (!(button->isNaive() && button->getVKey() == INVALID_VKEY)) {
|
||||
bool invert = button->getInvert();
|
||||
if (ImGui::Checkbox("Invert Resulting Value", &invert)) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user