Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cmc5788

Pages: [1]
1
Feature requests / Mouse capture/grab
« on: April 02, 2011, 08:09:30 pm »
Quote from: "kattle87"
What we could do is having the "mouse deltas" as a readly-available feature, giving the user float values calculated by sfml using velocity or position means. This way, one would have not to do anything but calling a function for getting "precise" and not-stuttering movements :P


This would simplify things a little bit.  However, for real mouse look you'll still need to reset the cursor every frame to make sure that it doesn't leave the window or get stuck on its edges.  You can't have any deltas if your mouse isn't moving ;)

2
Feature requests / Mouse capture/grab
« on: April 01, 2011, 07:07:47 pm »
Well, as embarrassing as this is, it looks like I jumped the gun a bit on blaming SFML.  I rewrote my code in simplified form to submit, and the bug disappeared.  I don't know what was causing it, and I'm not sure if I'll ever find out.

By way of apology, I'll submit a nice tutorial on implementing smoothed mouse look using the weighted mean of velocities to the wiki.

P.S. -- we still want cursor grabbing ;)

3
Feature requests / Mouse capture/grab
« on: March 31, 2011, 09:34:25 pm »
Quote from: "Tank"
Quote from: "cmc5788"
I can do that very easily, I'll just set a #define in my current code to toggle between SFML GetMouseX/Y and the Windows code

Sorry for being off-topic, but that is just hilarious. :D What it's called, "ENABLE_BUG"? ;)


Now that you mentioned it, I think I -will- call it that.

4
Feature requests / Mouse capture/grab
« on: March 31, 2011, 03:38:29 pm »
Quote from: "Laurent"
Quote
I understand that the design would be slightly inconsistent, but I think that having an "elegantly designed" function that returns values other than those expected is orders of magnitude worse than having a single function whose design is inconsistent from others of the type for reasons of usability.

I was not comparing it to the current code. I just said that as a user, seeing an API with two functions that do the same thing is not consistent/elegant/whatever.

So I didn't mean to keep the current function unchanged, but rather than fixing it with something that I don't like, I prefer trying to find a solution which is globally better (even if it means redesigning half of the window module).

I think the first thing to do is to examinate this "lag" problem before throwing away the whole event-based implementation; just to be sure, you know ;)

Would be very cool if you could provide a minimal code that shows the problem (with low FPS simulated) so that I can test it myself and use it as a starting point for improving mouse handling.


I can do that very easily, I'll just set a #define in my current code to toggle between SFML GetMouseX/Y and the Windows code.  I'll post it soon.

5
Feature requests / Mouse capture/grab
« on: March 31, 2011, 02:54:40 pm »
Quote from: "Laurent"
Quote
What's wrong with just implementing it for mouse?

Inconsistent design.
And it works only for mouse position, everything else (mouse buttons, keyboard, joysticks, ...) would produce the kind of problems that I described in my previous posts.


I understand that the design would be slightly inconsistent, but I think that having an "elegantly designed" function that returns values other than those expected is orders of magnitude worse than having a single function whose design is inconsistent from others of the type for reasons of usability.

Anecdotally, I spent a solid off-day of programming time trying to figure out why my mouse look was degrading precisely because "GetMouseX" sounds as though it should return, with as much precision as possible, the X value of the mouse.  As a client of the library, my application expects the function to work as-advertised, not to be consistent with its own internal state.  One major benefit of separating interface from implementation is that, as a user, I shouldn't CARE about inconsistent implementation so long as results are consistent with expectations.  In that way, I would make the argument that changing it is more elegant design.

As far as I can tell, -only- mouse coordinates would need to be changed in this way since they tend to be used for very time-sensitive tasks, none of the other variables that would produce problems would need to even be touched.

Quote
Quote
Just bear in mind that supporting mouse look is fairly important for anything that can be used as an OpenGL context.

That's right. I need to think more about this issue; providing mouse grab features would also be a solution.


