Login  Register

Re: Capturing relative mouse input (for 1st person shooters etc)

Posted by Sven Gothel on Jul 19, 2012; 3:01pm
URL: https://forum.jogamp.org/Capturing-relative-mouse-input-for-1st-person-shooters-etc-tp4025593p4025600.html

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));
>            }      
>     }
>
>
>
Here is one w/ NEWT's confined pointer and warping it back ..

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