bananatools/tekkenio/tekkenio.c

92 lines
2.1 KiB
C

#include <windows.h>
#include <xinput.h>
#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include "tekkenio/tekkenio.h"
#include "tekkenio/config.h"
#include "util/dprintf.h"
static bool tekken_io_coin = false;
static bool tekken_test_toggle = false;
static uint16_t tekken_coin_ct = 0;
static struct tekken_jvs_config najv4_cfg;
uint16_t tekken_io_get_api_version(void)
{
return 0x0100;
}
HRESULT tekken_io_jvs_init(void)
{
dprintf("Tekken IO: JVS Init\n");
tekken_io_najv4_config_load(&najv4_cfg, L".\\bananatools.ini");
return S_OK;
}
HRESULT tekken_io_jvs_poll(uint8_t *opbtn, uint16_t *gamebtn)
{
*opbtn = 0;
*gamebtn = 0;
if ((GetAsyncKeyState(najv4_cfg.test) & 0x8000)) {
*opbtn |= TEKKEN_IO_OPBTN_TEST;
}
if (GetAsyncKeyState(najv4_cfg.service) & 0x8000) {
*opbtn |= TEKKEN_IO_OPBTN_SERVICE;
}
if (GetAsyncKeyState(najv4_cfg.up) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_UP;
}
if (GetAsyncKeyState(najv4_cfg.down) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_DOWN;
}
if (GetAsyncKeyState(najv4_cfg.left) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_LEFT;
}
if (GetAsyncKeyState(najv4_cfg.right) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_RIGHT;
}
if (GetAsyncKeyState(najv4_cfg.start) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_START;
}
if (GetAsyncKeyState(najv4_cfg.p1b1) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_BUTTON1;
}
if (GetAsyncKeyState(najv4_cfg.p1b2) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_BUTTON2;
}
if (GetAsyncKeyState(najv4_cfg.p1b3) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_BUTTON3;
}
if (GetAsyncKeyState(najv4_cfg.p1b4) & 0x8000) {
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_BUTTON4;
}
return S_OK;
}
void tekken_io_jvs_read_coin_counter(uint16_t *coins)
{
if (GetAsyncKeyState(najv4_cfg.coin) & 0x8000) {
if (!tekken_io_coin) {
tekken_io_coin = true;
tekken_coin_ct++;
}
} else {
tekken_io_coin = false;
}
*coins = tekken_coin_ct;
}