segatools2/idacio/shifter.c

33 lines
622 B
C
Raw Normal View History

2023-04-23 14:13:51 +00:00
#include <stdbool.h>
#include <stdint.h>
2023-06-29 09:24:34 +00:00
#include "idacio/shifter.h"
2023-04-23 14:13:51 +00:00
static bool idac_shifter_shifting;
static uint8_t idac_shifter_gear;
2023-06-29 09:24:34 +00:00
void idac_shifter_set(uint8_t gear)
2023-04-23 14:13:51 +00:00
{
2023-06-29 09:24:34 +00:00
idac_shifter_gear = gear;
2023-04-23 14:13:51 +00:00
}
void idac_shifter_update(bool shift_dn, bool shift_up)
{
if (!idac_shifter_shifting) {
if (shift_dn && idac_shifter_gear > 0) {
idac_shifter_gear--;
}
if (shift_up && idac_shifter_gear < 6) {
idac_shifter_gear++;
}
}
idac_shifter_shifting = shift_dn || shift_up;
}
uint8_t idac_shifter_current_gear(void)
{
return idac_shifter_gear;
}