Skip to content

Commit

Permalink
Merge pull request #471 from paulscottrobson/wheel
Browse files Browse the repository at this point in the history
Emulator scroll wheel support
  • Loading branch information
paulscottrobson authored Apr 26, 2024
2 parents 5448dbc + a04ccee commit 7644e5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion basic/test.bsc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
cls
mouse show
mouse cursor 38
repeat
b = mouse(x,y,w)
print chr$(20);x,y,w;" "
until false
9 changes: 8 additions & 1 deletion emulator/src/framework/gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cmath>
#include "sys_processor.h"
#include <hardware.h>
#include <common.h>

#ifdef EMSCRIPTEN
#include "emscripten.h"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7644e5c

Please sign in to comment.