Re: [Pipmak-Devel] another way of measuring the mouse speed
Status: Alpha
Brought to you by:
cwalther
From: Christian W. <cwa...@gm...> - 2008-01-12 15:09:41
|
Aidan Gauland wrote: > Okay, here is the patch (as an attachment) generated with the -u option, > as requested. I hope it will work better across different systems. Thanks! Applied as-is, it makes it completely impossible to get the mouse ungrabbed here on Mac OS X. I don't understand what you're doing here: // Calculate the elapsed time since we last did this, int elapsedTime = thisRedrawTime - lastMouseMoveTime; // and don't bother with these next steps if no time has passed. if (elapsedTime != 0) { ... That basically means, "don't bother if the mouse has moved in this main loop iteration". When the mouse moves fast, it usually does move in every iteration (here), so you're skipping the potential ungrabbing exactly in the situation where it would be needed. (Perhaps you meant to use lastTime instead of lastMouseMoveTime, in which case the test would only serve to guard against a division by 0 in the case of several mouse events per main loop iteration?) When I comment that test out, it works quite well. However, the threshold of 3.18 px/ms seems a bit high to me, to reproduce the previous behavior I subjectively have to set it to about 1.0, though I can go as far down as about 0.1 while still being able to easily reach the edge without triggering an ungrab. (In fact, the previous threshold of 20 px per mouse event, combined with the assumptions of mouse events in every iteration (which I get, you apparently don't) and a refresh rate of 60 Hz would lead to a value of 1.2 px/ms.) Why exactly 3.18, anyway (just out of curiosity)? Is that somehow distinguishable from, say, 3.0? Have you thought about using the unclamped mouse delta from the event (event.motion.xrel) instead of a clamped one (mouseX - lastX)? The difference would be that you could also ungrab with a swift mouse motion when you're already at the edge, you wouldn't have to step back first. I'm undecided which behavior is better. Come to think of it, we could probably use a threshold of 0. After all, the goal is not "reach the edge without triggering an ungrab", but "reach the edge, period". If we can make the grabbing transparent to the user, all the better. Have to try that on Windows and Linux... -Christian |