Files
kyoubate-haruka 0e76dd832a diva: input rewrite, dinput/xinput, button alternation, auto-slide, wintouch, printer (#129)
* Rewrote the input handler

Added support for dinput and xinput, full keyboard slider cell binding (#127), hold-takeovers, button alternation and auto-sliding (PS4 behaviour). See segatools.ini for a detailed description about everything.

* Split touch handling into backends and added Wintouch touch emulation

Now you can use actual touchscreens as well as mouse emulation was not the greatest when trying to use an actual touchscreen.

* Fixed input issues

gamebtns was always uninitialized, so good luck trying to do anything. How did nobody ever complain about this? lol

* Fixed resolution issues caused by chaining both gfx hooks

The diva-specific hook is the only one we need. Stacking both has strange effects.

* Added support for the MITSUBISHI CP9550DS printer

Q: Why?
A: /shrug

![https://puu.sh/KQlev/ce2ef0efed.bmp](https://puu.sh/KQlev/ce2ef0efed.bmp)

I am not particularly good at this game (or the pass requirements are insane, 23+12 misses out of ~550 is a fail!?), so if someone could test how this feels as opposed to the PS4 version, that would help a lot!

![https://puu.sh/KQldU/fa4c848ff9.png](https://puu.sh/KQldU/fa4c848ff9.png)

Also something that happens but that I can't reliably reproduce is that my aime card reader randomly becomes NG after a dozen game starts until I delete eeprom.bin.
If that is the case, the only packet sent is SEND_HEX_DATA.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/129
Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
2026-08-10 15:41:40 +00:00

152 lines
2.9 KiB
C

/*
"Hatsune Miku Project DIVA Arcade " (diva) hook
Devices
JVS: 837-14572 "Type 3" I/O Board
COM1: 838-14772 (Elo Touchsystems 2701) Touch Controller Board
COM10: TN32MSEC003S "Gen 1" Aime Reader
COM11: 837-15275 Touch Slider
USB: MITSUBISHI CP9550DS Printer
*/
#include <windows.h>
#include <stdlib.h>
#include "amex/amex.h"
#include "board/sg-reader.h"
#include "divahook/config.h"
#include "divahook/diva-dll.h"
#include "divahook/jvs.h"
#include "divahook/slider.h"
#include "gfxhook/gl.h"
#include "hook/process.h"
#include "hooklib/printer_cp.h"
#include "hooklib/serial.h"
#include "hooklib/spike.h"
#include "platform/platform.h"
#include "util/dprintf.h"
#include "util/env.h"
#include "util/fg-detect.h"
static HMODULE diva_hook_mod;
static process_entry_t diva_startup;
static struct diva_hook_config diva_hook_cfg;
static DWORD CALLBACK diva_pre_startup(void)
{
HRESULT hr;
HMODULE dbghelp;
dprintf("--- Begin diva_pre_startup ---\n");
/* Pin dbghelp so the path hooks apply to it. */
dbghelp = LoadLibraryW(L"dbghelp.dll");
if (dbghelp != NULL) {
dprintf("Pinned debug helper library, hMod=%p\n", dbghelp);
}
else {
dprintf("Failed to load debug helper library!\n");
}
/* Config load */
diva_hook_config_load(&diva_hook_cfg, get_config_path());
/* Hook Win32 APIs */
dvd_hook_init(&diva_hook_cfg.dvd, diva_hook_mod);
gfx_gl_hook_init(&diva_hook_cfg.gfx, diva_hook_mod);
serial_hook_init();
/* Initialize emulation hooks */
hr = platform_hook_init(
&diva_hook_cfg.platform,
"SBZV",
"AAV0",
diva_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = diva_dll_init(&diva_hook_cfg.dll, diva_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = amex_hook_init(&diva_hook_cfg.amex, diva_jvs_init);
if (FAILED(hr)) {
goto fail;
}
hr = sg_reader_hook_init(&diva_hook_cfg.aime, 10, 1, diva_hook_mod);
if (FAILED(hr)) {
goto fail;
}
hr = slider_hook_init(&diva_hook_cfg.slider);
if (FAILED(hr)) {
goto fail;
}
hr = elo_hook_init(&diva_hook_cfg.touch, 1);
if (FAILED(hr)) {
goto fail;
}
hr = printer_cp_hook_init(&diva_hook_cfg.printer, diva_hook_mod);
if (FAILED(hr)) {
goto fail;
}
/* Initialize debug helpers */
spike_hook_init(get_config_path());
dprintf("--- End diva_pre_startup ---\n");
/* Jump to EXE start address */
return diva_startup();
fail:
ExitProcess(EXIT_FAILURE);
}
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
{
HRESULT hr;
if (cause != DLL_PROCESS_ATTACH) {
return TRUE;
}
diva_hook_mod = mod;
hr = process_hijack_startup(diva_pre_startup, &diva_startup);
if (!SUCCEEDED(hr)) {
dprintf("Failed to hijack process startup: %x\n", (int) hr);
}
return SUCCEEDED(hr);
}