mirror of
https://gitea.tendokyu.moe/TeamTofuShop/taitools.git
synced 2026-09-22 22:28:06 +03:00
119 lines
2.2 KiB
C
119 lines
2.2 KiB
C
#include <windows.h>
|
|
#include <assert.h>
|
|
|
|
#include "jvs/jvs-bus.h"
|
|
#include "idmac/fastio.h"
|
|
#include "board/io3.h"
|
|
|
|
#include "sivahook/fastio.h"
|
|
#include "sivahook/siva-dll.h"
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
static uint16_t coins;
|
|
static uint16_t services;
|
|
|
|
static void siva_fastio_digital_read(void *ctx, uint32_t *out);
|
|
static void siva_fastio_coin_read(void *ctx, uint8_t slot_no, uint32_t *out);
|
|
|
|
HRESULT siva_fastio_init(struct fastio_node *out)
|
|
{
|
|
HRESULT hr;
|
|
|
|
assert(out != NULL);
|
|
|
|
out->digital_in = siva_fastio_digital_read;
|
|
out->coins_in = siva_fastio_coin_read;
|
|
|
|
dprintf("Siva Nesica Fastio: Init\n");
|
|
|
|
siva_dll.init();
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
static void siva_fastio_digital_read(void *ctx, uint32_t *out)
|
|
{
|
|
uint8_t btn = 0;
|
|
uint8_t stick = 0;
|
|
*out = 0;
|
|
|
|
assert(siva_dll.get_btns != NULL);
|
|
|
|
siva_dll.get_btns(&btn, &stick);
|
|
|
|
if (btn & BTN_TEST) {
|
|
*out |= SIVA_SWITCH_SYS_TEST;
|
|
}
|
|
|
|
if (btn & BTN_SERVICE) {
|
|
*out |= SIVA_SWITCH_SYS_SERVICE;
|
|
}
|
|
|
|
if (btn & BTN_SELECT) {
|
|
*out |= SIVA_SWITCH_SYS_SELECT;
|
|
}
|
|
|
|
if (btn & BTN_ENTER) {
|
|
*out |= SIVA_SWITCH_SYS_ENTER;
|
|
}
|
|
|
|
if (btn & BTN_LEFT) {
|
|
*out |= SIVA_SWITCH_LEFT_BUTTON;
|
|
}
|
|
|
|
if (btn & BTN_RIGHT) {
|
|
*out |= SIVA_SWITCH_RIGHT_BUTTON;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_UP) {
|
|
*out |= SIVA_SWITCH_LEFT_UP;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_DOWN) {
|
|
*out |= SIVA_SWITCH_LEFT_DOWN;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_LEFT) {
|
|
*out |= SIVA_SWITCH_LEFT_LEFT;
|
|
}
|
|
|
|
if (stick & STICK_LEFT_RIGHT) {
|
|
*out |= SIVA_SWITCH_LEFT_RIGHT;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_UP) {
|
|
*out |= SIVA_SWITCH_RIGHT_UP;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_DOWN) {
|
|
*out |= SIVA_SWITCH_RIGHT_DOWN;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_LEFT) {
|
|
*out |= SIVA_SWITCH_RIGHT_LEFT;
|
|
}
|
|
|
|
if (stick & STICK_RIGHT_RIGHT) {
|
|
*out |= SIVA_SWITCH_RIGHT_RIGHT;
|
|
}
|
|
}
|
|
|
|
static void siva_fastio_coin_read(void *ctx, uint8_t slot_no, uint32_t *out)
|
|
{
|
|
uint16_t coin = 0;
|
|
uint16_t service = 0;
|
|
|
|
assert(siva_dll.get_btns != NULL);
|
|
|
|
if (slot_no != 1) {
|
|
*out = 0;
|
|
return;
|
|
}
|
|
|
|
siva_dll.read_coin_counter(&coin, &service);
|
|
|
|
*out += coin;
|
|
*out += service;
|
|
}
|