SDL_Event按钮类型为mouse4和mouse5

时间:2014-04-20 21:48:35

标签: button mouseevent sdl

您如何确定SDL_Event循环中的哪些按钮? enter image description here

我知道他们通常被称为button4和button5在许多游戏中分配它们。但是我在这里用它来检测它们呢?

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;
        }
    }

}

1 个答案:

答案 0 :(得分:1)

您通常会阅读文档。

http://wiki.libsdl.org/SDL_MouseButtonEvent

在这种情况下,按钮是SDL_BUTTON_X1和SDL_BUTTON_X2