[Pipmak-Devel] another way of measuring the mouse speed

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

[Pipmak-Devel] another way of measuring the mouse speed

Aidan Gauland
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


Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
Aidan Gauland wrote:
>  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!

>  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.

>  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>
<http://pipmak.sourceforge.net/temp/pipmak.jpeg>

  -Christian



Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

Aidan Gauland
Okay, here is the patch (as an attachment) generated with the -u option, as requested.  I hope it will work better across different systems.

Christian Walther wrote:
Aidan Gauland wrote:
  
 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!

  
 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.

  
 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>
<http://pipmak.sourceforge.net/temp/pipmak.jpeg>

  -Christian


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Pipmak-Devel mailing list
[hidden email]
<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
https://lists.sourceforge.net/lists/listinfo/pipmak-devel

  

mouseSpeedMod.patch.bz2 (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
In reply to this post by cwalther
I wrote:
> 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



Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] indent

cwalther
Administrator
I wrote:
> - 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



Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
In reply to this post by cwalther
I wrote:

> - 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



Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
In reply to this post by Aidan Gauland
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



Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
I wrote:
> 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

Index: source/main.c
===================================================================
--- source/main.c (revision 172)
+++ source/main.c (working copy)
@@ -582,8 +582,8 @@
  case SDL_MOUSEMOTION:
  if (!(screen->flags & SDL_FULLSCREEN) && (SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
  /*ungrab if the mouse runs against the window edge hard enough*/
- if (mouseX == 0 && event.motion.xrel < -20 || mouseX == screen->w-1 && event.motion.xrel > 20
- || mouseY == 0 && event.motion.yrel < -20 || mouseY == screen->h-1 && event.motion.yrel > 20
+ if (mouseX == 0 && event.motion.xrel < 0 || mouseX == screen->w-1 && event.motion.xrel > 0
+ || mouseY == 0 && event.motion.yrel < 0 || mouseY == screen->h-1 && event.motion.yrel > 0
  ) {
  SDL_WM_GrabInput(SDL_GRAB_OFF);
  SDL_WarpMouse(mouseX, mouseY);
Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

Aidan Gauland
  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.  So if that's that, then...

 Is anyone working on the bug with mouse clicks during transitions?  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?

 -Aidan

Christian Walther wrote:
I wrote:
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

------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________ Pipmak-Devel mailing list [hidden email] <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 https://lists.sourceforge.net/lists/listinfo/pipmak-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

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?

 -Aidan

I wrote:
  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.  So if that's that, then...

 Is anyone working on the bug with mouse clicks during transitions?  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?

 -Aidan

Christian Walther wrote:
I wrote:
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

------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________ Pipmak-Devel mailing list [hidden email] <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 https://lists.sourceforge.net/lists/listinfo/pipmak-devel

------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________ Pipmak-Devel mailing list [hidden email] <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 https://lists.sourceforge.net/lists/listinfo/pipmak-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

Urs Holzer-2

> 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)



Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

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?

 And what do you all mean when you say "revision 170".  I'm using the source tarball I got from a link on this page:
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.

Urs Holzer wrote:
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)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pipmak-Devel mailing list
[hidden email]
<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
https://lists.sourceforge.net/lists/listinfo/pipmak-devel

  
Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

aviare
Hello!

You wrote:

  And what do you all mean when you say "revision 170".  I'm using the source tarball I got from a link on this page:
<a href="http://pipmak.sourceforge.net/downloads.php" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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


Let's save the little pipmak from the forgotten land!
Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
In reply to this post by Aidan Gauland
Aidan Gauland wrote:
>   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


Reply | Threaded
Open this post in threaded view
|

Re: [Pipmak-Devel] another way of measuring the mouse speed

cwalther
Administrator
In reply to this post by Aidan Gauland
Aidan Gauland wrote:
>  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.

>  And what do you all mean when you say "revision 170".  I'm using  
> the source tarball I got from a link on this page:
> 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