From 2a9fc00441e4f3363ae1822236db7d56b41ac9ce Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 28 Dec 2021 11:21:56 -0800 Subject: [PATCH] Renamed mouse mod to mouse scroll --- projects/examples/blank.tal | 18 +++++++++--------- src/devices/mouse.c | 2 +- src/devices/mouse.h | 2 +- src/uxnemu.c | 21 ++++++++++----------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal index ebc8caa..d0ae748 100644 --- a/projects/examples/blank.tal +++ b/projects/examples/blank.tal @@ -22,17 +22,17 @@ ( devices ) -|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 +|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 |10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1 -|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 -|30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 -|40 @Audio1 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 -|50 @Audio2 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 -|60 @Audio3 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 +|30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 +|40 @Audio1 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 +|50 @Audio2 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 +|60 @Audio3 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |80 @Controller &vector $2 &button $1 &key $1 -|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &modx $2 &mody $2 -|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 -|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 +|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 +|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 +|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ( variables ) diff --git a/src/devices/mouse.c b/src/devices/mouse.c index c1af535..d6291a1 100644 --- a/src/devices/mouse.c +++ b/src/devices/mouse.c @@ -36,7 +36,7 @@ mouse_pos(Device *d, Uint16 x, Uint16 y) } void -mouse_mod(Device *d, Uint16 x, Uint16 y) +mouse_scroll(Device *d, Uint16 x, Uint16 y) { poke16(d->dat, 0xa, x); poke16(d->dat, 0xc, -y); diff --git a/src/devices/mouse.h b/src/devices/mouse.h index 839a8fe..c9e133f 100644 --- a/src/devices/mouse.h +++ b/src/devices/mouse.h @@ -13,4 +13,4 @@ WITH REGARD TO THIS SOFTWARE. void mouse_down(Device *d, Uint8 mask); void mouse_up(Device *d, Uint8 mask); void mouse_pos(Device *d, Uint16 x, Uint16 y); -void mouse_mod(Device *d, Uint16 x, Uint16 y); +void mouse_scroll(Device *d, Uint16 x, Uint16 y); diff --git a/src/uxnemu.c b/src/uxnemu.c index 4d802be..a4dbd72 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -500,16 +500,16 @@ run(Uxn *u) else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) uxn_eval(u, peek16((devaudio0 + (event.type - audio0_event))->dat, 0)); /* Mouse */ - else if(event.type == SDL_MOUSEWHEEL) - mouse_mod(devmouse, event.wheel.x, event.wheel.y); - else if(event.type == SDL_MOUSEBUTTONUP) - mouse_up(devmouse, 0x1 << (event.button.button - 1)); - else if(event.type == SDL_MOUSEBUTTONDOWN) - mouse_down(devmouse, 0x1 << (event.button.button - 1)); else if(event.type == SDL_MOUSEMOTION) mouse_pos(devmouse, clamp(event.motion.x - PAD, 0, ppu.width - 1), clamp(event.motion.y - PAD, 0, ppu.height - 1)); + else if(event.type == SDL_MOUSEBUTTONUP) + mouse_up(devmouse, 0x1 << (event.button.button - 1)); + else if(event.type == SDL_MOUSEBUTTONDOWN) + mouse_down(devmouse, 0x1 << (event.button.button - 1)); + else if(event.type == SDL_MOUSEWHEEL) + mouse_scroll(devmouse, event.wheel.x, event.wheel.y); /* Controller */ else if(event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) { if(event.type == SDL_TEXTINPUT) @@ -522,17 +522,16 @@ run(Uxn *u) do_shortcut(u, &event); } else if(event.type == SDL_KEYUP) controller_up(devctrl, get_button(&event)); - else if(event.type == SDL_JOYBUTTONDOWN) - controller_down(devctrl, get_button_joystick(&event)); - else if(event.type == SDL_JOYBUTTONUP) - controller_up(devctrl, get_button_joystick(&event)); else if(event.type == SDL_JOYAXISMOTION) { Uint8 vec = get_vector_joystick(&event); if(!vec) controller_up(devctrl, (0x03 << (!event.jaxis.axis * 2)) << 4); else controller_down(devctrl, (0x01 << ((vec + !event.jaxis.axis * 2) - 1)) << 4); - } + } else if(event.type == SDL_JOYBUTTONDOWN) + controller_down(devctrl, get_button_joystick(&event)); + else if(event.type == SDL_JOYBUTTONUP) + controller_up(devctrl, get_button_joystick(&event)); /* Console */ else if(event.type == stdin_event) console_input(u, event.cbutton.button);