Inconsistancy in API between 1.2 and 1.3 for SDL_GetMouseState

SDL_GetMouseState in 1.2 looks like this:
Uint8 SDL_GetMouseState (int* x, int* y);

SDL_GetMouseState in 1.3 looks like this:
Uint8 SDL_GetMouseState (int index, int* x, int* y);

SDL_GetMouseState in 1.3 should look like this:
Uint8 SDL_GetMouseState (int* x, int* y);

and work like this:
SDL_SelectMouse (index);
button = SDL_GetMouseState (&x, &y);

Filed as bug 758 ( http://bugzilla.libsdl.org/show_bug.cgi?id=758 ).

Kenneth Bull wrote:

SDL_GetMouseState in 1.2 looks like this:
Uint8 SDL_GetMouseState (int* x, int* y);

SDL_GetMouseState in 1.3 looks like this:
Uint8 SDL_GetMouseState (int index, int* x, int* y);

SDL_GetMouseState in 1.3 should look like this:
Uint8 SDL_GetMouseState (int* x, int* y);

and work like this:
SDL_SelectMouse (index);
button = SDL_GetMouseState (&x, &y);

I strongly disagree.

Stateful APIs are old-hat; they’re less conducive to good threaded
design - you would have to have a critical section AROUND a call to
SDL_SelectMouse() && SDL_GetMouseState to ensure that another thread
didn’t change the mouse you’re trying to inspect.

Also, why do with two function calls, something that can be done with one?

Filed as bug 758 ( http://bugzilla.libsdl.org/show_bug.cgi?id=758 ).

This is not a bug anyway - it is a design decision; please discuss it on
the mailing list before filing a bug report :slight_smile:

Eddy

This is a bug due to the inconsistent API and source documentation.
If you want a single function which takes a mouse index and returns the mouse
state, call it something else, like SDL_GetMouseStateEx or similar.

Please read the comments on the bug report before posting complaints about it
to the mailing list.On Saturday, 4 July 2009 06:51:56 Edward Cullen wrote:

I strongly disagree.

Stateful APIs are old-hat; they’re less conducive to good threaded
design - you would have to have a critical section AROUND a call to
SDL_SelectMouse() && SDL_GetMouseState to ensure that another thread
didn’t change the mouse you’re trying to inspect.

Also, why do with two function calls, something that can be done with one?

Filed as bug 758 ( http://bugzilla.libsdl.org/show_bug.cgi?id=758 ).

This is not a bug anyway - it is a design decision; please discuss it on
the mailing list before filing a bug report :slight_smile:

Eddy

Okay, Ryan and I discussed it, and we’re agreed that functions that operate
on a device context (window, joystick, texture, etc.) should take that
context as a parameter.

I’m going to go through the SDL 1.3 API soon and overhaul it to reduce the
number of global variables that it keeps around.

Thanks for the feedback!On Sat, Jul 4, 2009 at 5:51 AM, Kenneth Bull wrote:

On Saturday, 4 July 2009 06:51:56 Edward Cullen wrote:

I strongly disagree.

Stateful APIs are old-hat; they’re less conducive to good threaded
design - you would have to have a critical section AROUND a call to
SDL_SelectMouse() && SDL_GetMouseState to ensure that another thread
didn’t change the mouse you’re trying to inspect.

Also, why do with two function calls, something that can be done with
one?

Filed as bug 758 ( http://bugzilla.libsdl.org/show_bug.cgi?id=758 ).

This is not a bug anyway - it is a design decision; please discuss it on
the mailing list before filing a bug report :slight_smile:

Eddy

This is a bug due to the inconsistent API and source documentation.
If you want a single function which takes a mouse index and returns the
mouse
state, call it something else, like SDL_GetMouseStateEx or similar.

Please read the comments on the bug report before posting complaints about
it
to the mailing list.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC