siva: remove touch hook, work on moving from sega jvs to taito fastio

This commit is contained in:
Hay1tsme
2024-12-23 02:13:17 -05:00
parent 4437716bd0
commit 127d93b052
18 changed files with 140 additions and 107 deletions
-7
View File
@@ -2,13 +2,6 @@ $(BUILD_DIR_ZIP)/siva.zip:
$(V)echo ... $@
$(V)mkdir -p $(BUILD_DIR_ZIP)/siva
$(V)mkdir -p $(BUILD_DIR_ZIP)/siva/cert
$(V)cp $(BUILD_DIR_32)/subprojects/capnhook/inject/inject.exe \
$(BUILD_DIR_32)/sivahook/sivahook.dll \
$(BUILD_DIR_ZIP)/siva
$(V)mv $(BUILD_DIR_ZIP)/siva/inject.exe \
$(BUILD_DIR_ZIP)/siva/inject_32.exe
$(V)mv $(BUILD_DIR_ZIP)/siva/sivahook.dll \
$(BUILD_DIR_ZIP)/siva/sivahook_32.dll
$(V)cp $(BUILD_DIR_64)/subprojects/capnhook/inject/inject.exe \
$(BUILD_DIR_64)/sivahook/sivahook.dll \
$(BUILD_DIR_64)/idmac_stub/iDmacDrv.dll \
+1 -2
View File
@@ -172,8 +172,7 @@ The final octet of the default gateway's IP address on the virtualized subnet.
Default: `01:02:03:04:05:06`
The MAC address of the virtualized Ethernet adapter. The exact value shouldn't
ever matter.
The MAC address of the virtualized Ethernet adapter. Used in nesica auth.
## `[vfs]`
+6
View File
@@ -0,0 +1,6 @@
#include "idmac/fastio.h"
HRESULT fastio_hook_init(fastio_provider_t main, fastio_provider_t sub)
{
return S_OK;
}
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#include <windows.h>
#include <stdint.h>
struct fastio_node {
struct fastio_node *next;
// Unlike JVS, FastIO comms are done on the game side through
// DMA register reads and writes, meaning we need to have
// indivitual functions here instead of just "transact"
void (*digital_in)(uint16_t *out); // Digital button inputs
void (*analog_in)(uint16_t *out); // Analog stick inputs (WIP)
void (*coins_in)(uint8_t slot, uint16_t *out); // Number of unprocessed coins
void (*digital_out)(uint16_t channel, uint16_t val); // Digital outputs
void (*analog_out)(uint16_t channel, uint16_t val); // Analog outputs (WIP)
void (*coins_out)(uint8_t slot, uint16_t removed); // Remove coins from the count
};
typedef HRESULT (*fastio_provider_t)(struct fastio_node **root);
HRESULT fastio_hook_init(fastio_provider_t main, fastio_provider_t sub);
+12 -10
View File
@@ -11,18 +11,18 @@
#include "util/dprintf.h"
#include "util/str.h"
#define IDMAC_IOCTL_DMA_READ CTL_CODE(0xC350, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_DMA_WRITE CTL_CODE(0xC350, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_REGISTER_READ CTL_CODE(0xC350, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_REGISTER_WRITE CTL_CODE(0xC350, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_DMA_READ CTL_CODE(0xC350, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_DMA_WRITE CTL_CODE(0xC350, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_REGISTER_READ CTL_CODE(0xC350, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_REGISTER_WRITE CTL_CODE(0xC350, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_REGISTER_BUFFER_READ CTL_CODE(0xC350, 0x804, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_REGISTER_BUFFER_WRITE CTL_CODE(0xC350, 0x805, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_READ CTL_CODE(0xC350, 0x806, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_WRITE CTL_CODE(0xC350, 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_BUFFER_READ CTL_CODE(0xC350, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_BUFFER_WRITE CTL_CODE(0xC350, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_READ_EXT CTL_CODE(0xC350, 0x820, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_WRITE_EXT CTL_CODE(0xC350, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_READ CTL_CODE(0xC350, 0x806, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_WRITE CTL_CODE(0xC350, 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_BUFFER_READ CTL_CODE(0xC350, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_BUFFER_WRITE CTL_CODE(0xC350, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_READ_EXT CTL_CODE(0xC350, 0x820, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IDMAC_IOCTL_MEMORY_WRITE_EXT CTL_CODE(0xC350, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS)
static uint8_t dipsw = 0;
static HANDLE idmac_fd;
@@ -172,6 +172,8 @@ HRESULT idmac_hook_init(const struct idmac_config *cfg, struct idmac_hardware *h
return hr;
}
fastio_hook_init(hardware->fastio_main, hardware->fastio_sub);
idmac_hook_table_apply(NULL);
hr = iohook_open_nul_fd(&idmac_fd);
+3 -2
View File
@@ -4,6 +4,7 @@
#include <stdint.h>
#include "idmac/jvs.h"
#include "idmac/fastio.h"
#pragma pack(push,1)
@@ -17,8 +18,8 @@ struct idmac_hardware {
uint8_t dipsw;
jvs_provider_t dongle;
jvs_provider_t jvs;
jvs_provider_t fastio_main;
jvs_provider_t fastio_sub;
fastio_provider_t fastio_main;
fastio_provider_t fastio_sub;
};
#pragma pack(pop)
-7
View File
@@ -6,13 +6,6 @@
#include "jvs/jvs-bus.h"
DEFINE_GUID(
jvs_guid,
0xDB6BBB45,
0xCC96,
0x4288,
0xAA, 0x00, 0x6C, 0x00, 0xD7, 0x67, 0xBD, 0xBF);
struct jvs_config {
bool enable;
};
+2
View File
@@ -18,5 +18,7 @@ idmac_lib = static_library(
'guid.c',
'jvs.c',
'jvs.h',
'fastio.c',
'fastio.h',
],
)
-11
View File
@@ -22,16 +22,6 @@ void siva_dll_config_load(
filename);
}
void touch_config_load(
struct touch_config *cfg,
const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"touch", L"enable", 1, filename);
}
void siva_hook_config_load(
struct siva_hook_config *cfg,
const wchar_t *filename)
@@ -43,5 +33,4 @@ void siva_hook_config_load(
platform_config_load(&cfg->platform, filename);
siva_dll_config_load(&cfg->dll, filename);
gfx_config_load(&cfg->gfx, filename);
touch_config_load(&cfg->touch, filename);
}
-2
View File
@@ -3,7 +3,6 @@
#include <stddef.h>
#include "sivahook/siva-dll.h"
#include "sivahook/touch.h"
#include "idmac/config.h"
#include "platform/config.h"
@@ -15,7 +14,6 @@ struct siva_hook_config {
struct platform_config platform;
struct siva_dll_config dll;
struct gfx_config gfx;
struct touch_config touch;
};
void siva_hook_config_load(
-7
View File
@@ -20,7 +20,6 @@
#include "sivahook/reader.h"
#include "sivahook/config.h"
#include "sivahook/siva-dll.h"
#include "sivahook/touch.h"
#include "sivahook/unity.h"
#include "platform/platform.h"
@@ -64,12 +63,6 @@ static DWORD CALLBACK siva_pre_startup(void)
hr = siva_dll_init(&siva_hook_cfg.dll, siva_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = touch_hook_init(&siva_hook_cfg.touch);
if (FAILED(hr)) {
goto fail;
}
+7 -15
View File
@@ -2,7 +2,7 @@
#include <assert.h>
#include "jvs/jvs-bus.h"
#include "idmac/jvs.h"
#include "idmac/fastio.h"
#include "board/io3.h"
#include "sivahook/fastio.h"
@@ -10,20 +10,13 @@
#include "util/dprintf.h"
static void fastio_jvs_read_switches(void *ctx, struct io3_switch_state *out);
static void fastio_jvs_read_coin_counter(
static void fastio_digital_read(void *ctx, struct io3_switch_state *out);
static void fastio_coin_read(
void *ctx,
uint8_t slot_no,
uint16_t *out);
static const struct io3_ops siva_jvs_fastio_ops = {
.read_switches = fastio_jvs_read_switches,
.read_coin_counter = fastio_jvs_read_coin_counter,
};
static struct io3 siva_jvs_fastio;
HRESULT siva_fastio_init(struct jvs_node **out)
HRESULT siva_fastio_init(struct fastio_node **out)
{
HRESULT hr;
@@ -31,14 +24,13 @@ HRESULT siva_fastio_init(struct jvs_node **out)
dprintf("Siva Nesica Fastio: Init\n");
io3_init(&siva_jvs_fastio, NULL, &siva_jvs_fastio_ops, NULL);
*out = io3_to_jvs_node(&siva_jvs_fastio);
siva_dll.init();
return S_OK;
}
static void fastio_jvs_read_switches(void *ctx, struct io3_switch_state *out) {}
static void fastio_jvs_read_coin_counter(
static void fastio_digital_read(void *ctx, struct io3_switch_state *out) {}
static void fastio_coin_read(
void *ctx,
uint8_t slot_no,
uint16_t *out)
+20 -1
View File
@@ -2,5 +2,24 @@
#include <windows.h>
#include "jvs/jvs-bus.h"
#include "idmac/fastio.h"
HRESULT siva_fastio_init(struct jvs_node **out);
enum SIVA_SWITCH {
RIGHT_BUTTON = 0x000080,
RIGHT_UP = 0x010000,
RIGHT_DOWN = 0x040000,
RIGHT_LEFT = 0x100000,
RIGHT_RIGHT = 0x400000,
LEFT_BUTTON = 0x000020,
LEFT_UP = 0x000100,
LEFT_DOWN = 0x000400,
LEFT_LEFT = 0x001000,
LEFT_RIGHT = 0x004000,
SYS_SERVICE = 0x000004,
SYS_TEST = 0x000040,
SYS_SELECT = 0x000008,
SYS_ENTER = 0x000010,
SYS_COIN = 0x000001,
};
HRESULT siva_fastio_init(struct fastio_node **out);
-2
View File
@@ -26,8 +26,6 @@ shared_library(
'siva-dll.h',
'unity.c',
'unity.h',
'touch.c',
'touch.h',
'reader.c',
'reader.h',
'fastio.c',
-17
View File
@@ -1,17 +0,0 @@
#include <windows.h>
#include <stdbool.h>
#include "sivahook/touch.h"
#include "hooklib/createprocess.h"
#include "util/dprintf.h"
HRESULT touch_hook_init(const struct touch_config *cfg)
{
if (!cfg->enable) {
return S_FALSE;
}
dprintf("Touch: hook init\n");
return createprocess_push_hook_w(L"\"NanoTS_PTool_win8.exe\"", L"inject_32.exe -d -k sivahook_32.dll ", NULL, false);
}
-9
View File
@@ -1,9 +0,0 @@
#pragma once
#include <windows.h>
#include <stdbool.h>
struct touch_config {
bool enable;
};
HRESULT touch_hook_init(const struct touch_config *cfg);
+54 -2
View File
@@ -3,6 +3,7 @@
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "sivaio/sivaio.h"
@@ -15,6 +16,7 @@ static bool siva_io_service = false;
static uint16_t siva_coin_ct = 0;
static uint16_t siva_service_ct = 0;
static struct siva_input_config cfg;
static HANDLE selected_ri_dev = (HANDLE)-1;
uint16_t siva_io_get_api_version(void)
{
@@ -23,19 +25,69 @@ uint16_t siva_io_get_api_version(void)
HRESULT siva_io_init(void)
{
wchar_t ri_dev_name[PATH_MAX] = L"\0";
UINT num_ri_devs = 0;
UINT len_ri_dev_name = 0;
DWORD err = 0;
PRAWINPUTDEVICELIST ri_devs = NULL;
dprintf("Siva IO: Init\n");
siva_io_config_load(&cfg, L".\\bananatools.ini");
if (GetRawInputDeviceList(NULL, &num_ri_devs, sizeof(RAWINPUTDEVICELIST)) != 0) {
err = GetLastError();
dprintf("Siva IO: GetRawInputDeviceList failed to get number of devices %08lX\n", err);
return E_FAIL;
}
ri_devs = malloc(sizeof(RAWINPUTDEVICELIST) * num_ri_devs);
GetRawInputDeviceList(ri_devs, &num_ri_devs, sizeof(RAWINPUTDEVICELIST));
if (num_ri_devs <= 0) {
err = GetLastError();
dprintf("Siva IO: GetRawInputDeviceList failed to get devices info %08lX\n", err);
free(ri_devs);
return E_FAIL;
}
dprintf("Siva IO: Raw Input device list (%d devices):\n", num_ri_devs);
for (int i = 0; i < num_ri_devs; i++) {
len_ri_dev_name = 0;
if (GetRawInputDeviceInfoW(ri_devs[i].hDevice, RIDI_DEVICENAME, NULL, &len_ri_dev_name) != 0) {
dprintf("Siva IO: GetRawInputDeviceInfoW #%d failed to get name size\n", i);
break;
}
if (len_ri_dev_name <= 0) {
dprintf("Siva IO: GetRawInputDeviceInfoW #%d len_ri_dev_name <= 0\n", i);
break;
}
if (len_ri_dev_name >= MAX_PATH) {
dprintf("\tDev #%d - (name too long, %d characters)\n", i, len_ri_dev_name);
continue;
}
if (GetRawInputDeviceInfoW(ri_devs[i].hDevice, RIDI_DEVICENAME, ri_dev_name, &len_ri_dev_name) <= 0) {
dprintf("Siva IO: GetRawInputDeviceInfoW #%d failed to get name\n", i);
break;
}
dprintf("\tDev #%d - %ls\n", i, ri_dev_name);
}
free(ri_devs);
return S_OK;
}
void siva_io_get_btns(uint8_t *btn, uint8_t *stick)
{
if (GetAsyncKeyState(cfg.test) & 0x8000) {
*btn |= SIVA_BTN_TEST;
*btn |= BTN_TEST;
}
if (GetAsyncKeyState(cfg.service) & 0x8000) {
*btn |= SIVA_BTN_SERVICE;
*btn |= BTN_SERVICE;
}
}
+15 -13
View File
@@ -5,22 +5,24 @@
#include <stdint.h>
enum {
SIVA_BTN_TEST = 0x01,
SIVA_BTN_SERVICE = 0x02,
SIVA_BTN_COIN = 0x03,
SIVA_BTN_LEFT = 0x04,
SIVA_BTN_RIGHT = 0x05,
BTN_LEFT = 0b00000001,
BTN_RIGHT = 0b00000010,
BTN_TEST = 0b00000100,
BTN_SERVICE = 0b00001000,
BTN_SELECT = 0b00010000,
BTN_ENTER = 0b00100000,
BTN_COIN = 0b01000000,
};
enum {
SIVA_STICK_L_UP = 0x01,
SIVA_STICK_L_RIGHT = 0x02,
SIVA_STICK_L_DOWN = 0x03,
SIVA_STICK_L_LEFT = 0x04,
SIVA_STICK_R_UP = 0x05,
SIVA_STICK_R_RIGHT = 0x06,
SIVA_STICK_R_DOWN = 0x07,
SIVA_STICK_R_LEFT = 0x08,
STICK_LEFT_UP = 0b00000001,
STICK_LEFT_DOWN = 0b00000010,
STICK_LEFT_LEFT = 0b00000100,
STICK_LEFT_RIGHT = 0b00001000,
STICK_RIGHT_UP = 0b00010000,
STICK_RIGHT_DOWN = 0b00100000,
STICK_RIGHT_LEFT = 0b01000000,
STICK_RIGHT_RIGHT = 0b10000000,
};
/* Get the version of the Theatrhythm IO API that this DLL supports. This