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