forked from Hay1tsme/segatools
cardmaker: hook, touch screen hook added
Thanks @domeori https://dev.s-ul.net/domeori/segatools/-/tree/mr-imports
This commit is contained in:
54
cmio/cmio.c
Normal file
54
cmio/cmio.c
Normal file
@ -0,0 +1,54 @@
|
||||
#include <windows.h>
|
||||
#include <xinput.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cmio/cmio.h"
|
||||
#include "cmio/config.h"
|
||||
|
||||
static uint8_t cm_opbtn;
|
||||
static struct cm_io_config cm_io_cfg;
|
||||
static bool cm_io_coin;
|
||||
|
||||
uint16_t cm_io_get_api_version(void)
|
||||
{
|
||||
return 0x0100;
|
||||
}
|
||||
|
||||
HRESULT cm_io_init(void)
|
||||
{
|
||||
cm_io_config_load(&cm_io_cfg, L".\\segatools.ini");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT cm_io_poll(void)
|
||||
{
|
||||
cm_opbtn = 0;
|
||||
|
||||
if (GetAsyncKeyState(cm_io_cfg.vk_test) & 0x8000) {
|
||||
cm_opbtn |= CM_IO_OPBTN_TEST;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(cm_io_cfg.vk_service) & 0x8000) {
|
||||
cm_opbtn |= CM_IO_OPBTN_SERVICE;
|
||||
}
|
||||
|
||||
if (GetAsyncKeyState(cm_io_cfg.vk_coin) & 0x8000) {
|
||||
if (!cm_io_coin) {
|
||||
cm_io_coin = true;
|
||||
cm_opbtn |= CM_IO_OPBTN_COIN;
|
||||
}
|
||||
} else {
|
||||
cm_io_coin = false;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void cm_io_get_opbtns(uint8_t *opbtn)
|
||||
{
|
||||
if (opbtn != NULL) {
|
||||
*opbtn = cm_opbtn;
|
||||
}
|
||||
}
|
44
cmio/cmio.h
Normal file
44
cmio/cmio.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum {
|
||||
CM_IO_OPBTN_TEST = 0x01,
|
||||
CM_IO_OPBTN_SERVICE = 0x02,
|
||||
CM_IO_OPBTN_COIN = 0x04,
|
||||
};
|
||||
|
||||
/* Get the version of the CardMaker 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 cm_io_get_api_version(void);
|
||||
|
||||
/* Initialize the IO DLL. This is the second function that will be called on
|
||||
your DLL, after cm_io_get_api_version.
|
||||
|
||||
All subsequent calls to this API may originate from arbitrary threads.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
HRESULT cm_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 cm_io_poll(void);
|
||||
|
||||
/* Get the state of the cabinet's operator buttons as of the last poll. See
|
||||
cm_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 cm_io_get_opbtns(uint8_t *opbtn);
|
22
cmio/config.c
Normal file
22
cmio/config.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "cmio/config.h"
|
||||
|
||||
void cm_io_config_load(
|
||||
struct cm_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);
|
||||
cfg->vk_coin = GetPrivateProfileIntW(L"io4", L"coin", '3', filename);
|
||||
}
|
16
cmio/config.h
Normal file
16
cmio/config.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct cm_io_config {
|
||||
uint8_t vk_test;
|
||||
uint8_t vk_service;
|
||||
uint8_t vk_coin;
|
||||
};
|
||||
|
||||
void cm_io_config_load(
|
||||
struct cm_io_config *cfg,
|
||||
const wchar_t *filename);
|
13
cmio/meson.build
Normal file
13
cmio/meson.build
Normal file
@ -0,0 +1,13 @@
|
||||
cmio_lib = static_library(
|
||||
'cmio',
|
||||
name_prefix : '',
|
||||
include_directories : inc,
|
||||
implicit_include_directories : false,
|
||||
c_pch : '../precompiled.h',
|
||||
sources : [
|
||||
'cmio.c',
|
||||
'cmio.h',
|
||||
'config.c',
|
||||
'config.h',
|
||||
],
|
||||
)
|
Reference in New Issue
Block a user