forked from TeamTofuShop/segatools
Added wacca stub code
This commit is contained in:
25
mercuryio/config.c
Normal file
25
mercuryio/config.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mercuryio/config.h"
|
||||
|
||||
/*
|
||||
Wacca Default key binding
|
||||
*/
|
||||
|
||||
void mercury_io_config_load(
|
||||
struct mercury_io_config *cfg,
|
||||
const wchar_t *filename)
|
||||
{
|
||||
wchar_t key[16];
|
||||
int i;
|
||||
|
||||
assert(cfg != NULL);
|
||||
assert(filename != NULL);
|
||||
|
||||
cfg->vk_test = GetPrivateProfileIntW(L"io4", L"test", '1', filename);
|
||||
cfg->vk_service = GetPrivateProfileIntW(L"io4", L"service", '2', filename);
|
||||
}
|
17
mercuryio/config.h
Normal file
17
mercuryio/config.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct mercury_io_config {
|
||||
uint8_t vk_test;
|
||||
uint8_t vk_service;
|
||||
uint8_t vk_1p_btn[9];
|
||||
uint8_t vk_2p_btn[9];
|
||||
};
|
||||
|
||||
void mercury_io_config_load(
|
||||
struct mercury_io_config *cfg,
|
||||
const wchar_t *filename);
|
133
mercuryio/mercuryio.c
Normal file
133
mercuryio/mercuryio.c
Normal file
@ -0,0 +1,133 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mercuryio/mercuryio.h"
|
||||
#include "mercuryio/config.h"
|
||||
|
||||
static uint8_t mercury_opbtn;
|
||||
static uint16_t mercury_player1_btn;
|
||||
static uint16_t mercury_player2_btn;
|
||||
static struct mercury_io_config mercury_io_cfg;
|
||||
|
||||
uint16_t mercury_io_get_api_version(void)
|
||||
{
|
||||
return 0x0100;
|
||||
}
|
||||
|
||||
HRESULT mercury_io_init(void)
|
||||
{
|
||||
mercury_io_config_load(&mercury_io_cfg, L".\\segatools.ini");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT mercury_io_poll(void)
|
||||
{
|
||||
mercury_opbtn = 0;
|
||||
mercury_player1_btn = 0;
|
||||
mercury_player2_btn = 0;
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_test)) {
|
||||
mercury_opbtn |= MAI2_IO_OPBTN_TEST;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_service)) {
|
||||
mercury_opbtn |= MAI2_IO_OPBTN_SERVICE;
|
||||
}
|
||||
|
||||
//Player 1
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[0])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_1;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[1])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_2;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[2])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_3;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[3])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_4;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[4])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_5;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[5])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_6;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[6])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_7;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[7])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_8;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_1p_btn[8])) {
|
||||
mercury_player1_btn |= MAI2_IO_GAMEBTN_SELECT;
|
||||
}
|
||||
|
||||
//Player 2
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[0])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_1;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[1])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_2;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[2])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_3;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[3])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_4;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[4])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_5;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[5])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_6;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[6])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_7;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[7])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_8;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(mercury_io_cfg.vk_2p_btn[8])) {
|
||||
mercury_player2_btn |= MAI2_IO_GAMEBTN_SELECT;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void mercury_io_get_opbtns(uint8_t *opbtn)
|
||||
{
|
||||
if (opbtn != NULL) {
|
||||
*opbtn = mercury_opbtn;
|
||||
}
|
||||
}
|
||||
|
||||
void mercury_io_get_gamebtns(uint16_t *player1, uint16_t *player2)
|
||||
{
|
||||
if (player1 != NULL) {
|
||||
*player1 = mercury_player1_btn;
|
||||
}
|
||||
|
||||
if (player2 != NULL ){
|
||||
*player2 = mercury_player2_btn;
|
||||
}
|
||||
}
|
67
mercuryio/mercuryio.h
Normal file
67
mercuryio/mercuryio.h
Normal file
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum {
|
||||
MAI2_IO_OPBTN_TEST = 0x01,
|
||||
MAI2_IO_OPBTN_SERVICE = 0x02,
|
||||
};
|
||||
|
||||
enum {
|
||||
MAI2_IO_GAMEBTN_1 = 0x01,
|
||||
MAI2_IO_GAMEBTN_2 = 0x02,
|
||||
MAI2_IO_GAMEBTN_3 = 0x04,
|
||||
MAI2_IO_GAMEBTN_4 = 0x08,
|
||||
MAI2_IO_GAMEBTN_5 = 0x10,
|
||||
MAI2_IO_GAMEBTN_6 = 0x20,
|
||||
MAI2_IO_GAMEBTN_7 = 0x40,
|
||||
MAI2_IO_GAMEBTN_8 = 0x80,
|
||||
MAI2_IO_GAMEBTN_SELECT = 0x100,
|
||||
};
|
||||
|
||||
/* Get the version of the Wacca IO API that this DLL supports. This
|
||||
function should return a positive 16-bit integer, where the high byte is
|
||||
the major version and the low byte is the minor version (as defined by the
|
||||
Semantic Versioning standard).
|
||||
|
||||
The latest API version as of this writing is 0x0100. */
|
||||
|
||||
uint16_t mercury_io_get_api_version(void);
|
||||
|
||||
/* Initialize the IO DLL. This is the second function that will be called on
|
||||
your DLL, after mercury_io_get_api_version.
|
||||
|
||||
All subsequent calls to this API may originate from arbitrary threads.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
HRESULT mercury_io_init(void);
|
||||
|
||||
/* Send any queued outputs (of which there are currently none, though this may
|
||||
change in subsequent API versions) and retrieve any new inputs.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
HRESULT mercury_io_poll(void);
|
||||
|
||||
/* Get the state of the cabinet's operator buttons as of the last poll. See
|
||||
MAI2_IO_OPBTN enum above: this contains bit mask definitions for button
|
||||
states returned in *opbtn. All buttons are active-high.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
void mercury_io_get_opbtns(uint8_t *opbtn);
|
||||
|
||||
/* Get the state of the cabinet's gameplay buttons as of the last poll. See
|
||||
MAI2_IO_GAMEBTN enum above for bit mask definitions. Inputs are split into
|
||||
a left hand side set of inputs and a right hand side set of inputs: the bit
|
||||
mappings are the same in both cases.
|
||||
|
||||
All buttons are active-high, even though some buttons' electrical signals
|
||||
on a real cabinet are active-low.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
void mercury_io_get_gamebtns(uint16_t *player1, uint16_t *player2);
|
13
mercuryio/meson.build
Normal file
13
mercuryio/meson.build
Normal file
@ -0,0 +1,13 @@
|
||||
mercuryio_lib = static_library(
|
||||
'mercuryio',
|
||||
name_prefix : '',
|
||||
include_directories : inc,
|
||||
implicit_include_directories : false,
|
||||
c_pch : '../precompiled.h',
|
||||
sources : [
|
||||
'mercuryio.c',
|
||||
'mercuryio.h',
|
||||
'config.c',
|
||||
'config.h',
|
||||
],
|
||||
)
|
Reference in New Issue
Block a user