Jump to content
  • Advertisement
b2soft

C++ FPS-like mouse-look camera WinAPI problem

Recommended Posts

2 minutes ago, b2soft said:

in such case I need to manage focus states of the window

Well, checking if your application window is active is just another function call. I think this solution is much more convenient than fighting an event-based system which doesn't have games in mind. I don't really see any advantage in writing twenty lines of code to retrieve the cursor position. Especially not in a full-screen FPS where the only thing you need is just a mouse delta.

 

1 minute ago, JoeJ said:

Sounds interesting. But i guess you still have to use SetCursorPos, and a useless message is generated?

Yes, you'd still need SetCursorPos, but useless messages can be silently ignored. In fact, you are ignoring tons of messages anyway so this doesn't matter at all. Spy++ is a handy tool for monitoring such things BTW..

Share this post


Link to post
Share on other sites
Advertisement
8 minutes ago, Prototype said:

you are ignoring tons of messages anyway so this doesn't matter at all.

So OS is like Facebook, get it :D

Share this post


Link to post
Share on other sites
2 minutes ago, JoeJ said:

So OS is like Facebook, get it :D

More like Twitter, but you can't block anybody and you are obliged to retweet :)

Share this post


Link to post
Share on other sites
3 minutes ago, Prototype said:

More like Twitter, but you can't block anybody and you are obliged to retweet :)

actually, you can... :D own custom eventz for all!

just kidding.

 

Seems that checking for center-positioned mouse is OK for me

 

Thanks, mates

Share this post


Link to post
Share on other sites

Have you considered using raw input instead of win32 and using a virtual cursor instead? My engine works with both events and raw input and an input manager deals with things including providing an offset vector of how the cursor moved since the last frame.  So you could calculate your yaw and pitch from that and keep a little dot in the HUD in the center and hide the actual cursor?

Share this post


Link to post
Share on other sites
Just now, Jman2 said:

Have you considered using raw input instead of win32 and using a virtual cursor instead? My engine works with both events and raw input and an input manager deals with things including providing an offset vector of how the cursor moved since the last frame.  So you could calculate your yaw and pitch from that and keep a little dot in the HUD in the center and hide the actual cursor?

Yep, it's an option (DirectInput, XInput, something else), but I want to keep things simple for my sample, at least, for now,

Share this post


Link to post
Share on other sites

As mentioned earlier the Get/SetCursorPos can easily do the trick. Also don't forget to handle the WM_ACTIVATEAPP so when you hit alt-tab, or a system popup appears you can release the mouse. I don't remember if I had to deal with cursor visibility on focus change, though :( 

Also the SetCursorPos resets some internal counters, so call it only when you have some delta, otherwise it'll truncate the very small movements and your camera will be... hmm... what to say... :) 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!