it finally, FINALLY works

This commit is contained in:
Hay1tsme 2022-01-10 19:36:11 -05:00 committed by Hay1tsme
parent 3628395a9c
commit cde1781b53
2 changed files with 35 additions and 20 deletions

View File

@ -416,19 +416,46 @@ static HRESULT touch_handle_start_auto_scan(const struct touch_req *req)
static void touch_res_auto_scan(const bool *state)
{
struct touch_input_frame frame0;
//struct touch_input_frame frame1;
uint8_t data[24] = { 0 };
struct touch_input_frame frame1;
uint8_t dataR[24] = { 0 };
uint8_t dataL[24] = { 0 };
// this changes every input on a real board but
// the game doesn't seem to care about it...
uint8_t data2[9] = { 0x0d, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00 };
uint8_t counter = 0;
frame0.cmd = 0x81;
frame0.count = input_frame_count_0++;
input_frame_count_0 %= 0x7f;
memcpy(frame0.data1, data, sizeof(data));
frame1.cmd = 0x81;
frame1.count = input_frame_count_1++;
input_frame_count_1 %= 0x7f;
for (int i = 0; i < 24; i++) {
for (int j = 0; j < 5; j++) {
if (state[counter]) {
dataR[i] |= (1 << j);
}
if (state[counter+120]) {
dataL[i] |= (1 << j);
}
counter++;
}
}
memcpy(frame0.data1, dataR, sizeof(dataR));
memcpy(frame0.data2, data2, sizeof(data2));
memcpy(frame1.data1, dataL, sizeof(dataL));
memcpy(frame1.data2, data2, sizeof(data2));
frame0.checksum = 0;
frame0.checksum = calc_checksum(&frame0, sizeof(frame0));
frame1.checksum = 0;
frame1.checksum = calc_checksum(&frame1, sizeof(frame1));
if (touch0_auto) {
//dprintf("Wacca touch: Touch0 auto frame #%2hx sent\n", frame0.count);
EnterCriticalSection(&touch0_lock);
@ -439,7 +466,7 @@ static void touch_res_auto_scan(const bool *state)
if (touch1_auto) {
//dprintf("Wacca touch: Touch1 auto frame #%2hx sent\n", frame0.count);
EnterCriticalSection(&touch1_lock);
iobuf_write(&touch1_uart.readable, &frame0, sizeof(frame0));
iobuf_write(&touch1_uart.readable, &frame1, sizeof(frame1));
LeaveCriticalSection(&touch1_lock);
}
}

View File

@ -6,27 +6,15 @@
#include "mercuryio/config.h"
/*
Wacca Default key binding
Inner left
Inner right
2nd inner left
2nd inner right
3rd inner left
3rd inner right
outer left
outer right
*/
static const int mercury_io_default_cells[] = {
'1','1','1','2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','8','8','8','9','9','9','0','0','0',
'A','A','A','S','S','S','D','D','D','F','F','F','G','G','G','H','H','H','J','J','J','K','K','K','L','L','L',';',';',';',
'1','1','1','2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','8','8','8','9','9','9','0','0','0',
'A','A','A','S','S','S','D','D','D','F','F','F','G','G','G','H','H','H','J','J','J','K','K','K','L','L','L',';',';',';',
'Q','Q','Q','W','W','W','E','E','E','R','R','R','T','T','T','Y','Y','Y','U','U','U','I','I','I','O','O','O','P','P','P',
'Z','Z','Z','X','X','X','C','C','C','V','V','V','B','B','B','N','N','N','M','M','M',',',',',',','.','.','.','/','/','/',
'Q','Q','Q','W','W','W','E','E','E','R','R','R','T','T','T','Y','Y','Y','U','U','U','I','I','I','O','O','O','P','P','P',
'Z','Z','Z','X','X','X','C','C','C','V','V','V','B','B','B','N','N','N','M','M','M',',',',',',','.','.','.','/','/','/',
'A','A','A','S','S','S','D','D','D','F','F','F','G','G','G','H','H','H','J','J','J','K','K','K','L','L','L',VK_OEM_1,VK_OEM_1,VK_OEM_1,
'A','A','A','S','S','S','D','D','D','F','F','F','G','G','G','H','H','H','J','J','J','K','K','K','L','L','L',VK_OEM_1,VK_OEM_1,VK_OEM_1,
'Z','Z','Z','X','X','X','C','C','C','V','V','V','B','B','B','N','N','N','M','M','M',VK_OEM_COMMA,VK_OEM_COMMA,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_PERIOD,VK_OEM_PERIOD,VK_OEM_2,VK_OEM_2,VK_OEM_2,
'Z','Z','Z','X','X','X','C','C','C','V','V','V','B','B','B','N','N','N','M','M','M',VK_OEM_COMMA,VK_OEM_COMMA,VK_OEM_COMMA,VK_OEM_PERIOD,VK_OEM_PERIOD,VK_OEM_PERIOD,VK_OEM_2,VK_OEM_2,VK_OEM_2,
};
void mercury_io_config_load(