Skip to content

Commit 15552f3

Browse files
Daniel K. O. (dkosmari)Maschell
authored andcommitted
Allow empty combos.
1 parent 2fd26db commit 15552f3

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

source/ButtonComboInfo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ bool ButtonComboInfoIF::conflictsWith(const ButtonComboModule_ButtonComboOptions
9797
if ((mControllerMask & other.controllerMask) == 0) {
9898
return false;
9999
}
100+
101+
// No conflicts when either button combo is empty.
102+
if (!other.combo || !mCombo) {
103+
return false;
104+
}
105+
100106
if ((other.combo & mCombo) == mCombo || (other.combo & mCombo) == other.combo) {
101107
return true;
102108
}
@@ -141,4 +147,4 @@ int32_t ButtonComboInfoIF::ControllerTypeToChanIndex(const ButtonComboModule_Con
141147
}
142148

143149
return -1;
144-
}
150+
}

source/ButtonComboManager.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ std::optional<std::shared_ptr<ButtonComboInfoIF>> ButtonComboManager::CreateComb
289289
err = BUTTON_COMBO_MODULE_ERROR_INCOMPATIBLE_OPTIONS_VERSION;
290290
return std::nullopt;
291291
}
292-
if (options.buttonComboOptions.basicCombo.combo == 0 ||
293-
options.buttonComboOptions.basicCombo.controllerMask == BUTTON_COMBO_MODULE_CONTROLLER_NONE) {
294-
err = BUTTON_COMBO_MODULE_ERROR_INVALID_COMBO;
295-
return std::nullopt;
296-
}
297292
if (options.callbackOptions.callback == nullptr) {
298293
err = BUTTON_COMBO_MODULE_ERROR_INVALID_ARGUMENT;
299294
return std::nullopt;
@@ -303,7 +298,7 @@ std::optional<std::shared_ptr<ButtonComboInfoIF>> ButtonComboManager::CreateComb
303298
switch (options.buttonComboOptions.type) {
304299
case BUTTON_COMBO_MODULE_COMBO_TYPE_HOLD_OBSERVER:
305300
observer = true;
306-
__attribute__((fallthrough));
301+
[[fallthrough]];
307302
case BUTTON_COMBO_MODULE_COMBO_TYPE_HOLD: {
308303
if (options.buttonComboOptions.optionalHoldForXMs == 0) {
309304
err = BUTTON_COMBO_MODULE_ERROR_DURATION_MISSING;
@@ -320,7 +315,7 @@ std::optional<std::shared_ptr<ButtonComboInfoIF>> ButtonComboManager::CreateComb
320315
}
321316
case BUTTON_COMBO_MODULE_COMBO_TYPE_PRESS_DOWN_OBSERVER:
322317
observer = true;
323-
__attribute__((fallthrough));
318+
[[fallthrough]];
324319
case BUTTON_COMBO_MODULE_COMBO_TYPE_PRESS_DOWN: {
325320
err = BUTTON_COMBO_MODULE_ERROR_SUCCESS;
326321
return std::make_shared<ButtonComboInfoDown>(options.metaOptions.label,

0 commit comments

Comments
 (0)