Calculate the sum of mouse movement

F_Dos's icon

How can I calculate the total distance my mouse did at a specific axis (x or y) since I press 'start' ?

TFL's icon

By "total distance", do you mean absolute (regardless of the direction) or relative?

Like if you go from the left border of your screen to the right one and back to the left one, should this count as 0 (given you're back to your starting point) or as two times your screen width?

Check [mousestate] to get your mouse position.

F_Dos's icon

or as two times your screen width?

as two times

Source Audio's icon

In case your question is to report total mouse travel you add movement no matter in what direction.

here one example, use either adder or accumulate

F_Dos's icon

Thanks! I need it to work as well with float numbers from a sensor so I just changes all integers to floats.

I try to filter some small flactuating in the input signal so if I have changes below to some value it will not continue to the output. how can I do so?

TFL's icon

I would put a [expr ($f1 > 0.1) * $f1] just after the first expr. The $f1 > 0.1 parts transforms into a 0 or 1 depending on the result of the comparison. The whole expression is equivalent to [if $f1 > 0.1 then $f1 else 0].

Or make both expressions in one: [expr (abs($f1-$f2) > 0.1) * abs($f1-$f2)]

Of course you could replace my 0.1 with an extra $f so you can change the threshold easily.

Source Audio's icon

round & change