This commit is contained in:
bsongis
2015-06-18 19:10:05 +02:00
parent 81abf548a3
commit 98b23b348e
2 changed files with 15 additions and 6 deletions
+14 -6
View File
@@ -191,11 +191,10 @@ bool isLogicalSwitchAvailable(int index)
bool isSwitchAvailable(int swtch, SwitchContext context)
{
uint32_t index = switchInfo(abs(swtch)).quot;
bool negative = false;
if (swtch < 0) {
if (!IS_3POS(index))
return false;
negative = true;
if (swtch == -SWSRC_ON || swtch == -SWSRC_One) {
return false;
}
@@ -203,10 +202,19 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
}
if (swtch >= SWSRC_SA0 && swtch <= SWSRC_LAST_SWITCH) {
if (!SWITCH_EXISTS(index))
div_t swinfo = switchInfo(swtch);
if (!SWITCH_EXISTS(swinfo.quot)) {
return false;
if ((swtch-SWSRC_SA1)%3 == 0)
return IS_3POS(index);
}
if (!IS_3POS(swinfo.quot)) {
if (negative) {
return false;
}
if (IS_3POS_MIDDLE(swinfo.rem)) {
return false;
}
}
return true;
}
if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH && swtch <= SWSRC_LAST_MULTIPOS_SWITCH) {
+1
View File
@@ -732,6 +732,7 @@ PACK(typedef struct {
#define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE)
#define IS_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS)
#define IS_TOGGLE(x) (SWITCH_CONFIG(x) == SWITCH_TOGGLE)
#define IS_3POS_MIDDLE(x) ((x) == 1)
#define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !IS_TOGGLE(x))
#endif