Actually that isn't a solution, that's only part of the solution.  Mouse grab only confines the cursor to the window area; you still need a way of resetting the cursor every-so-often so that it doesn't wind up sticking to the borders.  The most-common way of doing this involves resetting it every frame to the center of the screen.  Mouse grab simply ensures that at low FPS your cursor won't "flicker" off-screen before it's reset.  You still need to ensure that it's reset to center (or some other location sufficiently far from the window borders) so that mouselook works properly.

If you were to provide mouse grab for mouse look support, you would also need to include an an abstracted way of returning an accurate mouse velocity per-frame.  If you can think of a good way to do this without resorting to cursor reset, then you're better than me.  (I also tried "wrapping" the mouse from the right border back around to the left, and top to bottom, etc., but that introduces its own set of problems)

edit:  Sorry for the mild rant, and thank you for your responses ;)

6
Feature requests / Mouse capture/grab
« on: March 31, 2011, 09:15:38 am »
What's wrong with just implementing it for mouse?  With keyboard response I don't see it being an issue.  Or just keep the current system in-place but also implement an alternative "GetImmediate__" series of functions to clarify the difference.

Just bear in mind that supporting mouse look is fairly important for anything that can be used as an OpenGL context.

7
Feature requests / Mouse capture/grab
« on: March 31, 2011, 01:43:41 am »
Just missed my edit, I reached the same conclusion.  I suppose it would be good if SFML had support for immediate querying via something like

Code: [Select]

POINT cursor_pos;
HWND sys_handle = window.GetSystemHandle();
GetCursorPos(&cursor_pos);
ScreenToClient(sys_handle, &cursor_pos);


which is what I used in my code to fix the delay.

e:  when I get a little farther on my project I'll compile the workarounds I've had to use into a separate feature request thread.

8
Feature requests / Mouse capture/grab
« on: March 31, 2011, 01:30:13 am »
Quote from: "Tank"
Well SFML does also use platform-specific code. :) The question is where's the difference? Maybe SFML can be enhanced in this case.


I'm not sure where the difference is, I haven't had a good look at SFML's code.  I can just tell you for sure that there's significant lag in reporting between Input::GetMouseX() and the Windows-specific GetCursorPos (or perhaps the difference is between the cursor-position setting functions).

edit: --------

Having now looked at the SFML code a little bit, I can surmise that the lag has to do with Input::myMouseX and myMouseY only being updated on MouseMove events.  The Windows-specific equivalent immediately queries the mouse state as tracked by the operating system, and is likely independent of the event system.

9
Feature requests / Mouse capture/grab
« on: March 30, 2011, 08:32:59 pm »
One more note on this topic:

Input's GetMouseX() and GetMouseY() functiosn are not accurate/quick enough to support the "snap to center screen every frame" method of mouselook.

I was wonder why my mouselook code was degenerating at lower FPS, and replacing these with Windows-specific code completely fixed the problem.  Not sure why this is, but in case anyone else is having trouble, you should definitely use platform-specific code for something as time-sensitive as getting and setting the mouse cursor location every frame.

10
Feature requests / Mouse capture/grab
« on: March 29, 2011, 07:18:12 pm »
Quote from: "Tank"
Would be nice if you could add that to the wiki.


I will once I clean it up.  Unfortunately, I had to resort to some Windows-specific functions to make sure that the program played nice with alt-tabbing.

It would really be nice if SFML exposed some of the functionality to check on more nuanced window states.  I discovered that windows has a "minimized but active" state that sends a FocusGained event, but keeps the window minimized.  I had to manually check for that specific window state to make sure that my mouselook code didn't try to hijack the mouse cursor when this happened.

Specifically, I'm referring to this GetWindowPlacement function.  It would be really nice if SFML had a wrapper around this.

11
Feature requests / Mouse capture/grab
« on: March 29, 2011, 02:09:06 am »
EDIT:

So, I solved the problem this post was originally about.

If anyone else is having trouble getting mouse look to work with SFML and OpenGL, I'd be willing to upload my code, which handles restricting the mouse to the window and translating the mouse X and Y velocities into mouse look.  Also it seems to function properly with alt-tab and minimizing, which was hell to figure out.  Just let me know if anyone is interested.

Pages: [1]