This also improves map_object parsing code. There are still unhandled issues in the parser output related to quirks in the input data.
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include <cstdint>
|
|
|
|
#include "smpc.h"
|
|
|
|
#include "input.hpp"
|
|
#include "common/intback.hpp"
|
|
|
|
static inline void
|
|
input_count(count_flop_t& button, const uint32_t input, const uint32_t mask)
|
|
{
|
|
if ((input & mask) == 0) {
|
|
if (button.count < input_debounce)
|
|
button.count += 1;
|
|
else
|
|
button.das += 1;
|
|
} else {
|
|
if (button.count == 0) {
|
|
button.flop = 0;
|
|
button.das = 0;
|
|
button.repeat = 0;
|
|
}
|
|
else if (button.count > 0)
|
|
button.count -= 1;
|
|
}
|
|
}
|
|
|
|
input_t input = { 0 };
|
|
|
|
void digital_callback(uint8_t fsm_state, uint8_t data)
|
|
{
|
|
switch (fsm_state) {
|
|
case intback::DATA1:
|
|
input_count(input.right, data, DIGITAL__1__RIGHT);
|
|
input_count(input.left, data, DIGITAL__1__LEFT);
|
|
input_count(input.down, data, DIGITAL__1__DOWN);
|
|
input_count(input.up, data, DIGITAL__1__UP);
|
|
input_count(input.start, data, DIGITAL__1__START);
|
|
input_count(input.a, data, DIGITAL__1__A);
|
|
input_count(input.c, data, DIGITAL__1__C);
|
|
input_count(input.b, data, DIGITAL__1__B);
|
|
break;
|
|
case intback::DATA2:
|
|
input_count(input.r, data, DIGITAL__2__R);
|
|
input_count(input.x, data, DIGITAL__2__X);
|
|
input_count(input.y, data, DIGITAL__2__Y);
|
|
input_count(input.z, data, DIGITAL__2__Z);
|
|
input_count(input.l, data, DIGITAL__2__L);
|
|
break;
|
|
default: break;
|
|
}
|
|
}
|