From a04cceed2314309ecab8bd24d715759bbb5a4837 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Fri, 26 Apr 2024 04:42:36 +0100 Subject: [PATCH] Emulator scroll wheel support --- basic/test.bsc | 5 ++++- emulator/src/framework/gfx.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/basic/test.bsc b/basic/test.bsc index a2953bdc..34e45bb2 100644 --- a/basic/test.bsc +++ b/basic/test.bsc @@ -1,3 +1,6 @@ cls mouse show -mouse cursor 38 \ No newline at end of file +repeat + b = mouse(x,y,w) + print chr$(20);x,y,w;" " +until false \ No newline at end of file diff --git a/emulator/src/framework/gfx.cpp b/emulator/src/framework/gfx.cpp index 616145e6..25321499 100644 --- a/emulator/src/framework/gfx.cpp +++ b/emulator/src/framework/gfx.cpp @@ -18,6 +18,7 @@ #include #include "sys_processor.h" #include +#include #ifdef EMSCRIPTEN #include "emscripten.h" @@ -106,9 +107,15 @@ static void _GFXMainLoop(void *arg) { _GFXUpdateKeyRecord(event.key.keysym.sym,event.type == SDL_KEYDOWN); HWQueueKeyboardEvent(event.key.keysym.scancode,event.type == SDL_KEYDOWN); } - if (event.type == SDL_MOUSEMOTION || event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) { + if (event.type == SDL_MOUSEMOTION || event.type == SDL_MOUSEBUTTONDOWN // Mouse button/position update + || event.type == SDL_MOUSEBUTTONUP) { HWUpdateMouse(); } + if (event.type == SDL_MOUSEWHEEL) { // Handle scroll wheel events. + int dy = event.wheel.y; + if (event.wheel.type == SDL_MOUSEWHEEL_FLIPPED) dy = -dy; + MSEUpdateScrollWheel(dy); + } if (event.type == SDL_QUIT) { // GUI hardware. isRunning = 0; }