update procaddr hook
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include "mai2hook/mai2-dll.h"
|
||||
|
||||
#include "util/dprintf.h"
|
||||
#include "util/dump.h"
|
||||
|
||||
const char CMD_START = '{';
|
||||
const char CMD_END = '}';
|
||||
@ -26,6 +27,7 @@ const char CMD_SENS_CHECK[2] = "th";
|
||||
const char CMD_RESET[7] = "{RSET}"; // Reset board to default state
|
||||
const char CMD_STAT[7] = "{STAT}"; // Start sending touch state
|
||||
const char CMD_HALT[7] = "{HALT}"; // Stop sending touch state
|
||||
const char RSP_ANY[6] = "(0000)"; // Stop sending touch state
|
||||
|
||||
static HRESULT read_fake_com0(void *bytes, uint32_t *nbytes);
|
||||
static HRESULT read_fake_com1(void *bytes, uint32_t *nbytes);
|
||||
@ -33,6 +35,7 @@ static HRESULT read_fake_com2(void *bytes, uint32_t *nbytes);
|
||||
static HRESULT touch_handle_irp(struct irp *irp);
|
||||
static HRESULT touch0_handle_irp_locked(struct irp *irp);
|
||||
static HRESULT touch1_handle_irp_locked(struct irp *irp);
|
||||
static HRESULT touch_cmd_dispatch(char* cmd, struct iobuf *dest, uint8_t side);
|
||||
|
||||
bool touch0_auto = false;
|
||||
bool touch1_auto = false;
|
||||
@ -149,7 +152,7 @@ static HRESULT touch0_handle_irp_locked(struct irp *irp)
|
||||
//hr = mai2_dll.touch_init();
|
||||
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch: Backend error: %x\n", (int) hr);
|
||||
dprintf("Mai2 touch0: Backend error: %x\n", (int) hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -163,24 +166,16 @@ static HRESULT touch0_handle_irp_locked(struct irp *irp)
|
||||
|
||||
for (;;) {
|
||||
#if 0
|
||||
dprintf("TX0 Buffer:\n");
|
||||
dprintf("touch0 Buffer:\n");
|
||||
dump_iobuf(&touch0_uart.written);
|
||||
#endif
|
||||
//hr = touch_frame_decode(&req, &touch0_uart.written, 0);
|
||||
|
||||
if (hr != S_OK) {
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch: Deframe error: %x\n", (int) hr);
|
||||
}
|
||||
|
||||
hr = touch_cmd_dispatch((char*)touch0_uart.written.bytes, &touch0_uart.readable, 0);
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch0: Dispatch failed %08lX\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
//hr = touch_req_dispatch(&req);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch: Processing error: %x\n", (int) hr);
|
||||
}
|
||||
touch0_uart.written.pos = 0;
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -195,13 +190,13 @@ static HRESULT touch1_handle_irp_locked(struct irp *irp)
|
||||
//hr = mai2_dll.touch_init();
|
||||
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch: Backend error: %x\n", (int) hr);
|
||||
dprintf("Mai2 touch1: Backend error: %x\n", (int) hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
hr = uart_handle_irp(&touch0_uart, irp);
|
||||
hr = uart_handle_irp(&touch1_uart, irp);
|
||||
|
||||
if (FAILED(hr) || irp->op != IRP_OP_WRITE) {
|
||||
return hr;
|
||||
@ -209,25 +204,35 @@ static HRESULT touch1_handle_irp_locked(struct irp *irp)
|
||||
|
||||
for (;;) {
|
||||
#if 0
|
||||
dprintf("TX0 Buffer:\n");
|
||||
dprintf("touch1 Buffer:\n");
|
||||
dump_iobuf(&touch0_uart.written);
|
||||
#endif
|
||||
//hr = touch_frame_decode(&req, &touch0_uart.written, 0);
|
||||
|
||||
if (hr != S_OK) {
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch: Deframe error: %x\n", (int) hr);
|
||||
}
|
||||
|
||||
hr = touch_cmd_dispatch((char*)touch1_uart.written.bytes, &touch1_uart.readable, 1);
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch1: Dispatch failed %08lX\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
//hr = touch_req_dispatch(&req);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
dprintf("Mai2 touch: Processing error: %x\n", (int) hr);
|
||||
}
|
||||
touch1_uart.written.pos = 0;
|
||||
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT touch_cmd_dispatch(char* cmd, struct iobuf *dest, uint8_t side)
|
||||
{
|
||||
if (!strcmp(cmd, CMD_RESET)) {
|
||||
dprintf("Mai2 touch%d: Reset\n", side);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
else if (!strcmp(cmd, CMD_HALT)) {
|
||||
dprintf("Mai2 touch%d: Halt\n", side);
|
||||
Sleep(1001); // ?
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
dprintf("Mai2 touch%d: Unknow %s\n", side, cmd);
|
||||
return S_OK;
|
||||
}
|
Reference in New Issue
Block a user