How to get the initial mouse coords before moving the mouse?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the initial mouse coords before moving the mouse?

Andre
Hi everybody,

I have a problem with `SDL_GetMouseState`: I want to get the inital
mouse coords before the user moves the mouse, but the function only
returns 0 for the x and y coord.

I have attached a MWE that shows my problem. The first line that is
printed is always "init: 0, 0". I expected it to give the actual coords.

I tried this example under Linux only.

I really appreciate any help you can provide.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

sdl_mouse.c (824 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Faluk
Hi Andre,

Do you have the event system initialized?

PS. Can't see anything attached.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Andre
> Do you have the event system initialized?
Which function do you mean exactly? I called SDL_PumpEvents before
SDL_GetMouseState.

> PS. Can't see anything attached.
Mailman separated the attachment from my email. See
http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20161110/13c00070/attachment.c
for my attachment.
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Faluk
In reply to this post by Andre
Hi Andre,

The problem is that if the mouse is outside the window there is no data to get. If the SDL_GetMouseState is called while the window is inside the window you will get data. Try creating a bigger where the mouse is inside the window.

Smile

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Andre
> The problem is that if the mouse is outside the window there is no data
> to get. If the SDL_GetMouseState is called while the window is inside
> the window you will get data. Try creating a bigger where the mouse is
> inside the window.

I'm not talking about the case where the mouse is outside the program.

Run my attached program. Then remember the position of the window. Close
the program. Then move the mouse into the position where the window was
created last time. Start the program again.

Now you can see that the initial call of SDL_GetMouseState always
returns (0,0) although the mouse is inside the window.
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Faluk
In reply to this post by Andre







Andre wrote:







Quote:
The problem is that if the mouse is outside the window there is no data
to get. If the SDL_GetMouseState is called while the window is inside
the window you will get data. Try creating a bigger where the mouse is
inside the window.

I'm not talking about the case where the mouse is outside the program.

Run my attached program. Then remember the position of the window. Close
the program. Then move the mouse into the position where the window was
created last time. Start the program again.

Now you can see that the initial call of SDL_GetMouseState always
returns (0,0) although the mouse is inside the window.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Maybe is the library you are using. Your same code is is working perfectly for me:








Code:
init: 92, 120
move: 92, 120
move: 88, 114
move: 81, 103
move: 71, 89
move: 43, 52
move: 17, 23
move: 0, 0

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Andre
> Maybe is the library you are using. Your same code is is working perfectly for me:

Ok, then it's a bug.

Can you please tell me what operating system + DE + window manager you
are using, so I can provide this information in the bug report?
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Faluk
In reply to this post by Andre
I currently tested your code under windows 7. I will try it under linux during the weekend.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: How to get the initial mouse coords before moving the mouse?

Andre
Thank you very much for your help so far.

I filed a bug under https://bugzilla.libsdl.org/show_bug.cgi?id=3487
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org