Skip to content

SDL_GetMouseState always returns (0,0) before moving the mouse the first time #2303

@SDLBugzilla

Description

@SDLBugzilla

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.8
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2016-11-11 14:28:47 +0000, Andre wrote:

Created attachment 2611
MWE

I have a problem with SDL_GetMouseState: I want to get the initial mouse coordinate before the user moves the mouse the first time, but the function only returns (0,0) regardless of the actual mouse position.

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 coordinates.

This behavior can be reproduced under Linux 2.28.2 with GNOME shell 3.22.1 and the X window system. It works fine under Windows 7.

How to reproduce:

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 somewhere else inside the window.

On 2018-04-10 04:38:40 +0000, Thums wrote:

I have the same problem, SDL_GetMouseState always returns (0,0) until the mouse is moved for the first time since the program was opened.

Tested on Arch Linux, kernel 4.15.14-1 under i3wm.

Calling SDL_PumpEvents before obtaining the mouse state changes nothing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions