From 6b25058f683937c486284741dd942254ec16668d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 21 May 2024 23:29:37 +1000 Subject: [PATCH] Try to fix mouse input --- src/Window_Terminal.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Window_Terminal.c b/src/Window_Terminal.c index 6240677ef..935082b67 100644 --- a/src/Window_Terminal.c +++ b/src/Window_Terminal.c @@ -153,23 +153,26 @@ static int stdin_available(void) { tok = strtok(NULL, ";"); \ x = atoi(tok); \ tok = strtok(NULL, ";"); \ - y = atoi(tok); + y = atoi(tok) * 2; static void ProcessMouse(char* buf, int n) { - char cpy[128]; - char* tok = strtok(cpy+3, ";"); - int x, y, mouse; + char cpy[256+2]; + strncpy(cpy, buf, n); + char* tok = strtok(cpy + 3, ";"); + int x, y, mouse; + if (!tok) return; - switch(tok[0]){ - case '0': - mouse = (strchr(buf, 'm') == NULL); - ExtractXY(); - Platform_Log2("CLICK: %i, %i", &x, &y); - break; - case '3': - mouse = (strcmp(tok, "32") == 0); - ExtractXY(); - Platform_Log2("HOVER: %i, %i", &x, &y); + switch (tok[0]){ + case '0': + mouse = strchr(buf, 'm') == NULL; + ExtractXY(); + Pointer_SetPosition(0, x, y); + Input_SetNonRepeatable(CCMOUSE_L, mouse); + break; + case '3': + mouse = (strcmp(tok, "32") == 0); + ExtractXY(); + Pointer_SetPosition(0, x, y); break; } } @@ -187,13 +190,13 @@ static void ProcessKey(int key) { } void Window_ProcessEvents(float delta) { - char buf[128]; + char buf[256]; int n; if (!stdin_available()) return; n = read(STDIN_FILENO, buf, sizeof(buf)); int A = buf[0]; - Platform_Log2("IN: %i, %i", &n, &A); + //Platform_Log2("IN: %i, %i", &n, &A); if (n >= 4 && buf[0] == '\x1b' && buf[1] == '[' && buf[2] == '<') { ProcessMouse(buf, n);