I wrote a simple SDL program using SDL 2.0. I have a little problem when I want to check the mouse wheel events. Actually, in the version 2.0 the flags SDL_BUTTON_WHEELDOWN and SDL_BUTTON_WHEELUP no longer exist. There is just the flags SDL_MOUSEWHEEL. The code below check correctly the' WHEELUP' and 'WHEELDOWN' events but with the same flag.
while(!terminer)
{
while (SDL_PollEvent(&evenements))
{
switch (evenements.type)
{
case SDL_QUIT:
terminer = true;
break;
case SDL_KEYDOWN:
switch (evenements.key.keysym.sym)
{
case SDLK_ESCAPE:
terminer = true;
break;
}
break;
case SDL_MOUSEMOTION:
std::cout << "MOUSE : MOVE" << std::endl;
break;
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
std::cout << "MOUSE : BUTTON DOWN" << std::endl;
break;
case SDL_MOUSEWHEEL:
std::cout << "MOUSE : WHEEL" << std::endl;
break;
}
}
But I would like to handle separately the 'WHEELUP' and 'WHEELDOWN' events. I tried several others flags in my condition but without success. Does anyone can help me?
You can catch the up and down event this way:
case SDL_MOUSEWHEEL:
if (evenements.wheel.y < 0)
std::cout << "MOUSE : WHEEL DOWN" << std::endl;
else
std::cout << "MOUSE : WHEEL UP" << std::endl;
break;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With