2023-01-03 05:35:53 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <xinput.h>
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "taikoio/taikoio.h"
|
2023-07-11 05:21:36 +02:00
|
|
|
#include "taikoio/config.h"
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static bool taiko_io_coin = false;
|
|
|
|
static bool taiko_io_service = false;
|
|
|
|
static bool taiko_test_toggle = false;
|
2023-07-29 08:51:58 +02:00
|
|
|
static bool taiko_test_last_state = false;
|
2023-01-03 05:35:53 +01:00
|
|
|
static uint16_t taiko_coin_ct = 0;
|
|
|
|
static uint16_t taiko_service_ct = 0;
|
2023-07-11 05:21:36 +02:00
|
|
|
static struct taiko_input_config cfg;
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
uint16_t taiko_io_get_api_version(void)
|
|
|
|
{
|
|
|
|
return 0x0100;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT taiko_io_init(void)
|
|
|
|
{
|
|
|
|
dprintf("Taiko IO: Init\n");
|
2023-07-11 05:21:36 +02:00
|
|
|
taiko_io_config_load(&cfg, L".\\bananatools.ini");
|
2023-01-03 05:35:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2023-07-29 08:51:58 +02:00
|
|
|
void taiko_io_get_opbtns(uint8_t *opbtn)
|
2023-01-03 05:35:53 +01:00
|
|
|
{
|
2023-07-11 05:21:36 +02:00
|
|
|
if ((GetAsyncKeyState(cfg.test) & 0x8000)) {
|
2023-07-29 08:51:58 +02:00
|
|
|
if (!taiko_test_last_state) {
|
|
|
|
taiko_test_toggle = !taiko_test_toggle;
|
|
|
|
}
|
|
|
|
taiko_test_last_state = true;
|
|
|
|
} else {
|
|
|
|
taiko_test_last_state = false;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.service) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*opbtn |= TAIKO_IO_OPBTN_SERVICE;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.up) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*opbtn |= TAIKO_IO_OPBTN_UP;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.down) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*opbtn |= TAIKO_IO_OPBTN_DOWN;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.enter) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*opbtn |= TAIKO_IO_OPBTN_ENTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (taiko_test_toggle) {
|
|
|
|
*opbtn |= TAIKO_IO_OPBTN_TEST;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
2023-07-29 08:51:58 +02:00
|
|
|
}
|
2023-01-03 05:35:53 +01:00
|
|
|
|
2023-07-29 08:51:58 +02:00
|
|
|
void taiko_io_get_drum_analog(uint8_t *gamebtn)
|
|
|
|
{
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p1_rim_l) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P1_RIM_L;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p1_center_l) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P1_CENTER_L;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p1_center_r) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P1_CENTER_R;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p1_rim_r) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P1_RIM_R;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p2_rim_l) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P2_RIM_L;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p2_center_l) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P2_CENTER_L;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p2_center_r) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P2_CENTER_R;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
if (GetAsyncKeyState(cfg.p2_rim_r) & 0x8000) {
|
2023-07-29 08:51:58 +02:00
|
|
|
*gamebtn |= TAIKO_IO_P2_RIM_R;
|
2023-01-03 05:35:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void taiko_io_read_coin_counter(uint16_t *coins, uint16_t *services)
|
|
|
|
{
|
|
|
|
|
2023-07-29 08:51:58 +02:00
|
|
|
if (GetAsyncKeyState(cfg.coin) & 0x8000) {
|
2023-01-03 05:35:53 +01:00
|
|
|
if (!taiko_io_coin) {
|
|
|
|
taiko_io_coin = true;
|
|
|
|
taiko_coin_ct++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
taiko_io_coin = false;
|
|
|
|
}
|
|
|
|
|
2023-07-29 08:51:58 +02:00
|
|
|
if (GetAsyncKeyState(cfg.service) & 0x8000) {
|
2023-01-03 05:35:53 +01:00
|
|
|
if (!taiko_io_service) {
|
|
|
|
taiko_io_service = true;
|
|
|
|
taiko_service_ct++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
taiko_io_service = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*coins = taiko_coin_ct;
|
|
|
|
*services = taiko_service_ct;
|
|
|
|
}
|