Renamed mouse mod to mouse scroll

This commit is contained in:
neauoire 2021-12-28 11:21:56 -08:00
parent 69f72485c7
commit 2a9fc00441
4 changed files with 21 additions and 22 deletions

View File

@ -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 )

View File

@ -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);

View File

@ -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);

View File

@ -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);