More new stuff for libgdx!

Mr. Thotep asked for mouse capturing and cursor invisibility. I added that today (besides a few other additions and fixes). Here’s how the new methods in Input look like:

The first method will make the cursor invisible on the desktop and make sure the mouse can’t leave the window. It works perfectly fine with the Lwjgl backend. For the Jogl backend i had to emulate this behaviour with Robot. Sadly, it will not work 100% if the mouse speeds are to fast: the mouse can escape the window in that case.

The second method’s function should be obvious. The third method allows you to position the mouse cursor within the window. That can come in handy for first person shooters where you usually center the mouse cursor in your window and only operate on deltas. But how to get the deltas? Looky:

Simple, eh? With all those nice additions we are nearing the 1.0 release with big steps. The last bits missing are the UI stuff i talked about earlier which i’ll try to integrate over the weekend, as well as finishing off the 3D API, which is also in a pretty good shape already.

Note: the cursor related methods in Input will of course only work on the desktop. The delta methods work on all backends! Finally, Gdx Remote needs an overhaul i don’t have time for at the moment to also implement the above methods. I’ll do that eventually, just not now. And the Angle backend also needs some love. Both things are recorded as issues on the tracker so i don’t forget them.

UI stuff tomorrow or on sunday if all goes well. Release of 0.9.2 with all the new stuff plus fixes on sunday 🙂 Use the nightlies for now.

Also, a shout-out to MatthiasM over at the #lwjgl channel for fixing a bug in Lwjgl we discovered today. I could have submitted a patch as well, but i was to lazy 😀 He’s also the guy that provides us with the awesome TWL UI library, go check it out (supported in libgdx!).

5 thoughts on “More new stuff for libgdx!

  1. OK so I tried using getDeltaX() and getDeltaY() and all it returns is either 0 or 1 (regardless of whether or not I reset the pointer location). Is there something you missed or am I doing something wrong :\ ?

  2. Maybe it’s a missunderstanding of how deltas work? A delta on the x- or y-axis is the difference in position between the last mouse/touch position and the current mouse/touch position.

  3. Nevermind. I tried it again and it worked fine. I guess I was doing something wrong the first time :\

    Sorry for being a pain.

  4. So I used SetCursorPosition passing in the deltaX and deltaY of mouse movements to do some rudimentary graphical cursor, constantly drawing an arrow texture at said position. With cursor catching enabled and some bounds checking to ensure the graphical cursor doesn’t fly off into space the effect is actually reasonably good.

    However, I notice a slight delay. It’s subtle but present. Is there a way to eliminate this? I’ve tried doing the mouse updates right before any other rendering, but there’s still a very very slight delay (i.e, when i stop moving the mouse the graphic of the mouse moves for what looks like maybe just one frame).

    Or am I just doing this completely incorrect?

  5. I really wish the mouse capturing was separate from mouse invisibility. My app uses windowed mode and a software cursor, so I want to hide the mouse without capturing it, but it seems impossible.

Leave a Reply

Your email address will not be published.