Question

What do you put to figure out which buttons these are in the SDL_Event loop? enter image description here

I know they are usually known as button4 and button5 from assigning them in many games. But what do I put in here to detect them?

SDL_Event event;
while (SDL_PollEvent(&event)) {
    switch (event.type) {
        case SDL_MOUSEBUTTONDOWN: {
            if (event.button.button == SDL_BUTTON_LEFT) {
                mouseLeft = true;
            }
            else if (event.button.button == SDL_BUTTON_RIGHT) {
                mouseRight = true;
            }
            else if (event.button.button == SDL_BUTTON_MIDDLE) {
                mouseMiddle = true;
            }
            else if (event.button.button == MOUSE4?) {
                mouse4 = true;
            }
            else if (event.button.button == MOUSE5?) {
                mouse5 = true;
            }
            break;
        }
    }

}
Was it helpful?

Solution

You would usually read the documentation.

http://wiki.libsdl.org/SDL_MouseButtonEvent

In this case the buttons are SDL_BUTTON_X1 and SDL_BUTTON_X2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top