How to read mouse positon when event queue empty?

How do I read current mouse cursor position given that all events have
been filtered out of the queue and no event has taken place since then ?

Meetul

Can you not just keep it from the previous value? it should still be the
same.

I copy to my display class for use by other functions.

Btw: has anyone used the mouse scroler? it is just an up and down button
I think in its implementation.

JG

Meetul Kinarivala wrote:>

How do I read current mouse cursor position given that all events have
been filtered out of the queue and no event has taken place since then ?

Meetul

The code is full of various event loops, sub-loops all scattered…Whenever I need mouse position, I use different local variables…thats why at many points in the code I don’t have the ‘previous’ value…And the code has just gotten complicated enough to make mouse position variables global.> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of J
Grant
Sent: Friday, October 05, 2001 1:34 AM
To: sdl at libsdl.org
Subject: Re: [SDL] how to read mouse positon when event queue empty ?

Can you not just keep it from the previous value? it should still be the
same.

I copy to my display class for use by other functions.

Btw: has anyone used the mouse scroler? it is just an up and down button
I think in its implementation.

JG

Meetul Kinarivala wrote:

How do I read current mouse cursor position given that all events have
been filtered out of the queue and no event has taken place
since then ?

Meetul


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Maybe you should think about your design?
Only a sugestion!

    Alil

Meetul Kinarivala wrote:> The code is full of various event loops, sub-loops all scattered…Whenever I need mouse position, I use different local variables…thats why at many points in the code I don’t have the ‘previous’ value…And the code has just gotten complicated enough to make mouse position variables global.

-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of J
Grant
Sent: Friday, October 05, 2001 1:34 AM
To: sdl at libsdl.org
Subject: Re: [SDL] how to read mouse positon when event queue empty ?

Can you not just keep it from the previous value? it should still be the
same.

I copy to my display class for use by other functions.

Btw: has anyone used the mouse scroler? it is just an up and down button
I think in its implementation.

JG

Meetul Kinarivala wrote:

How do I read current mouse cursor position given that all events have
been filtered out of the queue and no event has taken place
since then ?

Meetul


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I believe you want the SDL_GetMouseState function.

Zephaniah E. Hull.On Fri, Oct 05, 2001 at 01:51:00AM -0700, Meetul Kinarivala wrote:

The code is full of various event loops, sub-loops all
scattered…Whenever I need mouse position, I use different local
variables…thats why at many points in the code I don’t have the
’previous’ value…And the code has just gotten complicated enough to
make mouse position variables global.


1024D/E65A7801 Zephaniah E. Hull <@Zephaniah_E_Hull>
92ED 94E4 B1E6 3624 226D 5727 4453 008B E65A 7801
CCs of replies from mailing lists are requested.

“First they came for the fourth amendment, but I said nothing because I
wasn’t a drug dealer. Then they came for the sixth amendment, but I kept
quiet because I wasn’t guilty. Finally they came for the first
amendment, and by then it was too late to say anything at all.”

No, the design is very modular…Some programmers prefer a one huge event
loop that encloses the complete game…Others prefer small modular loops that
accomplish certain tasks and a good design is to keep the event variables
local. Mine is a board game with different modes like ‘mission’, ‘single
player’ and ‘editor’ mode.>

Maybe you should think about your design?
Only a sugestion!

    Alil

SDL_PumpEvents();
SDL_GetMouseState(&mouse_x, &mouse_y);On Thu, Oct 04, 2001 at 11:41:20PM -0700, Meetul Kinarivala wrote:

How do I read current mouse cursor position given that all events have
been filtered out of the queue and no event has taken place since then ?

Meetul


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Martin

Bother, said Pooh, as Soran destroyed the nearby sun.

Thanks, Martin and Zephaniah…It worked…But SDL_GetMouseState(…) is not in
the function list in the docs!!

How do I read current mouse cursor position given that all events have
been filtered out of the queue and no event has taken place since then ?

SDL_GetMouseState()

–ryan.

It is in the event functions subsection:
See http://sdldoc.csn.ul.ie/eventfunctions.php
and http://sdldoc.csn.ul.ie/sdlgetmousestate.phpOn Friday 05 October 2001 14:58, Meetul Kinarivala wrote:

Thanks, Martin and Zephaniah…It worked…But SDL_GetMouseState(…) is not
in the function list in the docs!!


Johannes Schmidt

< http://libufo.sourceforge.net > Your widget set for OpenGL

Actually, you may also be ignoring or filtering the mouse events (I can think
of one or two reasons you’d want to do this).

You can always use SDL_GetMouseState(…)

int x,y;
Uint8 state;
state = SDL_GetMouseState(&x, &y);

will get you the current mouse position without a event queue entry.

(Is SDL_GetMouseState(…) undocumented? I couldn’t find it in the SDL docs
just now ;-)On Friday 05 October 2001 1:33, J Grant wrote:

Can you not just keep it from the previous value? it should still be the
same.


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Tux4Kids: < http://www.geekcomix.com/tux4kids/ >

A previous post told me that it is under the hyperlink “Event Functions” …
Though it would be better (for new users) if all functions list were on a
single page.> (Is SDL_GetMouseState(…) undocumented? I couldn’t find it in

the SDL docs
just now :wink: