asiekierka / uxnds

NDS/3DS fork/port of the uxn/Varvara virtual machine
MIT License
150 stars 5 forks source link

Bring mouse device behaviour in line with reference implementation #5

Closed Hoolean closed 2 years ago

Hoolean commented 2 years ago

The upstream implementation of the mouse device only updates a port exactly when its specific property changes, e.g.:

Currently, the uxnds implementation of the mouse device updates all ports when some properties change, e.g.:

The upstream behaviour is assumed in certain ROMs. For example, noodle assumes that after the mouse has been clicked, the state port will not be touched again by the environment until the mouse has been unclicked.

"noodle" zeroes the state port to acknowledge clicks, and assumes that this can be relied upon to avoid duplicate clicks while the mouse is held down.

With the current behaviour of uxnds, the mouse's state is reset upon movement, even if it has not been clicked or unclicked again, which causes such ROMs to interpret phantom mouse presses.

This can be reproduced by opening "noodle" in uxnds and moving the stylus over in-game buttons; instead of toggling once, buttons will be toggled on every movement of the stylus.

This commit brings the emulator in line with the reference/C uxn implementation, fixes this issue with "noodle", and attempts a little tidy to make the new behaviour clear :^)

asiekierka commented 2 years ago

Thanks!