taitools/ll3io/ll3io.c

64 lines
1.3 KiB
C
Raw Normal View History

2024-02-17 21:46:23 +00:00
#include <windows.h>
#include <xinput.h>
#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include "ll3io/ll3io.h"
#include "ll3io/config.h"
#include "util/dprintf.h"
static bool ll3_io_coin = false;
static bool ll3_io_service = false;
static uint16_t ll3_coin_ct = 0;
static uint16_t ll3_service_ct = 0;
static struct ll3_input_config cfg;
uint16_t ll3_io_get_api_version(void)
{
return 0x0100;
}
HRESULT ll3_io_init(void)
{
dprintf("ll3 IO: Init\n");
ll3_io_config_load(&cfg, L".\\bananatools.ini");
return S_OK;
}
void ll3_io_get_btns(uint8_t *btn, uint8_t *stick)
{
if (GetAsyncKeyState(cfg.test) & 0x8000) {
*btn |= ll3_BTN_TEST;
}
if (GetAsyncKeyState(cfg.service) & 0x8000) {
*btn |= ll3_BTN_SERVICE;
}
}
void ll3_io_read_coin_counter(uint16_t *coins, uint16_t *services)
{
if (GetAsyncKeyState(cfg.coin) & 0x8000) {
if (!ll3_io_coin) {
ll3_io_coin = true;
ll3_coin_ct++;
}
} else {
ll3_io_coin = false;
}
if (GetAsyncKeyState(cfg.service) & 0x8000) {
if (!ll3_io_service) {
ll3_io_service = true;
ll3_service_ct++;
}
} else {
ll3_io_service = false;
}
*coins = ll3_coin_ct;
*services = ll3_service_ct;
}