diff --git a/sdl-game-controller.cc b/sdl-game-controller.cc index 8849aed..e1262a9 100644 --- a/sdl-game-controller.cc +++ b/sdl-game-controller.cc @@ -19,14 +19,14 @@ static struct GLint color; GLint position; } uniforms; -int color = 0; +unsigned int color = 0u; GLfloat size = 0.2; GLfloat position[2] = {0.0, 0.0}; GLfloat colors[][4] = { {1.0, 0.7, 0.0, 1.0}, - {0.0, 0.5, 1.0, 1.0}, + {0.0, 0.2, 1.0, 1.0}, {1.0, 1.0, 0.0, 1.0}, - {0.2, 0.2, 1.0, 1.0}, + {0.2, 1.0, 1.0, 1.0}, }; float movement[2]; static SDL_Event UpdateEvent; @@ -194,9 +194,23 @@ int main(int argc, char *argv[]) movement[1] = 0.0; } } - else if (event.type == SDL_CONTROLLERBUTTONDOWN) + else if ((event.type == SDL_CONTROLLERBUTTONDOWN) && + (event.cbutton.state == SDL_PRESSED)) { - std::cerr << "button!" << std::endl; + switch (event.cbutton.button) + { + case SDL_CONTROLLER_BUTTON_A: + size *= 0.8; + break; + case SDL_CONTROLLER_BUTTON_B: + size *= 1.2; + break; + case SDL_CONTROLLER_BUTTON_X: + color++; + if (color >= sizeof(colors) / sizeof(colors[0])) + color = 0u; + break; + } } else if (event.type == SDL_USEREVENT) {