2024-10-04 09:09:51 +02:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "board/usio.h"
|
|
|
|
|
|
|
|
#include "kizunahook/kizuna-dll.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
bool kizuna_io_coin = false;
|
|
|
|
uint16_t kizuna_io_coins = 0;
|
|
|
|
|
|
|
|
static HRESULT kizuna_usio_poll(void *ctx, struct usio_state *state);
|
|
|
|
|
|
|
|
static const struct usio_ops kizuna_usio_ops = {
|
|
|
|
.poll = kizuna_usio_poll,
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT kizuna_usio_hook_init(const struct usio_config *cfg)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
assert(kizuna_dll.init != NULL);
|
|
|
|
|
|
|
|
hr = usio_hook_init(cfg, &kizuna_usio_ops, NULL, NULL);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
dprintf("Kizuna USIO: Init\n");
|
|
|
|
|
|
|
|
return kizuna_dll.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT kizuna_usio_poll(void *ctx, struct usio_state *state)
|
|
|
|
{
|
|
|
|
uint8_t opbtn_out = 0;
|
|
|
|
uint8_t gamebtn_out = 0;
|
|
|
|
uint8_t x = 128;
|
|
|
|
uint8_t y = 128;
|
2024-10-04 15:55:53 +02:00
|
|
|
uint8_t z = 128;
|
|
|
|
uint8_t r = 128;
|
2024-10-04 09:09:51 +02:00
|
|
|
uint16_t coin_ct = 0;
|
|
|
|
uint16_t service_ct = 0;
|
|
|
|
|
|
|
|
kizuna_dll.get_opbtns(&opbtn_out);
|
|
|
|
kizuna_dll.get_analog(&x, &y);
|
|
|
|
kizuna_dll.read_coin_counter(&coin_ct, &service_ct);
|
|
|
|
kizuna_dll.get_gamebtns(&gamebtn_out);
|
|
|
|
|
|
|
|
state->op_btns = 0;
|
|
|
|
state->p1_btns = 0;
|
|
|
|
state->p2_btns = 0;
|
|
|
|
|
|
|
|
if (opbtn_out & 0x01) {
|
|
|
|
state->op_btns |= 0x80; // Test
|
|
|
|
}
|
|
|
|
if (opbtn_out & 0x02) {
|
|
|
|
state->p1_btns |= 0x40; // Service
|
|
|
|
}
|
|
|
|
if (opbtn_out & 0x04) {
|
|
|
|
state->p1_btns |= 0x20; // Up
|
|
|
|
}
|
|
|
|
if (opbtn_out & 0x08) {
|
|
|
|
state->p1_btns |= 0x10; // Down
|
|
|
|
}
|
|
|
|
if (opbtn_out & 0x10) {
|
|
|
|
state->p1_btns |= 0x02; // Enter
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gamebtn_out & 0x01) {
|
|
|
|
state->p1_btns |= 0x2000;
|
|
|
|
}
|
|
|
|
if (gamebtn_out & 0x02) {
|
|
|
|
state->p1_btns |= 0x1000;
|
|
|
|
}
|
|
|
|
if (gamebtn_out & 0x04) {
|
|
|
|
state->p1_btns |= 0x0800;
|
|
|
|
}
|
|
|
|
if (gamebtn_out & 0x08) {
|
|
|
|
state->p1_btns |= 0x4000;
|
|
|
|
}
|
|
|
|
if (gamebtn_out & 0x10) {
|
|
|
|
state->p1_btns |= 0x01;
|
|
|
|
}
|
|
|
|
if (gamebtn_out & 0x20) {
|
|
|
|
state->p1_btns |= 0x8000;
|
|
|
|
}
|
|
|
|
|
|
|
|
state->analog[0] = x << 8;
|
|
|
|
state->analog[1] = y << 8;
|
2024-10-04 15:55:53 +02:00
|
|
|
state->analog[2] = z << 8;
|
|
|
|
state->analog[3] = r << 8;
|
2024-10-04 09:09:51 +02:00
|
|
|
|
|
|
|
state->coins[0].current_coin_count = coin_ct;
|
|
|
|
state->service.current_coin_count = service_ct;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|