From d8ea7314c7100722cfb8eda5025e2a7ea588ea1b Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 9 Apr 2024 08:26:42 +0000 Subject: [PATCH] zxemut: init absolute kmouse coords when "absolute" mode is turned on FossilOrigin-Name: cee54025fc6eb5e2615214ca6910cdc9a80326c8a96c7b2adc7c5d638538b864 --- src/ZXEmuT/emuutils.h | 1 + src/ZXEmuT/jimapi.c | 2 +- src/ZXEmuT/main.c | 21 +++++++++++++-------- src/ZXEmuT/zymcb.c | 1 + 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/ZXEmuT/emuutils.h b/src/ZXEmuT/emuutils.h index 1eec242..f78f468 100644 --- a/src/ZXEmuT/emuutils.h +++ b/src/ZXEmuT/emuutils.h @@ -111,6 +111,7 @@ void emuHideRealMouseCursor (void); void emuShowRealMouseCursor (void); void emuFullScreenChanged (void); void emuRealizeRealMouseCursorState (void); +void emuSetKMouseAbsCoords (void); uint8_t emuGetCursorColor (uint8_t c0, uint8_t c1); diff --git a/src/ZXEmuT/jimapi.c b/src/ZXEmuT/jimapi.c index 98debef..8f21dc0 100644 --- a/src/ZXEmuT/jimapi.c +++ b/src/ZXEmuT/jimapi.c @@ -432,7 +432,7 @@ JIMAPI_FN(kmouse) { else if (strEqu(a0, "off") || strEqu(a0, "ona")) optKMouse = 0; else if (strEqu(a0, "toggle")) optKMouse = !optKMouse; else if (strEqu(a0, "normal")) optKMouseAbsolute = 0; - else if (strEqu(a0, "absolute")) optKMouseAbsolute = 1; + else if (strEqu(a0, "absolute")) { optKMouseAbsolute = 1; emuSetKMouseAbsCoords(); } else { jim_SetResStrf(interp, "%s: invalid mode: '%s'", Jim_String(argv[0]), Jim_String(argv[1])); return JIM_ERR; diff --git a/src/ZXEmuT/main.c b/src/ZXEmuT/main.c index d6436ce..e638e95 100644 --- a/src/ZXEmuT/main.c +++ b/src/ZXEmuT/main.c @@ -733,19 +733,24 @@ static void zxMouseSetButtons (int buttons) { } +void emuSetKMouseAbsCoords (void) { + int x = msRealX, y = msRealY; + //fprintf(stderr, "MS: scale=%d, x=%d; y=%d\n", vidScale, x / vidScale, y / vidScale); + x /= vidScale; + y /= vidScale; + x -= 32 + zxScreenOfs; + y -= 24; + //fprintf(stderr, "MS: x=%d; y=%d\n", x, y); + kmouseAbsX = x; kmouseAbsY = y; +} + + static void zxMouseCB (int x, int y, int xrel, int yrel, int buttons) { if (/*widgetsProcessMouse(x, y, 0, buttons) ||*/ msCursorDrawn) return; //fprintf(stderr, "mouse: x=%d; y=%d; xrel=%d; yrel=%d; btn=#%02X\n", x, y, xrel, yrel, buttons); if (optKMouse && optKMouseAbsolute) { - x = msRealX; y = msRealY; - //fprintf(stderr, "MS: scale=%d, x=%d; y=%d\n", vidScale, x / vidScale, y / vidScale); - x /= vidScale; - y /= vidScale; - x -= 32 + zxScreenOfs; - y -= 24; - //fprintf(stderr, "MS: x=%d; y=%d\n", x, y); - kmouseAbsX = x; kmouseAbsY = y; + emuSetKMouseAbsCoords(); return; } diff --git a/src/ZXEmuT/zymcb.c b/src/ZXEmuT/zymcb.c index 5550754..c011a9e 100644 --- a/src/ZXEmuT/zymcb.c +++ b/src/ZXEmuT/zymcb.c @@ -877,6 +877,7 @@ static int zxemutTraps (zym_cpu_t *z80, uint8_t code, uint16_t dataaddr, uint8_t optKMouse = 1; optKMouseAbsolute = 1; emuHideRealMouseCursor(); + emuSetKMouseAbsCoords(); z80->af.a = 1; break; case 0x61: // kmouse normal -- 2.11.4.GIT