1
0
mirror of synced 2024-12-18 07:05:52 +01:00
bananatools/tekkenio/tekkenio.c

92 lines
2.1 KiB
C
Raw Normal View History

2023-09-18 10:15:27 +02:00
#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;
2024-06-18 06:28:58 +02:00
static struct tekken_jvs_config najv4_cfg;
2023-09-18 10:15:27 +02:00
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)
2023-09-18 10:15:27 +02:00
{
*opbtn = 0;
*gamebtn = 0;
2023-09-18 10:15:27 +02:00
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;
2023-09-18 10:15:27 +02:00
}
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;
2023-09-18 10:15:27 +02:00
}
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;
2023-09-18 10:15:27 +02:00
}
return S_OK;
}
void tekken_io_jvs_read_coin_counter(uint16_t *coins)
{
if (GetAsyncKeyState(najv4_cfg.coin) & 0x8000) {
2023-09-18 10:15:27 +02:00
if (!tekken_io_coin) {
tekken_io_coin = true;
tekken_coin_ct++;
}
} else {
tekken_io_coin = false;
}
*coins = tekken_coin_ct;
}