We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 368 - event.button.button+SDL_MOUSEMOTION+[right mouse button]=SDL_BUTTON_WHEELUP
Summary: event.button.button+SDL_MOUSEMOTION+[right mouse button]=SDL_BUTTON_WHEELUP
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.11
Hardware: x86 All
: P2 blocker
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-29 21:31 UTC by Krzysztof Myhan
Modified: 2007-02-16 01:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Myhan 2006-11-29 21:31:24 UTC
simple... when you motion mouse and press right button you get that(code 4 instend of 3) wheel up is pressed :/ Everything is ok, till any motion... I cross compile program from FreeBSD mingw to windows NT. In my program i need moveing and updateing in real time screen by pressing right+motion..
Comment 1 Krzysztof Myhan 2007-01-13 05:43:23 UTC
i compiled my program on linux debian and used lastest sdl (from packages- testing) and there is the same problem.
Comment 2 Ryan C. Gordon 2007-02-15 05:48:02 UTC
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.

Comment 3 Krzysztof Myhan 2007-02-15 08:58:34 UTC
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.
Comment 4 Ryan C. Gordon 2007-02-16 01:36:58 UTC
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.