forked from TeamTofuShop/segatools
In this PR, I have added the `mai2` touch and `led15070` hooks to provide an example for handling custom peripherals. This change allows users to implement the touch and `led15070` logic by writing appropriate `mai2io` scripts. #### **Touch Hook**: - The touch hook simulates touch points based on keyboard combinations. For example, to trigger the A1 touch point, the user must press the A and 1 keys on the keyboard. Input for the 1p requires Caps Lock to be off, while 2p requires Caps Lock to be on. - The hook allows for independent control of whether device simulation is enabled for "1p" and "2p" and whether keyboard input mapping is enabled. - **Note**: The current touch hook is not yet functional as it requires modifications to the `capnhook` for proper completion of the `sinmai` hook. #### **LED15070 Hook**: - This hook implements basic device simulation. Peripherals requiring lighting data should complete the logic as needed. - **Note**: The LED data refresh can flood the console logs, so I’ve added a `DEBUG` flag to control whether the debug logging is enabled or not. #### **Other Changes**: - In certain versions of `sinmai`, key inputs for 1p and 2p can be directly read from the keyboard without requiring simulation via the `amdaemon io4` hook. I’ve added a switch to control this behavior to prevent redundant input. - **Benefit**: This ensures that key input is only read when `sinmai` is in the foreground. If you'd like to learn more about the touch and `led15070` features, my research findings are available here: [Mai2Touch](https://github.com/Sucareto/Mai2Touch) Co-authored-by: Sucareto <28331534+Sucareto@users.noreply.github.com> Reviewed-on: TeamTofuShop/segatools#55 Co-authored-by: Mahuyo <mahuyo@noreply.gitea.tendokyu.moe> Co-committed-by: Mahuyo <mahuyo@noreply.gitea.tendokyu.moe>
93 lines
2.3 KiB
C
93 lines
2.3 KiB
C
#include <assert.h>
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "board/config.h"
|
|
|
|
#include "hooklib/config.h"
|
|
#include "hooklib/dvd.h"
|
|
|
|
#include "mai2hook/config.h"
|
|
|
|
#include "platform/config.h"
|
|
|
|
void mai2_dll_config_load(
|
|
struct mai2_dll_config *cfg,
|
|
const wchar_t *filename)
|
|
{
|
|
assert(cfg != NULL);
|
|
assert(filename != NULL);
|
|
|
|
GetPrivateProfileStringW(
|
|
L"mai2io",
|
|
L"path",
|
|
L"",
|
|
cfg->path,
|
|
_countof(cfg->path),
|
|
filename);
|
|
}
|
|
|
|
void touch_config_load(
|
|
struct touch_config *cfg,
|
|
const wchar_t *filename)
|
|
{
|
|
assert(cfg != NULL);
|
|
assert(filename != NULL);
|
|
|
|
cfg->enable_1p = GetPrivateProfileIntW(L"touch", L"p1Enable", 1, filename);
|
|
cfg->enable_2p = GetPrivateProfileIntW(L"touch", L"p2Enable", 1, filename);
|
|
}
|
|
|
|
void led15070_config_load(struct led15070_config *cfg, const wchar_t *filename)
|
|
{
|
|
assert(cfg != NULL);
|
|
assert(filename != NULL);
|
|
|
|
wchar_t tmpstr[16];
|
|
|
|
cfg->enable = GetPrivateProfileIntW(L"led15070", L"enable", 1, filename);
|
|
cfg->port_no = GetPrivateProfileIntW(L"led15070", L"portNo", 0, filename);
|
|
cfg->fw_ver = GetPrivateProfileIntW(L"led15070", L"fwVer", 0x90, filename);
|
|
cfg->fw_sum = GetPrivateProfileIntW(L"led15070", L"fwSum", 0x00, filename);
|
|
|
|
GetPrivateProfileStringW(
|
|
L"led15070",
|
|
L"boardNumber",
|
|
L"15070-04",
|
|
tmpstr,
|
|
_countof(tmpstr),
|
|
filename);
|
|
|
|
size_t n = wcstombs(cfg->board_number, tmpstr, sizeof(cfg->board_number));
|
|
for (int i = n; i < sizeof(cfg->board_number); i++)
|
|
{
|
|
cfg->board_number[i] = ' ';
|
|
}
|
|
|
|
GetPrivateProfileStringW(
|
|
L"led15070",
|
|
L"eepromPath",
|
|
L"DEVICE",
|
|
cfg->eeprom_path,
|
|
_countof(cfg->eeprom_path),
|
|
filename);
|
|
}
|
|
|
|
void mai2_hook_config_load(
|
|
struct mai2_hook_config *cfg,
|
|
const wchar_t *filename)
|
|
{
|
|
assert(cfg != NULL);
|
|
assert(filename != NULL);
|
|
|
|
platform_config_load(&cfg->platform, filename);
|
|
aime_config_load(&cfg->aime, filename);
|
|
dvd_config_load(&cfg->dvd, filename);
|
|
io4_config_load(&cfg->io4, filename);
|
|
vfd_config_load(&cfg->vfd, filename);
|
|
mai2_dll_config_load(&cfg->dll, filename);
|
|
touch_config_load(&cfg->touch, filename);
|
|
led15070_config_load(&cfg->led15070, filename);
|
|
unity_config_load(&cfg->unity, filename);
|
|
}
|