Sign in to follow this  
Servant of the Lord

SDL - Getting mouse input without events?

Recommended Posts

I'm not particularily fond of event queues, and prefer to get input states as opposed to events. Actually, I'm using GetAsyncKeyState for my input, and so am completely dodging SDL events as much as I can, and only using SDL for graphics and(eventually) sound. Is there some way I can get the cordinates of the mouse without the event queue? I can get mouse clicks easily enough, but I'm not sure how to get the position. Perferably with a simple function, and I really don't care if it's a SDL function or not. Alternately, I can get the absalute corridates of the mouse from the topleft corner of the monitor's screen. If I can find out where my application window is, I can get the corridnates based off that. I can't find either of them on libSDL.(Either the app corridinates, or the mouse position w/o using events) Any help is greatly apreciated!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This is something which I do also, but if you use the mousewheel then you have to catch them via the event loop as there is currently no other way of getting the wheel movements :(

Share this post


Link to post
Share on other sites
Thanks guys. Yeah I'm using SDL_PumpEvents and I have just switched out all my GetAsyncKeyState with SDL's SDL_GetKeyState (thanks Artum) as well, so as to have more crossplatformed code.

Luckily I haven't found a need for the mousewheel yet, so I haven't run across that hitch, AP, but thanks for the headsup!

Share this post


Link to post
Share on other sites
Quote:
Original post by Servant of the Lord
Thanks guys. Yeah I'm using SDL_PumpEvents and I have just switched out all my GetAsyncKeyState with SDL's SDL_GetKeyState (thanks Artum) as well, so as to have more crossplatformed code.

Luckily I haven't found a need for the mousewheel yet, so I haven't run across that hitch, AP, but thanks for the headsup!


You should still use PollEvent and grab SDL_Quit events, they can be generated in ways you dont expect. PollEvent calls PumpEvents internally, so you could replace the PumpEvents with a small poll-for-quit loop.

It wont affect your SDL_GetMouseState or SDL_GetKeyboardState either.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
You should still use PollEvent and grab SDL_Quit events, they can be generated in ways you dont expect. PollEvent calls PumpEvents internally, so you could replace the PumpEvents with a small poll-for-quit loop.

It wont affect your SDL_GetMouseState or SDL_GetKeyboardState either.


Thats a good idea. I'll add that later. I was wondering how I would allow people to hit [x] to close the window, without using PollEvent, but your way is good.

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

Sign in to follow this