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

80 lines
1.8 KiB
C

#include "backend.h"
static void diva_mouse_update(diva_io_touch_callback_t callback);
static const struct diva_touch_backend diva_mouse_backend = {
.update = diva_mouse_update
};
static int diva_io_m1 = VK_LBUTTON;
HRESULT diva_touch_mouse_init(const struct diva_touch_backend** backend) {
diva_io_m1 = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON;
*backend = &diva_mouse_backend;
return S_OK;
}
static uint8_t status = 0;
static uint16_t x = 0;
static uint16_t y = 0;
static uint16_t last_x = 0;
static uint16_t last_y = 0;
static uint8_t id = 0;
static bool touch = false;
void diva_mouse_update(diva_io_touch_callback_t callback) {
if (GetAsyncKeyState(diva_io_m1) & 0x8000) {
POINT point;
/* Get cursor location and map to window size */
BOOL ok = GetCursorPos(&point);
if (!ok) {
return;
}
HWND hwnd = GetForegroundWindow();
ok = ScreenToClient(hwnd, &point);
if (!ok) {
return;
}
/* Set status */
if (!touch) {
status = DIVA_IO_TOUCH_DOWN;
touch = true;
} else {
status = DIVA_IO_TOUCH_STREAM;
}
/* Set coordinates */
if (point.x < 0) point.x = 0;
if (point.y < 0) point.y = 0;
x = (uint16_t)point.x;
y = (uint16_t)point.y;
last_x = x;
last_y = y;
} else {
if (touch) {
status = DIVA_IO_TOUCH_LIFTOFF;
x = last_x;
y = last_y;
touch = false;
} else {
/* No touch event */
status = 0;
x = 0;
y = 0;
}
}
/* Mouse always acts as single-touch */
id = 1;
callback(status, x, y, id);
}