mirror of
https://gitea.tendokyu.moe/Hay1tsme/segatools.git
synced 2026-05-22 20:21:35 -05:00
This adds a setting to the global configuration to allow only input when the game is focused. This prevents issues, such as triggering game buttons or service buttons while being tabbed out. Turned off by default. The implementation is not the best, but in the context how these games are structured, the most acceptable. It will keep scanning if the foreground window title fully matches (some games partially match, like FGO because due to the revision number in the title), and if found, will grab the HWND of that window and compare that from then on, to not tank performance due to constant string operations. Tested with FGO, chusan and ongeki. Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/segatools/pulls/83 Reviewed-by: Dniel97 <dniel97@noreply.gitea.tendokyu.moe> Co-authored-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Co-committed-by: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com>
68 lines
1.2 KiB
C
68 lines
1.2 KiB
C
#include <windows.h>
|
|
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "board/io4.h"
|
|
|
|
#include "cmhook/cm-dll.h"
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
static HRESULT cm_io4_poll(void* ctx, struct io4_state* state);
|
|
|
|
static uint16_t coins;
|
|
|
|
static const struct io4_ops cm_io4_ops = {
|
|
.poll = cm_io4_poll,
|
|
};
|
|
|
|
HRESULT cm_io4_hook_init(const struct io4_config* cfg) {
|
|
HRESULT hr;
|
|
|
|
assert(cm_dll.init != NULL);
|
|
|
|
hr = io4_hook_init(cfg, &cm_io4_ops, NULL, L"MU3CardViewer", false);
|
|
|
|
if (FAILED(hr)) {
|
|
return hr;
|
|
}
|
|
|
|
return cm_dll.init();
|
|
}
|
|
|
|
static HRESULT cm_io4_poll(void* ctx, struct io4_state* state) {
|
|
uint8_t opbtn;
|
|
HRESULT hr;
|
|
|
|
assert(cm_dll.poll != NULL);
|
|
assert(cm_dll.get_opbtns != NULL);
|
|
|
|
memset(state, 0, sizeof(*state));
|
|
|
|
hr = cm_dll.poll();
|
|
|
|
if (FAILED(hr)) {
|
|
return hr;
|
|
}
|
|
|
|
opbtn = 0;
|
|
|
|
cm_dll.get_opbtns(&opbtn);
|
|
|
|
if (opbtn & CM_IO_OPBTN_TEST) {
|
|
state->buttons[0] |= IO4_BUTTON_TEST;
|
|
}
|
|
|
|
if (opbtn & CM_IO_OPBTN_SERVICE) {
|
|
state->buttons[0] |= IO4_BUTTON_SERVICE;
|
|
}
|
|
|
|
if (opbtn & CM_IO_OPBTN_COIN) {
|
|
coins++;
|
|
}
|
|
state->chutes[0] = coins << 8;
|
|
|
|
return S_OK;
|
|
} |