18 Commits
Author SHA1 Message Date
Gl0w1amp 35169a5057 Remove global Sleep(1) from uart_handle_read (#6)
This removes the global Sleep(1) workaround that was originally added to prevent memory leaks caused by tight polling loops.

While it helped with the mai2 memory leak, introducing artificial latency here negatively impacts other UART devices (e.g., breaking slider inputs in chusan). The proper fix has now been implemented downstream in `segatools` by rate-limiting the specific `led15070` board instead. Therefore, this global hack is no longer needed and can be safely removed.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/capnhook/pulls/6
Co-authored-by: Gl0w1amp <gl0w1amp@noreply.gitea.tendokyu.moe>
Co-committed-by: Gl0w1amp <gl0w1amp@noreply.gitea.tendokyu.moe>
2026-03-09 16:33:23 +00:00
Gl0w1amp 34a2716827 Add delay in uart_handle_read() to prevent tight polling loop and memory leaks
Added Sleep(1) to uart_handle_read when no data is available to simulate
hardware I/O latency. This prevents the hook from entering a tight polling
loop, which was causing high CPU usage and massive memory leaks.
2025-11-29 05:32:56 +00:00
octocat 252465b23f Fix deadlock in uart_handle_read() (#2)
The loop this commit removed tries to sleep and wait for the IO DLL
to write something to uart->readable. It doesn't work for two reasons:

1. When uart_handle_read() is sleeping, its caller holds the lock
   for the resource, meaning nothing can be writen, and it always times out.

2. Even without the deadlock problem, due to timer resolution limit
   on Windows, Sleep(1) does not actually sleep 1ms.
   Instead it sleeps over 15ms by default.

The symptom is a noticable input lag, and lost inputs.
This commit tries to fix that.

Reviewed-on: https://gitea.tendokyu.moe/TeamTofuShop/capnhook/pulls/2
Co-authored-by: octocat <git.rascal570@passinbox.com>
Co-committed-by: octocat <git.rascal570@passinbox.com>
2025-10-12 10:07:25 +00:00
Hay1tsme dafd0aa336 Implement ilufang's ERROR_IO_PENDING for empty serial reads 2025-02-09 04:50:10 -05:00
Hay1tsme 4633c51d58 remove precompiled headers 2025-02-04 11:05:07 -05:00
Hay1tsme cbffaed804 fix my_GetCommModemStatus 2025-01-20 03:16:51 -05:00
Haruka 47cb508a05 serial: fix flow flags 2024-10-10 11:20:53 +02:00
Hay1tsme 1122b83a29 uart: add modem IOCTLS 2024-08-20 11:29:32 -04:00
Kevin Trocolli 09306229f1 iohook: add hook for GetCommModemStatus 2024-02-21 00:33:25 -05:00
Kevin Trocolli 6b732bfbd6 add io and serial to procaddr table 2023-12-10 18:59:02 -05:00
Kevin Trocolli aaeed25995 impl procaddr hook 2023-12-10 18:41:10 -05:00
Kevin Trocolli 888d068d58 allow iohook and serial_hook to land on DLLs loaded after initialization 2023-11-30 02:18:50 -05:00
Decaf Code dfb7fbf219 Remove PCH source file
Newer versions of Meson create this automatically for MSVC builds.
2019-05-01 21:00:11 -04:00
Decaf Code bfee3db861 Fix MSVC compatibility issues
Project now builds in Visual Studio 2017, probably earlier versions
too as long as they support enough of C99.
2018-11-23 13:58:25 -05:00
Decaf Code d985965639 Fix non-PCH build 2018-11-23 13:46:49 -05:00
Decaf Code de528c108f hooklib/uart.c: Add emulated UART 2018-11-10 11:24:57 -05:00
Decaf Code 6465ab6f09 hooklib/serial.c: Add iohook wrappers for Win32 UART ops 2018-11-10 11:24:57 -05:00
Decaf Code 74697b7cb3 hooklib: Add empty static library 2018-11-10 11:24:57 -05:00