1
0
mirror of https://gitea.tendokyu.moe/Dniel97/segatools.git synced 2024-12-03 17:07:16 +01:00
segatools-dniel97/idacio/shifter.c

33 lines
622 B
C
Raw Normal View History

2023-04-23 16:13:51 +02:00
#include <stdbool.h>
#include <stdint.h>
2023-06-29 11:24:34 +02:00
#include "idacio/shifter.h"
2023-04-23 16:13:51 +02:00
static bool idac_shifter_shifting;
static uint8_t idac_shifter_gear;
2023-06-29 11:24:34 +02:00
void idac_shifter_set(uint8_t gear)
2023-04-23 16:13:51 +02:00
{
2023-06-29 11:24:34 +02:00
idac_shifter_gear = gear;
2023-04-23 16:13:51 +02: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;
}