mirror of
https://gitea.tendokyu.moe/TeamTofuShop/segatools.git
synced 2026-10-10 02:28:10 +03: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>
40 lines
733 B
C
40 lines
733 B
C
#pragma once
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#define IO4_REPORT_OUT_PAYLOAD_LEN 62
|
|
|
|
enum {
|
|
/* System buttons in button[0] */
|
|
|
|
IO4_BUTTON_TEST = 1 << 9,
|
|
IO4_BUTTON_SERVICE = 1 << 6,
|
|
};
|
|
|
|
struct io4_config {
|
|
bool enable;
|
|
bool foreground_only;
|
|
};
|
|
|
|
struct io4_state {
|
|
uint16_t adcs[8];
|
|
uint16_t spinners[4];
|
|
uint16_t chutes[2];
|
|
uint16_t buttons[2];
|
|
};
|
|
|
|
struct io4_ops {
|
|
HRESULT (*poll)(void* ctx, struct io4_state* state);
|
|
|
|
HRESULT (*write_gpio)(uint8_t* payload, size_t len);
|
|
};
|
|
|
|
HRESULT io4_hook_init(
|
|
const struct io4_config* cfg,
|
|
const struct io4_ops* ops,
|
|
void* ctx,
|
|
const wchar_t* window_name,
|
|
const bool window_name_is_partial_match); |