Is there any standard way to capture relative mouse input with jogl? From what I can tell I can only get absolute coordinates from the Event Listeners, but maybe I'm missing something.
An (ugly) workaround would be to simply place the cursor back in the center all the time, but I don't particularly like that idea. Also, what if I would want to capture some sub-pixel precision (not sure it's possible but I think if you go through a more raw system API for example API like DirectX I think you can do something like that) Any ideas, suggestions or hints on where I should start looking? I guess one could also Jni/Jna up some native solution, but I'd like to avoid that if possible. |
Administrator
|
Hi
Several free open source first person shooters use JOGL including jogl-shooter and TUER (mine). The way you get events depends on the canvas you use. Please look at my Ardor3D renderer based on JOGL 2, you will see how I do that with AWT and NEWT : http://gouessej.wordpress.com/2011/09/18/le-moteur-3d-ardor3d-fonctionne-desormais-avec-jogl-2-the-3d-engine-ardor3d-now-works-with-jogl-2/ Of course you don't need to add any new API to do that, it has worked fine for years, it is a common problem. You can use an approach based on events or JInput for JogAmp.
Julien Gouesse | Personal blog | Website
|
Ok maybe I wasn't clear enough.
I know how to get mouse events. What I do NOT know is how to get relative mouse movement events, I only know how to get events which tell me absolute x,y coordinates, so that I do not manually need to deal with wraparound Here is a dx-example : http://www.directxtutorial.com/tutorial9/e-directinput/dx9e2.aspx Or a lwjgl approach in their class "Mouse": setAbsolute(boolean ...) |
I see that in your Tuer game (early version with own engine) you handled wraparound like this:
/** * Contribution from Riven * @return */ public final Point getDelta(){ Point pointer=MouseInfo.getPointerInfo().getLocation(); int xDelta=pointer.x-centerx; int yDelta=pointer.y-centery; if(xDelta==0 && yDelta==0) {// robot caused this OR user did not do anything return(new Point(0,0)); } else {robot.mouseMove(centerx, centery); return(new Point(xDelta, yDelta)); } } I guess there is no native support to handle this with just JOGL? (like a mouse listener only reporting deltas?) Would be cool if we could also set DPI :) Hehe, I find myself posting a long feature request list.. |
Administrator
|
On 07/19/2012 04:45 PM, GiGurra [via jogamp] wrote:
> I see that in your Tuer game (early version with own engine) you handled > wraparound like this: > > /** > * Contribution from Riven > * @return > */ > public final Point getDelta(){ > Point pointer=MouseInfo.getPointerInfo().getLocation(); > int xDelta=pointer.x-centerx; > int yDelta=pointer.y-centery; > if(xDelta==0 && yDelta==0) > {// robot caused this OR user did not do anything > return(new Point(0,0)); > } > else > {robot.mouseMove(centerx, centery); > return(new Point(xDelta, yDelta)); > } > } > > > http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java;h=6aea5bb9c70a03527798eaea523cafabdb4fca77;hb=HEAD#l305 Check also it's main class Test*GearsES2* for usage/setup. > I guess there is no native support to handle this with just JOGL? (like a > mouse listener only reporting deltas?) Well, possible. We could also track it directly via NEWT and pass it along the Mouse/Pointer event. Reminds me of a request of querying the last known position. Please file an enhancement bug report including this conversation .. maybe you like to implement it ? > Would be cool if we could also set DPI :) Dunno how to do this platform independent. > ~Sven signature.asc (910 bytes) Download Attachment |
Excellent, thank you both for your answers. Now I know what I have to work with :P.
I guess warpPointer does not trigger a subsequent mouse event? |
Administrator
|
In reply to this post by GiGurra
I don't use Microsoft's APIs and I don't need to use the competitor of JOGL. You have found which part of the code does what you want in the alpha version of my game. If you need an example with NEWT, you will have to look at the renderer based on Ardor3D as I suggested:
http://sourceforge.net/p/ardor3d-jogl2/code/71/tree/trunk/ardor3d-jogl2/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseManager.java http://sourceforge.net/p/ardor3d-jogl2/code/71/tree/trunk/ardor3d-jogl2/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java
Julien Gouesse | Personal blog | Website
|
In reply to this post by Sven Gothel
One more thing: About helping out implementing new features/helping out maintaining the jogl/jocl projects it does sound interesting. But I'd prefer if we could talk a bit on msn or skype or similar before making such a decision.
On skype my name is "gigurra" and on msn you can reach me on "ancient_banana_tmuk+++A.T---hotmail[dot]com". NOTE: that address does NOT work for emailing :). |
Administrator
|
On 07/21/2012 05:40 PM, GiGurra [via jogamp] wrote:
> One more thing: About helping out implementing new features/helping out > maintaining the jogl/jocl projects it does sound interesting. But I'd prefer > if we could talk a bit on msn or skype or similar before making such a decision. > Why not using our jabber forum as posted on our contacts page ? I use pidgin as a client, which is available on most Unix [like] systems, as well as on Windows. ~Sven signature.asc (910 bytes) Download Attachment |
oh sry, I did not notice that :).
I have never used jabber before, I will try it as soon as possible. |
Administrator
|
You can use Jappix Mini, it is simple and you can use it anonymously:
https://mini.jappix.com/ If it is not enough, I will deploy our XMPP instant messaging software Jeti (which works on Linux, Mac, Unix and Windows).
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |