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;
|
|
|
|
static struct tekken_najv4_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;
|
|
|
|
}
|
|
|
|
|
2023-11-12 11:13:44 +01:00
|
|
|
HRESULT tekken_io_jvs_poll(uint8_t *opbtn, uint16_t *gamebtn)
|
2023-09-18 10:15:27 +02:00
|
|
|
{
|
|
|
|
*opbtn = 0;
|
2023-11-12 11:13:44 +01:00
|
|
|
*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) {
|
2023-11-12 11:13:44 +01:00
|
|
|
*gamebtn |= TEKKEN_IO_GAMEBTN_P1_UP;
|
2023-09-18 10:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(najv4_cfg.down) & 0x8000) {
|
2023-11-12 11:13:44 +01:00
|
|
|
*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
|
|
|
}
|
|
|
|
|
2023-11-12 11:13:44 +01: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)
|
|
|
|
{
|
2023-11-12 11:13:44 +01:00
|
|
|
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;
|
|
|
|
}
|