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>
85 lines
2.6 KiB
C
85 lines
2.6 KiB
C
#include <windows.h>
|
|
|
|
#include <assert.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "mai2io/config.h"
|
|
#include "mai2hook/touch.h"
|
|
|
|
/*
|
|
Maimai DX Default key binding
|
|
1P: self-explanatory
|
|
2P: (Numpad) 8, 9, 6, 3, 2, 1, 4, 7, *
|
|
*/
|
|
static const int mai2_io_1p_default[] = {'W', 'E', 'D', 'C', 'X', 'Z', 'A', 'Q', '3'};
|
|
static const int mai2_io_2p_default[] = {0x68, 0x69, 0x66, 0x63, 0x62, 0x61, 0x64, 0x67, 0x54};
|
|
|
|
static const int mai2_io_1p_touch_default[] = {
|
|
'T', 'Y', 'H', 'N', 'B', 'V', 'F', 'R',
|
|
'T', 'Y', 'H', 'N', 'B', 'V', 'F', 'R',
|
|
'G', 'G',
|
|
'T', 'Y', 'H', 'N', 'B', 'V', 'F', 'R',
|
|
'T', 'Y', 'H', 'N', 'B', 'V', 'F', 'R',
|
|
};
|
|
static const int mai2_io_2p_touch_default[] = {
|
|
'I', 'O', 'L', VK_OEM_PERIOD, VK_OEM_COMMA, 'M', 'J', 'U',
|
|
'I', 'O', 'L', VK_OEM_PERIOD, VK_OEM_COMMA, 'M', 'J', 'U',
|
|
'K', 'K',
|
|
'I', 'O', 'L', VK_OEM_PERIOD, VK_OEM_COMMA, 'M', 'J', 'U',
|
|
'I', 'O', 'L', VK_OEM_PERIOD, VK_OEM_COMMA, 'M', 'J', 'U',
|
|
};
|
|
|
|
void mai2_io_config_load(
|
|
struct mai2_io_config *cfg,
|
|
const wchar_t *filename)
|
|
{
|
|
wchar_t key[16];
|
|
int i;
|
|
|
|
assert(cfg != NULL);
|
|
assert(filename != NULL);
|
|
|
|
cfg->vk_test = GetPrivateProfileIntW(L"io4", L"test", VK_F1, filename);
|
|
cfg->vk_service = GetPrivateProfileIntW(L"io4", L"service", VK_F2, filename);
|
|
cfg->vk_coin = GetPrivateProfileIntW(L"io4", L"coin", VK_F3, filename);
|
|
cfg->vk_btn_enable = GetPrivateProfileIntW(L"button", L"enable", 1, filename);
|
|
|
|
for (i = 0; i < 9; i++)
|
|
{
|
|
swprintf_s(key, _countof(key), L"p1Btn%i", i + 1);
|
|
cfg->vk_1p_btn[i] = GetPrivateProfileIntW(
|
|
L"button",
|
|
key,
|
|
mai2_io_1p_default[i],
|
|
filename);
|
|
|
|
swprintf_s(key, _countof(key), L"p2Btn%i", i + 1);
|
|
cfg->vk_2p_btn[i] = GetPrivateProfileIntW(
|
|
L"button",
|
|
key,
|
|
mai2_io_2p_default[i],
|
|
filename);
|
|
}
|
|
|
|
cfg->debug_input_1p = GetPrivateProfileIntW(L"touch", L"p1DebugInput", 0, filename);
|
|
cfg->debug_input_2p = GetPrivateProfileIntW(L"touch", L"p2DebugInput", 0, filename);
|
|
for (i = 0; i < 34; i++)
|
|
{
|
|
swprintf_s(key, _countof(key), L"p1Touch%S", sensor_map[i]);
|
|
cfg->vk_1p_touch[i] = GetPrivateProfileIntW(
|
|
L"touch",
|
|
key,
|
|
mai2_io_1p_touch_default[i],
|
|
filename);
|
|
|
|
swprintf_s(key, _countof(key), L"p2Touch%S", sensor_map[i]);
|
|
cfg->vk_2p_touch[i] = GetPrivateProfileIntW(
|
|
L"touch",
|
|
key,
|
|
mai2_io_2p_touch_default[i],
|
|
filename);
|
|
}
|
|
}
|