SDL mouse wheel not picking up
Posted
by
Chris
on Game Development
See other posts from Game Development
or by Chris
Published on 2012-03-30T05:43:19Z
Indexed on
2012/03/30
11:42 UTC
Read the original article
Hit count: 285
Running Ubuntu 11.04, SDL 1.2 trying to pickup mouse wheel up/down movement with this (stripped down) code:
int main( int argc, char **argv )
{
SDL_MouseButtonEvent *mousebutton = NULL;
while ( !done )
{
if(mousebutton != NULL && mousebutton->button == SDL_BUTTON_LEFT)
yrot += 0.75f;
else if(mousebutton != NULL && mousebutton->button == SDL_BUTTON_RIGHT)
yrot -= 0.75f;
else if(mousebutton != NULL && mousebutton->button == SDL_BUTTON_WHEELUP){
xrot += 0.75f;
}else if(mousebutton != NULL && mousebutton->button == SDL_BUTTON_WHEELDOWN){
xrot -= 0.75f;
}
while ( SDL_PollEvent( &event ) )
{
switch( event.type )
{
case SDL_MOUSEBUTTONDOWN:
mousebutton = &event.button;
break;
case SDL_MOUSEBUTTONUP:
mousebutton = NULL;
break;
default:
break;
}
}
}
return 0;
}
strange thing is, scrolling with the mouse button does nothing, but if I hold down a mouse button or two and then move the mouse it hits the SDL_BUTTON_WHEEL code occasionally. This honestly reeks of a pointer issue, which would make sense since I've been spoiled with C# for the past couple years, but I am just not seeing it.
How do i correctly find mouse scroll events in SDL?
© Game Development or respective owner