The state port is set only when the mouse is first clicked or unclicked:
The value is not maintained or corrected while the mouse is held down;
The value is not maintained or corrected when the mouse is moved.
Currently, the uxnds implementation of the mouse device updates all ports when some properties change, e.g.:
The state port is set/corrected when the mouse is moved.
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.
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 :^)
The upstream implementation of the mouse device only updates a port exactly when its specific property changes, e.g.:
state
port is set only when the mouse is first clicked or unclicked:Currently, the uxnds implementation of the mouse device updates all ports when some properties change, e.g.:
state
port is set/corrected when the mouse is moved.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 :^)