Discussion:
[Pipmak-Devel] another way of measuring the mouse speed
Aidan Gauland
2008-01-10 03:12:57 UTC
Permalink
Hello again,

My father (who is much more experienced in C, and programming in
general than I am), and I have come up with another way of measuring the
rate at which the mouse hits the edge of the window in Pipmak. I won't
bore you with all the details, but we measure the time between mouse
events, and then use that to calculate the speed of the mouse, and use
THAT to decide if the mouse should be ungrabbed. The code for
regrabbing the mouse is still the same though. This will, of course,
need to be tested on at least one other system, before it could be
considered for the next official release of Pipmak.

But before I generate a patch, I want to know if you have a set of
rules for indentation of the Pipmak code, that I could use with the
program "indent" to make sure the indentation in the patch is consistent
with the existing code. If emacs (the text editor I use) had a
pre-defined indentation style that matched the Pipmak source, then I
would have used that when editing the code, but, unfortunately, it didn't.

And by the way, where did Pipmak get its name from?

Regards,
Aidan
Christian Walther
2008-01-10 20:26:58 UTC
Permalink
Post by Aidan Gauland
My father (who is much more experienced in C, and programming in
general than I am), and I have come up with another way of measuring the
rate at which the mouse hits the edge of the window in Pipmak.
Cool!
Post by Aidan Gauland
But before I generate a patch, I want to know if you have a set of
rules for indentation of the Pipmak code, that I could use with the
program "indent" to make sure the indentation in the patch is consistent
with the existing code.
To date no such rules exist. I have never used indent on Pipmak. But I
can see if I can come up with a set of rules that approximately match my
coding style. That would obviously be useful for contributors. I don't
insist that everyone use exactly my style, but it would still be nice to
keep a certain consistency.
Post by Aidan Gauland
And by the way, where did Pipmak get its name from?
The name comes from the pipmak, which is the thing depicted in Pipmak's
logo. I made up the word "pipmak" for that when I was a child (or maybe
my father or my sister did, don't remember). Now what's a pipmak? A
movie and a picture say more than a thousand words:
<http://pipmak.sourceforge.net/temp/pipmak.mov>
<Loading Image...>

-Christian
Aidan Gauland
2008-01-12 09:13:42 UTC
Permalink
Christian Walther
2008-01-12 15:09:29 UTC
Permalink
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
Christian Walther
2008-01-13 19:50:37 UTC
Permalink
Post by Christian Walther
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...
OK, I just checked:

- I don't have any problems ungrabbing with the existing code on Linux
(that doesn't mean that there is no problem, of course, but it explains
why I haven't noticed and fixed it before).

- The zero threshold solution seems to work quite well on Windows and
Linux. You can't slide the Pipmak cursor along the window edge anymore,
but I'm not sure that's necessary. Can you try the attached patch and
see if you like that behavior?

-Christian
Aidan Gauland
2008-01-15 02:59:29 UTC
Permalink
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
&nbsp;
I applied the patch, and it works perfectly fine on my system.&nbsp; I also
added a printf() just after each call to SDL_WM_GrabInput, so I could
confirm that Pipmak was grabbing and releasing the mouse when it
should.&nbsp; And yes, I do like that behaviour.&nbsp; So if that's that, then...<br>
<br>
&nbsp;Is anyone working on the bug with mouse clicks during transitions?&nbsp; If
not, then where could I start on that one?&nbsp; I know where the event
handling case statement is for mouse clicks (at least, I think it's
near the one for mouse motion events), but where is the code for
display transitions?<br>
<br>
&nbsp;-Aidan<br>
<br>
Christian Walther wrote:
<blockquote cite="mid:fmdq2i$n1m$***@ger.gmane.org" type="cite">I wrote: <br>
<blockquote type="cite">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... <br>
</blockquote>
<br>
OK, I just checked: <br>
<br>
- I don't have any problems ungrabbing with the existing code on Linux
(that doesn't mean that there is no problem, of course, but it explains
why I haven't noticed and fixed it before). <br>
<br>
- The zero threshold solution seems to work quite well on Windows and
Linux. You can't slide the Pipmak cursor along the window edge anymore,
but I'm not sure that's necessary. Can you try the attached patch and
see if you like that behavior? <br>
<br>
&nbsp;-Christian <br>
<pre wrap=""><pre wrap=""><hr size="4" width="90%">
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
<a class="moz-txt-link-freetext"
href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace">http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace</a></pre><pre
wrap=""><hr size="4" width="90%">
_______________________________________________
Pipmak-Devel mailing list
<a class="moz-txt-link-abbreviated"
href="mailto:Pipmak-***@lists.sourceforge.net">Pipmak-***@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext"
href="news://news.gmane.org/gmane.games.devel.pipmak.devel">news://news.gmane.org/gmane.games.devel.pipmak.devel</a>
<a class="moz-txt-link-freetext"
href="https://lists.sourceforge.net/lists/listinfo/pipmak-devel">https://lists.sourceforge.net/lists/listinfo/pipmak-devel</a></pre></pre>
</blockquote>
</body>
</html>
Aidan Gauland
2008-01-16 03:52:56 UTC
Permalink
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
&nbsp;Hmmm, I've just discovered a... well, bug really, which I didn't
notice when I wrote this last message.&nbsp; If I move the mouse when Pipmak
is launching, then for the rest of that Pipmak session, it is
impossible to get the mouse out of the window, even WITH the zero
threshold.&nbsp; I have no idea where to start looking for the cause of this
one.&nbsp; Do you?<br>
<br>
&nbsp;-Aidan<br>
<br>
I wrote:
<blockquote cite="mid:***@ihug.co.nz" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
&nbsp;
I applied the patch, and it works perfectly fine on my system.&nbsp; I also
added a printf() just after each call to SDL_WM_GrabInput, so I could
confirm that Pipmak was grabbing and releasing the mouse when it
should.&nbsp; And yes, I do like that behaviour.&nbsp; So if that's that, then...<br>
<br>
&nbsp;Is anyone working on the bug with mouse clicks during transitions?&nbsp; If
not, then where could I start on that one?&nbsp; I know where the event
handling case statement is for mouse clicks (at least, I think it's
near the one for mouse motion events), but where is the code for
display transitions?<br>
<br>
&nbsp;-Aidan<br>
<br>
Christian Walther wrote:
<blockquote cite="mid:fmdq2i$n1m$***@ger.gmane.org" type="cite">I
wrote: <br>
<blockquote type="cite">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... <br>
</blockquote>
<br>
OK, I just checked: <br>
<br>
- I don't have any problems ungrabbing with the existing code on Linux
(that doesn't mean that there is no problem, of course, but it explains
why I haven't noticed and fixed it before). <br>
<br>
- The zero threshold solution seems to work quite well on Windows and
Linux. You can't slide the Pipmak cursor along the window edge anymore,
but I'm not sure that's necessary. Can you try the attached patch and
see if you like that behavior? <br>
<br>
&nbsp;-Christian <br>
<pre wrap=""><pre wrap=""><hr size="4" width="90%">
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace">http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace</a></pre><pre
wrap=""><hr size="4" width="90%">
_______________________________________________
Pipmak-Devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:Pipmak-***@lists.sourceforge.net">Pipmak-***@lists.sourceforge.net</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="news://news.gmane.org/gmane.games.devel.pipmak.devel">news://news.gmane.org/gmane.games.devel.pipmak.devel</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://lists.sourceforge.net/lists/listinfo/pipmak-devel">https://lists.sourceforge.net/lists/listinfo/pipmak-devel</a></pre></pre>
</blockquote>
<pre wrap="">
<hr size="4" width="90%">
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
<a class="moz-txt-link-freetext" href="http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace">http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace</a></pre>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Pipmak-Devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pipmak-***@lists.sourceforge.net">Pipmak-***@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext" href="news://news.gmane.org/gmane.games.devel.pipmak.devel">news://news.gmane.org/gmane.games.devel.pipmak.devel</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/pipmak-devel">https://lists.sourceforge.net/lists/listinfo/pipmak-devel</a></pre>
</blockquote>
</body>
</html>
Urs Holzer
2008-01-16 08:30:52 UTC
Permalink
Post by Aidan Gauland
Hmmm, I've just discovered a... well, bug really, which I didn't
notice when I wrote this last message. If I move the mouse when
Pipmak is launching, then for the rest of that Pipmak session, it is
impossible to get the mouse out of the window, even WITH the zero
threshold. I have no idea where to start looking for the cause
of this one. Do you?
Ha! You are great. I checked that, and here is what happens on my
system: If the mouse is outside of the window of pipmak when pipmak
starts, pipmak grabs the mouse and puts it inside its window. Then, it
is impossible to free the mouse during the whole pipmak session.
On the other hand, if the mouse is already where pipmak's window will
appear, and I start pipmak, then the mouse can be freed during the
whole session.

(I am working on Linux, using revision 170. I didn't test with zero
threshold)
Aidan Gauland
2008-01-17 00:09:34 UTC
Permalink
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
&nbsp;I see it does the same on my system, now that I look more closely.&nbsp;
But, I have NO IDEA where to start looking in the source code for this
one.&nbsp; Maybe, not grabbing the mouse as soon as Pipamk starts, but
grabbing the mouse when it is moved into the window, just as would be
done for the rest of the session, would remove this problem.&nbsp; But when
in the code does Pipmak grab the mouse for the first time?<br>
<br>
&nbsp;And what do you all mean when you say "revision 170".&nbsp; I'm using the
source tarball I got from a link on this page:<br>
<a class="moz-txt-link-freetext" href="http://pipmak.sourceforge.net/downloads.php">http://pipmak.sourceforge.net/downloads.php</a><br>
I'm sorry if this seems like a silly question, but I haven't been
involved with an open source project before.<br>
<br>
Urs Holzer wrote:
<blockquote cite="mid:fmkfbs$d11$***@ger.gmane.org" type="cite">
<blockquote type="cite">
<pre wrap="">Hmmm, I've just discovered a... well, bug really, which I didn't
notice when I wrote this last message. If I move the mouse when
Pipmak is launching, then for the rest of that Pipmak session, it is
impossible to get the mouse out of the window, even WITH the zero
threshold. I have no idea where to start looking for the cause
of this one. Do you?
</pre>
</blockquote>
<pre wrap=""><!---->
Ha! You are great. I checked that, and here is what happens on my
system: If the mouse is outside of the window of pipmak when pipmak
starts, pipmak grabs the mouse and puts it inside its window. Then, it
is impossible to free the mouse during the whole pipmak session.
On the other hand, if the mouse is already where pipmak's window will
appear, and I start pipmak, then the mouse can be freed during the
whole session.

(I am working on Linux, using revision 170. I didn't test with zero
threshold)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
<a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/</a>
_______________________________________________
Pipmak-Devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pipmak-***@lists.sourceforge.net">Pipmak-***@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext" href="news://news.gmane.org/gmane.games.devel.pipmak.devel">news://news.gmane.org/gmane.games.devel.pipmak.devel</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/pipmak-devel">https://lists.sourceforge.net/lists/listinfo/pipmak-devel</a>

</pre>
</blockquote>
</body>
</html>
Andrea Viarengo
2008-01-17 08:57:23 UTC
Permalink
Hello!

You wrote:

And what do you all mean when you say "revision 170". I'm using the
Post by Aidan Gauland
http://pipmak.sourceforge.net/downloads.php
I'm sorry if this seems like a silly question, but I haven't been involved
with an open source project before.
The source tarball that you have downloaded Corresponds approximately at
"revision 144", the official release,but you can found a newer version
(of-course, still in a development stage), in the subversion repository,
check at http://pipmak.svn.sourceforge.net/viewvc/pipmak/trunk/?view=log

Actually th last revision is the 172, which have a lot of improvement
respect official 0.2.6, like:

- patches 3D placement
- image manipulation methods (newimage, color, fill,...)
- possibility to write text into image (drawtext,....)
- new Lua Command line tool
- new Lua Table inspector
- error traceback
- new methods to manage full screen
- program icons association (hust for Windows...)
- some bugs corrections

if you want to get the last revision, you need a subversion client,
check my tutorial in the wiki, sorry it's only for Windows, but in Linux,
the operations are similar,

http://pipmak.sourceforge.net/wiki/index.php/MSVC8_Build#Get_pipmak_SVN

Tortoise is a client just for Windows, you have to download another
SVN-client (check at http://sourceforge.net/docs/B01/en/#svn_client )

You can try with this: http://subversion.tigris.org/

Once the program is installed, you need to pass to the svn-client, just
these informations:

Repository: https://pipmak.svn.sourceforge.net/svnroot/pipmak/trunk/pipmak
Revision number: put HEAD or 172

Bye

Andrea
Christian Walther
2008-01-20 07:53:26 UTC
Permalink
Post by Aidan Gauland
I see it does the same on my system, now that I look more closely.
But, I have NO IDEA where to start looking in the source code for
this one. Maybe, not grabbing the mouse as soon as Pipamk starts,
but grabbing the mouse when it is moved into the window, just as
would be done for the rest of the session, would remove this
problem. But when in the code does Pipmak grab the mouse for the
first time?
The first grab happens on main.c line 484, just before entering the
main loop. I have no idea why that would prevent later ungrabbing when
the mouse was outside of the window at that time. Let me know what you
find out.
Post by Aidan Gauland
And what do you all mean when you say "revision 170". I'm using
http://pipmak.sourceforge.net/downloads.php
I'm sorry if this seems like a silly question, but I haven't been
involved with an open source project before.
Not a silly question. Welcome to the world of revision control, a very
useful tool in collaborative (and even solitary) software development!
A revision control tool stores the whole history of the source code of
the project, it lets you go back and forth in time and review who did
what, when, and why. It also makes it easy to review (and undo) the
changes to the code you have made in your personal copy.

Pipmak uses Subversion (SVN) for revision control, like many other
projects nowadays (Side node: I've played with the idea of setting up
a Bazaar branch mirroring our Subversion repository at launchpad.net.
Would anyone be interested in this?). A very good resource for
learning about Subversion is the SVN Book ("Version Control with
Subversion") at <http://svnbook.red-bean.com>.

To get started, you need to install a Subversion client. On Linux, you
will probably want to use the command line client. You're on Debian,
right? Try "apt-get install subversion".

Run "svn checkout https://pipmak.svn.sourceforge.net/svnroot/pipmak/trunk/pipmak
" to download a copy of the current Pipmak source code. This will get
you approximately what you have in your source tarball, but with the
addition that you can run "svn status" to see your local changes, "svn
update" to update to the latest code from the repository, "svn diff"
to generate patches, and many more. You can't currently do "svn
commit" to send your changes back to the repository (only I can do
that), but I will give you that privilege if I come to the conclusion
that your contributions are of sufficient frequency and quality that
it would be more work for me to apply your patches than to let you
commit them yourself.

-Christian

Christian Walther
2008-01-20 07:50:15 UTC
Permalink
I applied the patch, and it works perfectly fine on my system. I
also added a printf() just after each call to SDL_WM_GrabInput, so I
could confirm that Pipmak was grabbing and releasing the mouse when
it should. And yes, I do like that behaviour.
Fine, then I'll commit that. I'm sorry you had to do all the hard work
with timing and stuff before we found that simple solution.
Is anyone working on the bug with mouse clicks during transitions?
Not that I know of. I expect that to be a simple one. One thing you
should double-check is if there are any hidden assumptions in the code
along the lines of "there's exactly one mouse up event for every mouse
down event", which you could violate by ignoring some events. Off the
top of my head, I'd say this is already taken care of by the code that
does things like coalescing multiple mouse buttons into one, but it
can't hurt to check that nothing unexpected happens when e.g. the
mouse goes down during a transition and up after it, or down before
and up during.
If not, then where could I start on that one? I know where the
event handling case statement is for mouse clicks (at least, I think
it's near the one for mouse motion events), but where is the code
for display transitions?
Check the switch statement in the last few lines of main.c. Depending
on whether a transition is in progress, redrawGL() is called there
either with an argument of 1.0 ("render normally") or with an argument
between 0.0 and 1.0 ("render a transition effect").

A case-insensitive search for "transition" in the whole source code
may help you get an overview too.

-Christian
Christian Walther
2008-01-12 12:55:46 UTC
Permalink
I can see if I can come up with a set of rules that approximately match my coding style.
So far I haven't had much success with GNU indent 2.2.9 - I have come up
with the options

-br -brs -npsl -l1000 -npcs -ncs -ut -c0 -cd0 -cp0

(plus a whole bunch of '-T xyz' to make it recognize casts and tell
pointer * from multiplication) but there are still several things wrong:

- I specify -br, but it still changes

int func() {
return 5;
}

to

int func()
{
return 5;
}

- I specify -ut, but it still changes my indenting tabs into spaces
(but, curiously, it changes spaces between code and comments into tabs).

- I haven't found a way of stopping it from changing

if (a) b();

to

if (a)
b();

(if anything, it should change it to

if (a) {
b();
}

)

Unless you can help me with these, I fear we have to give up the idea of
using indent.

-Christian
Christian Walther
2008-01-12 13:08:29 UTC
Permalink
Post by Christian Walther
- I specify -ut, but it still changes my indenting tabs into spaces
OK, I fixed that one, by using -ut -i2 -ts2. I hadn't realized that
there were separate -i and -ts options.

-Christian
Christian Walther
2008-01-12 13:24:04 UTC
Permalink
Post by Christian Walther
- I specify -br, but it still changes
int func() {
return 5;
}
to
int func()
{
return 5;
}
Ah, got that one too, with the help of the bug-indent mailing list
archives. That's the undocumented -brf option.

-Christian
Loading...