divaio: Wire up input config

This commit is contained in:
9c2a94eb294ac460ccbd019f5f01f45fffff7759 2020-06-06 15:10:43 -04:00 committed by e008852e53e8552101c3cb4b1c29fdf09b83b3ac
parent 415b06af7c
commit 1e2788795c

View File

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "divaio/divaio.h" #include "divaio/divaio.h"
#include "divaio/config.h"
static unsigned int __stdcall diva_io_slider_thread_proc(void *ctx); static unsigned int __stdcall diva_io_slider_thread_proc(void *ctx);
@ -13,32 +14,33 @@ static bool diva_io_coin;
static uint16_t diva_io_coins; static uint16_t diva_io_coins;
static HANDLE diva_io_slider_thread; static HANDLE diva_io_slider_thread;
static bool diva_io_slider_stop_flag; static bool diva_io_slider_stop_flag;
static struct diva_io_config diva_io_cfg;
HRESULT diva_io_jvs_init(void) HRESULT diva_io_jvs_init(void)
{ {
diva_io_config_load(&diva_io_cfg, L".\\segatools.ini");
return S_OK; return S_OK;
} }
void diva_io_jvs_poll(uint8_t *opbtn_out, uint8_t *gamebtn_out) void diva_io_jvs_poll(uint8_t *opbtn_out, uint8_t *gamebtn_out)
{ {
static const int opbtn_vk[] = { '1', '2' };
static const int gamebtn_vk[] = { 'L', 'J', 'F', 'S', ' ' };
uint8_t opbtn; uint8_t opbtn;
uint8_t gamebtn; uint8_t gamebtn;
size_t i; size_t i;
opbtn = 0; opbtn = 0;
gamebtn = 0;
for (i = 0 ; i < _countof(opbtn_vk) ; i++) { if (GetAsyncKeyState(diva_io_cfg.vk_test) & 0x8000) {
if (GetAsyncKeyState(opbtn_vk[i]) & 0x8000) { opbtn |= 1;
opbtn |= 1 << i;
}
} }
for (i = 0 ; i < _countof(gamebtn_vk) ; i++) { if (GetAsyncKeyState(diva_io_cfg.vk_service) & 0x8000) {
if (GetAsyncKeyState(gamebtn_vk[i]) & 0x8000) { opbtn |= 2;
}
for (i = 0 ; i < _countof(diva_io_cfg.vk_buttons) ; i++) {
if (GetAsyncKeyState(diva_io_cfg.vk_buttons[i]) & 0x8000) {
gamebtn |= 1 << i; gamebtn |= 1 << i;
} }
} }
@ -53,7 +55,7 @@ void diva_io_jvs_read_coin_counter(uint16_t *out)
return; return;
} }
if (GetAsyncKeyState('3')) { if (GetAsyncKeyState(diva_io_cfg.vk_coin) & 0x8000) {
if (!diva_io_coin) { if (!diva_io_coin) {
diva_io_coin = true; diva_io_coin = true;
diva_io_coins++; diva_io_coins++;
@ -103,10 +105,6 @@ void diva_io_slider_set_leds(const uint8_t *rgb)
static unsigned int __stdcall diva_io_slider_thread_proc(void *ctx) static unsigned int __stdcall diva_io_slider_thread_proc(void *ctx)
{ {
static const int keys[] = {
'Q', 'W', 'E', 'R', 'U', 'I', 'O', 'P',
};
diva_io_slider_callback_t callback; diva_io_slider_callback_t callback;
uint8_t pressure_val; uint8_t pressure_val;
uint8_t pressure[32]; uint8_t pressure[32];
@ -116,7 +114,7 @@ static unsigned int __stdcall diva_io_slider_thread_proc(void *ctx)
while (!diva_io_slider_stop_flag) { while (!diva_io_slider_stop_flag) {
for (i = 0 ; i < 8 ; i++) { for (i = 0 ; i < 8 ; i++) {
if(GetAsyncKeyState(keys[i]) & 0x8000) { if (GetAsyncKeyState(diva_io_cfg.vk_slider[i]) & 0x8000) {
pressure_val = 20; pressure_val = 20;
} else { } else {
pressure_val = 0; pressure_val = 0;