implement hitbox compatible SOCD.
This commit is contained in:
@@ -145,68 +145,63 @@ void loop()
|
||||
|
||||
for (int i=0; i<4; i++){
|
||||
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){
|
||||
// add arrow to the tail of linked list
|
||||
arrowTable[i].older = newestArrow->older;
|
||||
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));
|
||||
if(arrowTable[1].current == 0){
|
||||
if(arrowTable[3].current == 0){
|
||||
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));
|
||||
}
|
||||
else{
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP));
|
||||
}
|
||||
else { // Hat::RIGHT
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(newestYArrow.older->arrowSymbol == Hat::CENTER){
|
||||
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
|
||||
}
|
||||
else { // Hat::RIGHT
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::RIGHT));
|
||||
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));
|
||||
}
|
||||
else{
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM));
|
||||
}
|
||||
else { // Hat::RIGHT
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_RIGHT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//SwitchControlLibrary().MoveHat(static_cast<uint8_t>(newestArrow.older->arrowSymbol));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user