mfc: fix 2025 version touch (#426)

## Link to GitHub Issue, if one exists
n/a

## Description of change
HG cabinet uses wintouch and it requires TOUCHEVENTF_PRIMARY flag in
order to accept touch inputs.
Added wintouchemu on game hook and TOUCHEVENTF_PRIMARY flag on
wintouchemu.
 
## Testing
The game boots into test menu, touch now works. (tested in I/O TEST ->
TOUCH PANEL CHECK with '-s' flag)
TDJ subscreen overlay and nostalgia seems works fine regardless added
TOUCHEVENTF_PRIMARY flag but more testing required.
This commit is contained in:
duel0213
2025-11-26 10:14:07 +09:00
committed by GitHub
parent 0dad96b876
commit d06b8bd731
5 changed files with 45 additions and 2 deletions
+11 -2
View File
@@ -4,6 +4,7 @@
#include "avs/game.h" #include "avs/game.h"
#include "hooks/graphics/graphics.h" #include "hooks/graphics/graphics.h"
#include "misc/eamuse.h" #include "misc/eamuse.h"
#include "misc/wintouchemu.h"
#include "touch/touch.h" #include "touch/touch.h"
#include "util/detour.h" #include "util/detour.h"
#include "util/libutils.h" #include "util/libutils.h"
@@ -32,6 +33,8 @@ namespace games::mfc {
static uint8_t CARD_TYPE = 0; static uint8_t CARD_TYPE = 0;
static uint8_t CARD_UID[8]; static uint8_t CARD_UID[8];
bool HG_MODE = false;
typedef int (__cdecl *inifile_param_num_t)(const char *, int *); typedef int (__cdecl *inifile_param_num_t)(const char *, int *);
static inifile_param_num_t inifile_param_num_real; static inifile_param_num_t inifile_param_num_real;
@@ -50,8 +53,10 @@ namespace games::mfc {
static void __cdecl touch_init(int width, int height) { static void __cdecl touch_init(int width, int height) {
log_info("mfc", "call touch_init(width: {}, height: {})", width, height); log_info("mfc", "call touch_init(width: {}, height: {})", width, height);
// attach touch module if (HG_MODE) {
if (!TOUCH_ATTACHED) { wintouchemu::ADD_TOUCH_FLAG_PRIMARY = true;
wintouchemu::hook("MFC9", avs::game::DLL_INSTANCE);
} else if (!TOUCH_ATTACHED) { // attach touch module
// store touch size specification // store touch size specification
TOUCH_MAX_X = width; TOUCH_MAX_X = width;
@@ -328,6 +333,10 @@ namespace games::mfc {
if (allinone_module == nullptr) { if (allinone_module == nullptr) {
log_misc("mfc", "using system.dll instead of allinone.dll for i/o hooks"); log_misc("mfc", "using system.dll instead of allinone.dll for i/o hooks");
allinone_module = system_module; allinone_module = system_module;
if (avs::game::SPEC[0] == 'F') {
HG_MODE = true;
}
} }
// network fix // network fix
+2
View File
@@ -4,6 +4,8 @@
namespace games::mfc { namespace games::mfc {
extern bool HG_MODE;
struct joystick_state { struct joystick_state {
bool up = false; bool up = false;
bool down = false; bool down = false;
@@ -15,6 +15,7 @@
#include "cfg/screen_resize.h" #include "cfg/screen_resize.h"
#include "games/iidx/iidx.h" #include "games/iidx/iidx.h"
#include "games/sdvx/sdvx.h" #include "games/sdvx/sdvx.h"
#include "games/mfc/mfc.h"
#include "games/io.h" #include "games/io.h"
#include "hooks/graphics/graphics.h" #include "hooks/graphics/graphics.h"
#include "launcher/launcher.h" #include "launcher/launcher.h"
@@ -1360,6 +1361,11 @@ void graphics_d3d9_on_present(
graphics_d3d9_ldj_on_present(wrapped_device); graphics_d3d9_ldj_on_present(wrapped_device);
} }
const bool is_mfc = avs::game::is_model("KK9") && games::mfc::HG_MODE;
if (is_mfc) {
wintouchemu::update();
}
// check screenshot key // check screenshot key
static bool trigger_last = false; static bool trigger_last = false;
auto buttons = games::get_buttons_overlay(eamuse_get_game()); auto buttons = games::get_buttons_overlay(eamuse_get_game());
+25
View File
@@ -34,6 +34,7 @@ namespace wintouchemu {
bool FORCE = false; bool FORCE = false;
bool INJECT_MOUSE_AS_WM_TOUCH = false; bool INJECT_MOUSE_AS_WM_TOUCH = false;
bool LOG_FPS = false; bool LOG_FPS = false;
bool ADD_TOUCH_FLAG_PRIMARY = false;
static inline bool is_emu_enabled() { static inline bool is_emu_enabled() {
return FORCE || !is_touch_available("wintouchemu::is_emu_enabled") || GRAPHICS_SHOW_CURSOR; return FORCE || !is_touch_available("wintouchemu::is_emu_enabled") || GRAPHICS_SHOW_CURSOR;
@@ -187,16 +188,28 @@ namespace wintouchemu {
switch (touch_event->type) { switch (touch_event->type) {
case TOUCH_DOWN: case TOUCH_DOWN:
if (valid) { if (valid) {
if (ADD_TOUCH_FLAG_PRIMARY) {
touch_input->dwFlags |= TOUCHEVENTF_PRIMARY;
}
touch_input->dwFlags |= TOUCHEVENTF_DOWN; touch_input->dwFlags |= TOUCHEVENTF_DOWN;
} }
break; break;
case TOUCH_MOVE: case TOUCH_MOVE:
if (valid) { if (valid) {
if (ADD_TOUCH_FLAG_PRIMARY) {
touch_input->dwFlags |= TOUCHEVENTF_PRIMARY;
}
touch_input->dwFlags |= TOUCHEVENTF_MOVE; touch_input->dwFlags |= TOUCHEVENTF_MOVE;
} }
break; break;
case TOUCH_UP: case TOUCH_UP:
// don't check valid so that this touch ID can be released // don't check valid so that this touch ID can be released
if (ADD_TOUCH_FLAG_PRIMARY) {
touch_input->dwFlags |= TOUCHEVENTF_PRIMARY;
}
touch_input->dwFlags |= TOUCHEVENTF_UP; touch_input->dwFlags |= TOUCHEVENTF_UP;
break; break;
} }
@@ -238,16 +251,28 @@ namespace wintouchemu {
switch (mouse_state.touch_event) { switch (mouse_state.touch_event) {
case TOUCHEVENTF_DOWN: case TOUCHEVENTF_DOWN:
if (valid) { if (valid) {
if (ADD_TOUCH_FLAG_PRIMARY) {
touch_input->dwFlags |= TOUCHEVENTF_PRIMARY;
}
touch_input->dwFlags |= TOUCHEVENTF_DOWN; touch_input->dwFlags |= TOUCHEVENTF_DOWN;
} }
break; break;
case TOUCHEVENTF_MOVE: case TOUCHEVENTF_MOVE:
if (valid) { if (valid) {
if (ADD_TOUCH_FLAG_PRIMARY) {
touch_input->dwFlags |= TOUCHEVENTF_PRIMARY;
}
touch_input->dwFlags |= TOUCHEVENTF_MOVE; touch_input->dwFlags |= TOUCHEVENTF_MOVE;
} }
break; break;
case TOUCHEVENTF_UP: case TOUCHEVENTF_UP:
// don't check valid so that this touch ID can be released // don't check valid so that this touch ID can be released
if (ADD_TOUCH_FLAG_PRIMARY) {
touch_input->dwFlags |= TOUCHEVENTF_PRIMARY;
}
touch_input->dwFlags |= TOUCHEVENTF_UP; touch_input->dwFlags |= TOUCHEVENTF_UP;
break; break;
} }
+1
View File
@@ -8,6 +8,7 @@ namespace wintouchemu {
extern bool FORCE; extern bool FORCE;
extern bool INJECT_MOUSE_AS_WM_TOUCH; extern bool INJECT_MOUSE_AS_WM_TOUCH;
extern bool LOG_FPS; extern bool LOG_FPS;
extern bool ADD_TOUCH_FLAG_PRIMARY;
void hook(const char *window_title, HMODULE module = nullptr, int delay_in_s=0); void hook(const char *window_title, HMODULE module = nullptr, int delay_in_s=0);
void hook_title_ends( void hook_title_ends(