bananatools/taikoio/taikoio.c

128 lines
2.6 KiB
C

#include <windows.h>
#include <xinput.h>
#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include "taikoio/taikoio.h"
#include "util/dprintf.h"
static bool taiko_io_coin = false;
static bool taiko_io_service = false;
static bool taiko_test_toggle = false;
static uint8_t taiko_opbtn = 0;
static uint16_t taiko_gamebtn = 0;
static uint16_t taiko_coin_ct = 0;
static uint16_t taiko_service_ct = 0;
uint16_t taiko_io_get_api_version(void)
{
return 0x0100;
}
HRESULT taiko_io_init(void)
{
dprintf("Taiko IO: Init\n");
return S_OK;
}
HRESULT taiko_io_poll(void)
{
taiko_opbtn = 0;
taiko_gamebtn = 0;
if ((GetAsyncKeyState(VK_HOME) & 0x8000)) {
taiko_opbtn |= TAIKO_IO_OPBTN_TEST;
}
if (GetAsyncKeyState(VK_DELETE) & 0x8000) {
taiko_opbtn |= TAIKO_IO_OPBTN_SERVICE;
}
if (GetAsyncKeyState(VK_UP) & 0x8000) {
taiko_opbtn |= TAIKO_IO_OPBTN_UP;
}
if (GetAsyncKeyState(VK_DOWN) & 0x8000) {
taiko_opbtn |= TAIKO_IO_OPBTN_DOWN;
}
if (GetAsyncKeyState(VK_RETURN) & 0x8000) {
taiko_opbtn |= TAIKO_IO_OPBTN_ENTER;
}
if (GetAsyncKeyState('Z') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P1_RIM_L;
}
if (GetAsyncKeyState('X') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P1_CENTER_L;
}
if (GetAsyncKeyState('C') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P1_CENTER_R;
}
if (GetAsyncKeyState('V') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P1_RIM_R;
}
if (GetAsyncKeyState('U') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P2_RIM_L;
}
if (GetAsyncKeyState('I') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P2_CENTER_L;
}
if (GetAsyncKeyState('O') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P2_CENTER_R;
}
if (GetAsyncKeyState('P') & 0x8000) {
taiko_gamebtn |= TAIKO_IO_P2_RIM_R;
}
return S_OK;
}
void taiko_io_get_opbtns(uint8_t *opbtn)
{
if (opbtn != NULL) {
*opbtn = taiko_opbtn;
}
}
void taiko_io_get_gamebtns(uint8_t *gamebtn)
{
if (gamebtn != NULL) {
*gamebtn = taiko_gamebtn;
}
}
void taiko_io_read_coin_counter(uint16_t *coins, uint16_t *services)
{
if (GetAsyncKeyState(VK_INSERT) & 0x8000) {
if (!taiko_io_coin) {
taiko_io_coin = true;
taiko_coin_ct++;
}
} else {
taiko_io_coin = false;
}
if (GetAsyncKeyState(VK_DELETE) & 0x8000) {
if (!taiko_io_service) {
taiko_io_service = true;
taiko_service_ct++;
}
} else {
taiko_io_service = false;
}
*coins = taiko_coin_ct;
*services = taiko_service_ct;
}