| Summary: | event.button.button+SDL_MOUSEMOTION+[right mouse button]=SDL_BUTTON_WHEELUP | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Krzysztof Myhan <krz123> |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | ||
| Version: | 1.2.11 | ||
| Hardware: | x86 | ||
| OS: | All | ||
|
Description
Krzysztof Myhan
2006-11-29 21:31:24 UTC
i compiled my program on linux debian and used lastest sdl (from packages- testing) and there is the same problem. Please post some sample code here that demonstrates this problem. I tried it on both Linux and Windows XP with the latest SDL from Subversion and it works fine in both cases (dragging the mouse and clicking the right button reports button #3 in the testwm app that comes with SDL). Is it possible that you are checking for events in a switch statement and forgot to put a "break;" between the motion and button case, so you're looking at the "button" data that is really the bits of a motion event? --ryan. http://another.int.pl/~krzycho/bug.tar.bz2 cross compiled source for win32, or by edit paths in makefile to compile under linux. right click on any area and without releaseing button move mouse and see what is reported in left top corner.
Ok, this isn't an SDL bug.
The various fields in an SDL_event are only meaningful depending on event.type ...
event.button and event.motion are in a union, so it's two views of the same bytes of memory. When you see "Button 4" you're really just seeing whatever happens to be in memory for the mouse motion event.
We don't report the mouse status every event, only when it changes.
So you'll need to do something like this:
static int mousex = 0;
static int mousey = 0;
static int button = 0;
switch (event.type) {
case SDL_MOUSEMOTION:
mousex = event.motion.x;
mousey = event.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
button = event.button.button;
break;
case SDL_QUIT:
done = 1;
break;
}
if(frame%50==0) {
fps2=SDL_GetTicks()-fps;
fps=SDL_GetTicks();
}
sprintf(buf, "ox: %d, oy: %d, %d fps, x:%d,y:%d,button: %d", o
0*50/fps2, mousex,mousey,button);
--ryan.
|