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>
43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
#pragma once
|
|
#include <assert.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <windows.h>
|
|
|
|
#include "hooklib/fdshark.h"
|
|
#include "hooklib/reg.h"
|
|
#include "hooklib/uart.h"
|
|
#include "mai2hook/mai2-dll.h"
|
|
#include "util/dprintf.h"
|
|
#include "util/dump.h"
|
|
|
|
struct touch_config
|
|
{
|
|
bool enable_1p;
|
|
bool enable_2p;
|
|
};
|
|
|
|
enum
|
|
{
|
|
commandRSET = 0x45, // E
|
|
commandHALT = 0x4C, // L
|
|
commandSTAT = 0x41, // A
|
|
commandRatio = 0x72, // r
|
|
commandSens = 0x6B, // k
|
|
req_start = 0x7b, // {
|
|
req_end = 0x7d, // }
|
|
res_start = 0x28, // (
|
|
res_end = 0x29, // )
|
|
};
|
|
|
|
extern const char *sensor_map[34];
|
|
const char *sensor_to_str(uint8_t sensor);
|
|
|
|
HRESULT touch_hook_init(const struct touch_config *cfg);
|
|
static HRESULT touch_handle_irp(struct irp *irp);
|
|
static HRESULT touch_handle_irp_locked(struct irp *irp, struct uart *uart);
|
|
|
|
/* Called in mai2io to send touch data.
|
|
Similar to chuni slider_res_auto_scan, but the host does not require periodic updates.
|
|
Touch data is sent only when there is a change. */
|
|
static void touch_auto_scan(const uint8_t player, const uint8_t state[7]); |