-
Notifications
You must be signed in to change notification settings - Fork 54
Description
I've been making a small library with SDL recently, and one thing that I got confused by was what I should do with the return value of SDL_GetMouseState().
Right now, it's not very obvious how you're meant to use it. I had to search up examples on online forums to find out how it works. In the documentation page for https://wiki.libsdl.org/SDL3/SDL_MouseButtonFlags and https://wiki.libsdl.org/SDL3/SDL_GetMouseState, (this also applies to SDL2's wiki) it doesn't really mention what you should be doing with it. It just says that it can be 'bitwise-compared' with the SDL_BUTTON_MASK(X) macro.
I think it would be useful to go into a little bit more detail, and maybe give some example code, like:
SDL_MouseButtonFlags mstate = SDL_GetMouseState(NULL, NULL);
bool leftPressed = mstate & SDL_BUTTON_MASK(SDL_BUTTON_LEFT);
Because, at least for me 'bitwise compare' doesn't really tell me exactly how I should use it. Bitwise or, and? Obviously I know now (I think), but I think it would be useful to specify in the docs. I haven't written it myself because I'm not 100% sure how best to explain it, or even if my example code suggestion is the 'right way' to do it, although it seems to work.