0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-24 06:45:11 +00:00

Added a scroll wheel port to the mouse device

This commit is contained in:
neauoire 2021-05-29 15:01:19 -07:00
parent 17af020cc0
commit 3276b370e8

View file

@ -155,7 +155,6 @@ domouse(SDL_Event *event)
Uint16 y = clamp(event->motion.y - PAD, 0, ppu.ver * 8 - 1);
mempoke16(devmouse->dat, 0x2, x);
mempoke16(devmouse->dat, 0x4, y);
devmouse->dat[7] = 0x00;
switch(event->button.button) {
case SDL_BUTTON_LEFT: flag = 0x01; break;
case SDL_BUTTON_RIGHT: flag = 0x10; break;
@ -164,10 +163,8 @@ domouse(SDL_Event *event)
case SDL_MOUSEBUTTONDOWN:
devmouse->dat[6] |= flag;
if(flag == 0x10 && (devmouse->dat[6] & 0x01))
devmouse->dat[7] = 0x01;
if(flag == 0x01 && (devmouse->dat[6] & 0x10))
devmouse->dat[7] = 0x10;
break;
if(flag == 0x01 && (devmouse->dat[6] & 0x10))
break;
case SDL_MOUSEBUTTONUP:
devmouse->dat[6] &= (~flag);
break;
@ -353,6 +350,10 @@ start(Uxn *u)
evaluxn(u, mempeek16(devctrl->dat, 0));
devctrl->dat[3] = 0;
break;
case SDL_MOUSEWHEEL:
devmouse->dat[7] = event.wheel.y;
evaluxn(u, mempeek16(devmouse->dat, 0));
break;
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION: