implement hitbox compatible SOCD.

This commit is contained in:
2020-09-18 22:17:12 +09:00
parent 20a25ecf26
commit 9454fdc54e

View File

@@ -145,68 +145,63 @@ void loop()
for (int i=0; i<4; i++){ for (int i=0; i<4; i++){
arrowTable[i].current = digitalRead(arrowTable[i].pinNumber); arrowTable[i].current = digitalRead(arrowTable[i].pinNumber);
struct arrow *newestArrow;
if(i % 2 == 0){ // Y axis
newestArrow = &newestYArrow;
}
else { // X axis
newestArrow = &newestXArrow;
} }
if(arrowTable[i].prev==1 && arrowTable[i].current==0){ if(arrowTable[1].current == 0){
// add arrow to the tail of linked list if(arrowTable[3].current == 0){
arrowTable[i].older = newestArrow->older; if(arrowTable[0].current == 0){
arrowTable[i].newer = newestArrow;
newestArrow->older->newer = &(arrowTable[i]);
newestArrow->older = &(arrowTable[i]);
}
else if (arrowTable[i].prev==0 && arrowTable[i].current==1){
arrowTable[i].newer->older = arrowTable[i].older;
arrowTable[i].older->newer = arrowTable[i].newer;
arrowTable[i].newer = NULL;
arrowTable[i].older = NULL;
}
arrowTable[i].prev = arrowTable[i].current;
}
if(newestYArrow.older->arrowSymbol == Hat::TOP){
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_LEFT));
}
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP)); SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP));
} }
else { // Hat::RIGHT else{
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_RIGHT)); if(arrowTable[2].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM));
} }
} else{
if(newestYArrow.older->arrowSymbol == Hat::CENTER){
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::LEFT));
}
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER)); SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
} }
else { // Hat::RIGHT }
}
else{
if(arrowTable[0].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_LEFT));
}
else{
if(arrowTable[2].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_LEFT));
}
else{
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::LEFT));
}
}
}
}
else{
if(arrowTable[3].current == 0){
if(arrowTable[0].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_RIGHT));
}
else{
if(arrowTable[2].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_RIGHT));
}
else{
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::RIGHT)); SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::RIGHT));
} }
} }
if(newestYArrow.older->arrowSymbol == Hat::BOTTOM){
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_LEFT));
} }
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) { else{
if(arrowTable[0].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP));
}
else{
if(arrowTable[2].current == 0){
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM)); SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM));
} }
else { // Hat::RIGHT else{
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_RIGHT)); SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
}
}
} }
} }
//SwitchControlLibrary().MoveHat(static_cast<uint8_t>(newestArrow.older->arrowSymbol));
} }