WheelMouse Wheel (up&down) Input Events

Hello!

I started to build a program which required input from the wheel on my
WheelMouse (i.e. moving the wheel up and down).
I looked in the documentation of the events, but found nothing about it.
After some experimenting, I’ve found out that when the wheel moves up
and down, I recieve a SDL_MOUSEBUTTONDOWN event with 4 (wheel up) and 5
(wheel down) as the button index (event.state).
In the documentation it’s said: “The mouse button index
(SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
wheel… :frowning:

All those of you who are not Wheel-challenged, I would appriciate it if
you check if this works the same way for you too.

[To SDL developers:]
In case I’m telling you something you neven knew before – please put
this in the documentation and appropriate header.
If you have any reason not to, or already knew about this but didn’t put
it, please explain why.

RK.

Thanks for the info! I have only just begun working with the SDL, but
have already noticed a number of discrepancies between the documentation
and the code. (I’m compiling them as I go, so I can submit them to
whomever is handling documentation along the way.)

After some experimenting, I’ve found out that when the wheel moves up
and down, I recieve a SDL_MOUSEBUTTONDOWN event with 4 (wheel up) and
5
(wheel down) as the button index (event.state).
In the documentation it’s said: “The mouse button index
(SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
wheel… :frowning:

Ok … I’m using the version tagged “release_1_2_4” from CVS … so my
mileage may be varying here … but I did some quick tests to confirm.

Platform:
WinXP Pro

I figured that it would be incongruous for SDL to only be receiving
mouse button down events without mouse button up events, so I trapped
both in my test. For each tick of the mouse wheel, I got one
SDL_MOUSEBUTTONDOWN followed immediately by an SDL_MOUSEBUTTONUP event.

Wheel Up:
SDL_MOUSEBUTTONDOWN
event.button.button = 4
event.button.state = 1 (I assume this is for simply testing true/false
"is the button down?"

SDL_MOUSEBUTTONUP
event.button.button = 4
event.button.state = 0

Wheel Down:
SDL_MOUSEBUTTONDOWN
event.button.button = 5
event.button.state = 1

SDL_MOUSEBUTTONUP
event.button.button = 5
event.button.state = 0

So … consider this a confirmation on at least one other system :slight_smile:

Lee Dohm

This is what I’ve found too.On Sat, Jun 01, 2002 at 01:56:09AM +0200, Romi Kuntsman wrote:

and down, I recieve a SDL_MOUSEBUTTONDOWN event with 4 (wheel up) and 5
(wheel down) as the button index (event.state).


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/

| In the documentation it’s said: “The mouse button index
| (SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
| wheel… :frowning:

Incase you didn’t know…

There’s nothing special about mouse wheels, they’re just buttons 4 and
5 (as you found out). It should also emit a SDL_BUTTON_MIDDLE when you
press the wheel.On Sat, Jun 01, 2002 at 01:56:09AM +0200, Romi Kuntsman wrote:


I will never win an Emmy

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

James wrote:>On Sat, Jun 01, 2002 at 01:56:09AM +0200, Romi Kuntsman wrote:

| In the documentation it’s said: “The mouse button index
| (SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
| wheel… :frowning:

Incase you didn’t know…

There’s nothing special about mouse wheels, they’re just buttons 4 and
5 (as you found out). It should also emit a SDL_BUTTON_MIDDLE when you
press the wheel.

I really didn’t know, since in Win32 API, with which I’ve been working
for quite long, there are seperate messages for mouse wheel and for
mouse buttons (yes, I know that pressing the wheel is like the middle
mouse button).

I would be nice to have at least a note about it in the documentation.
Nicer yet would be adding constants to be checked against the mouse
button index in the event…

RK.

Lee Dohm wrote:

Thanks for the info! I have only just begun working with the SDL, but
have already noticed a number of discrepancies between the documentation
and the code. (I’m compiling them as I go, so I can submit them to
whomever is handling documentation along the way.)

That’s what I just did… :slight_smile:

After some experimenting, I’ve found out that when the wheel moves up
and down, I recieve a SDL_MOUSEBUTTONDOWN event with 4 (wheel up) and 5
(wheel down) as the button index (event.state).

In the documentation it’s said: “The mouse button index
(SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
wheel… :frowning:

Ok … I’m using the version tagged “release_1_2_4” from CVS … so my
mileage may be varying here … but I did some quick tests to confirm.

I only use binaries, but did check the latest CVS and saw there’s no
sign of wheel mouse.

Platform:
WinXP Pro

Me too…

I figured that it would be incongruous for SDL to only be receiving
mouse button down events without mouse button up events, so I trapped
both in my test. For each tick of the mouse wheel, I got one
SDL_MOUSEBUTTONDOWN followed immediately by an SDL_MOUSEBUTTONUP event.

Wheel Up:
SDL_MOUSEBUTTONDOWN
event.button.button = 4
event.button.state = 1 (I assume this is for simply testing true/false
"is the button down?"

SDL_MOUSEBUTTONUP
event.button.button = 4
event.button.state = 0

Wheel Down:
SDL_MOUSEBUTTONDOWN
event.button.button = 5
event.button.state = 1

SDL_MOUSEBUTTONUP
event.button.button = 5
event.button.state = 0

Are you sure about that?
Because I got 4 and 5 in event.button.state, and this is what’s written
in my documentation (from JEDI-SDL, Delphi structure):

TSDL_MouseButtonEvent = record
type_: UInt8; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
which: UInt8; // The mouse device index
state: UInt8; // The mouse button index
button: UInt8; // SDL_PRESSED or SDL_RELEASED
x: UInt16; // The X coordinates of the mouse at press time
y: UInt16; // The Y coordinates of the mouse at press time
end;

Wait a minute! I just notices the “state” and “button” are in reverse
order in the original header (ok, the correct order, and the reverse
order in mine) :

typedef struct {
Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP /
Uint8 which; /
The mouse device index /
Uint8 button; /
The mouse button index /
Uint8 state; /
SDL_PRESSED or SDL_RELEASED /
Uint16 x, y; /
The X/Y coordinates of the mouse at press
time */
} SDL_MouseButtonEvent;

Damm! My Delphi translation of the header (JEDI-SDL) is wrong!!!
AAAAaaaaaahhhhh!!! :((((
Any other JEDI-SDL users on the list?

RK.

I don’t think that’s actually so. As far as I can tell, it’s actually
another mouse axis (like moving the mouse around). This is why you put
"ZAxisMapping" in your XFree86 config – this translates that axis into
button presses. It could theoretically be used some other way – a real Z
axis in a 3d environment, for example.On Sat, Jun 01, 2002 at 09:37:50AM +0100, James wrote:

There’s nothing special about mouse wheels, they’re just buttons 4 and
5 (as you found out). It should also emit a SDL_BUTTON_MIDDLE when you
press the wheel.


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/

Hi Romi,
I am the maintainer of JEDI-SDL, we usually ask JEDI-SDL type
question over on JEDI-SDL at yahoogroups.com and only when none of us know
anything , do we tend to hassle this main list.
If you would like to join you can do so @
http://groups.yahoo.com/group/JEDI-SDL/join

Which version of JEDI-SDL are you using? I released the beta 5 RC1 about
a month ago, where the problem you mention has been fixed.

I hope to you see you on the JEDI-SDL mailing list.

Sincerely,

Dominique.

Romi Kuntsman wrote:> Lee Dohm wrote:

Thanks for the info! I have only just begun working with the SDL, but
have already noticed a number of discrepancies between the documentation
and the code. (I’m compiling them as I go, so I can submit them to
whomever is handling documentation along the way.)

That’s what I just did… :slight_smile:

After some experimenting, I’ve found out that when the wheel moves up
and down, I recieve a SDL_MOUSEBUTTONDOWN event with 4 (wheel up) and 5
(wheel down) as the button index (event.state).

In the documentation it’s said: “The mouse button index
(SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
wheel… :frowning:

Ok … I’m using the version tagged “release_1_2_4” from CVS … so my
mileage may be varying here … but I did some quick tests to confirm.

I only use binaries, but did check the latest CVS and saw there’s no
sign of wheel mouse.

Platform:
WinXP Pro

Me too…

I figured that it would be incongruous for SDL to only be receiving
mouse button down events without mouse button up events, so I trapped
both in my test. For each tick of the mouse wheel, I got one
SDL_MOUSEBUTTONDOWN followed immediately by an SDL_MOUSEBUTTONUP event.

Wheel Up:
SDL_MOUSEBUTTONDOWN
event.button.button = 4
event.button.state = 1 (I assume this is for simply testing true/false
"is the button down?"

SDL_MOUSEBUTTONUP
event.button.button = 4
event.button.state = 0

Wheel Down:
SDL_MOUSEBUTTONDOWN
event.button.button = 5
event.button.state = 1

SDL_MOUSEBUTTONUP
event.button.button = 5
event.button.state = 0

Are you sure about that?
Because I got 4 and 5 in event.button.state, and this is what’s written
in my documentation (from JEDI-SDL, Delphi structure):

TSDL_MouseButtonEvent = record
type_: UInt8; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
which: UInt8; // The mouse device index
state: UInt8; // The mouse button index
button: UInt8; // SDL_PRESSED or SDL_RELEASED
x: UInt16; // The X coordinates of the mouse at press time
y: UInt16; // The Y coordinates of the mouse at press time
end;

Wait a minute! I just notices the “state” and “button” are in reverse
order in the original header (ok, the correct order, and the reverse
order in mine) :

typedef struct {
Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP /
Uint8 which; /
The mouse device index /
Uint8 button; /
The mouse button index /
Uint8 state; /
SDL_PRESSED or SDL_RELEASED /
Uint16 x, y; /
The X/Y coordinates of the mouse at press
time */
} SDL_MouseButtonEvent;

Damm! My Delphi translation of the header (JEDI-SDL) is wrong!!!
AAAAaaaaaahhhhh!!! :((((
Any other JEDI-SDL users on the list?

RK.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


http://www.DelphiGamer.com := for all your Object Pascal game
development needs;
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.

Dominique Louis wrote:

Hi Romi,
I am the maintainer of JEDI-SDL, we usually ask JEDI-SDL type
question over on JEDI-SDL at yahoogroups.com and only when none of us
know anything , do we tend to hassle this main list.
If you would like to join you can do so @
http://groups.yahoo.com/group/JEDI-SDL/join

This was not about JEDI-SDL. I started the thread to ask the mouse wheel
stuff in SDL itself.
Only later I’ve found out that I have a minor problem in the JEDI-SDL
header, but it’s not the important point.

Which version of JEDI-SDL are you using? I released the beta 5 RC1
about a month ago, where the problem you mention has been fixed.

I’ve got beta 4 from last year. I’ll download the new one now. 10x.

I hope to you see you on the JEDI-SDL mailing list.

Ok. Joining now… :)> Sincerely,

Dominique.

Romi Kuntsman wrote:

Lee Dohm wrote:

Thanks for the info! I have only just begun working with the SDL, but
have already noticed a number of discrepancies between the
documentation
and the code. (I’m compiling them as I go, so I can submit them to
whomever is handling documentation along the way.)

That’s what I just did… :slight_smile:

After some experimenting, I’ve found out that when the wheel moves up
and down, I recieve a SDL_MOUSEBUTTONDOWN event with 4 (wheel up)
and 5
(wheel down) as the button index (event.state).

In the documentation it’s said: “The mouse button index
(SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)”, no mention of
wheel… :frowning:

Ok … I’m using the version tagged “release_1_2_4” from CVS … so my
mileage may be varying here … but I did some quick tests to confirm.

I only use binaries, but did check the latest CVS and saw there’s no
sign of wheel mouse.

Platform:
WinXP Pro

Me too…

I figured that it would be incongruous for SDL to only be receiving
mouse button down events without mouse button up events, so I trapped
both in my test. For each tick of the mouse wheel, I got one
SDL_MOUSEBUTTONDOWN followed immediately by an SDL_MOUSEBUTTONUP event.

Wheel Up:
SDL_MOUSEBUTTONDOWN
event.button.button = 4
event.button.state = 1 (I assume this is for simply testing true/false
"is the button down?"

SDL_MOUSEBUTTONUP
event.button.button = 4
event.button.state = 0

Wheel Down:
SDL_MOUSEBUTTONDOWN
event.button.button = 5
event.button.state = 1

SDL_MOUSEBUTTONUP
event.button.button = 5
event.button.state = 0

Are you sure about that?
Because I got 4 and 5 in event.button.state, and this is what’s
written in my documentation (from JEDI-SDL, Delphi structure):

TSDL_MouseButtonEvent = record
type_: UInt8; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
which: UInt8; // The mouse device index
state: UInt8; // The mouse button index
button: UInt8; // SDL_PRESSED or SDL_RELEASED
x: UInt16; // The X coordinates of the mouse at press time
y: UInt16; // The Y coordinates of the mouse at press time
end;

Wait a minute! I just notices the “state” and “button” are in reverse
order in the original header (ok, the correct order, and the reverse
order in mine) :

typedef struct {
Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP /
Uint8 which; /
The mouse device index /
Uint8 button; /
The mouse button index /
Uint8 state; /
SDL_PRESSED or SDL_RELEASED /
Uint16 x, y; /
The X/Y coordinates of the mouse at
press time */
} SDL_MouseButtonEvent;

Damm! My Delphi translation of the header (JEDI-SDL) is wrong!!!
AAAAaaaaaahhhhh!!! :((((
Any other JEDI-SDL users on the list?

RK.

There’s nothing special about mouse wheels, they’re just buttons 4 and
5 (as you found out). It should also emit a SDL_BUTTON_MIDDLE when you
press the wheel.

How about mice with more than one wheel? What about those with
additional buttons, like the Logitech cordless optical with the thumb
button, or the MS Explorer with 2 thumb buttons? Do these get numbered
beyond 5, if 4 and 5 are allocated to the first wheel?

(BTW, anyone want to reply to my earlier post about trapping keyboard
events from a background app? This is for TeamSpeak, so games without
good built-in voicecomm can have it added by a separate app.)On Sat, 2002-06-01 at 01:37, James wrote:

Matthew Miller wrote:>On Sat, Jun 01, 2002 at 09:37:50AM +0100, James wrote:

There’s nothing special about mouse wheels, they’re just buttons 4 and
5 (as you found out). It should also emit a SDL_BUTTON_MIDDLE when you
press the wheel.

I don’t think that’s actually so. As far as I can tell, it’s actually
another mouse axis (like moving the mouse around). This is why you put
"ZAxisMapping" in your XFree86 config – this translates that axis into
button presses. It could theoretically be used some other way – a real Z
axis in a 3d environment, for example.

That’s really not just like another button. Don’t know about another
mouse axis, but I do know that windows sends a seperate message for
moving the mouse wheel, and I just found out that SDL processes it and
sends an event with mouse index 4 and 5:

(from “\src\video\wincommon\SDL_sysevents.c”)

 case WM_MOUSEWHEEL:
     if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) {
         int move = (short)HIWORD(wParam);
         if ( move ) {
             Uint8 button;
             if ( move > 0 )
                 button = 4;
             else
                 button = 5;
             posted = SDL_PrivateMouseButton(
                 SDL_PRESSED, button, 0, 0);
             posted |= SDL_PrivateMouseButton(
                 SDL_RELEASED, button, 0, 0);
             }
         }
         return(0);

So it will be good if this will be documented and proper constants (e.g.
SDL_WHEEL_UP, SDL_WHEEL_DOWN) be defined for it.

RK.

Matthew Miller wrote:

There’s nothing special about mouse wheels, they’re just buttons 4 and
5 (as you found out). It should also emit a SDL_BUTTON_MIDDLE when you
press the wheel.

I don’t think that’s actually so. As far as I can tell, it’s actually
another mouse axis (like moving the mouse around). This is why you put
"ZAxisMapping" in your XFree86 config – this translates that axis into
button presses. It could theoretically be used some other way – a real Z
axis in a 3d environment, for example.

That’s really not just like another button. Don’t know about another
mouse axis, but I do know that windows sends a seperate message for
moving the mouse wheel, and I just found out that SDL processes it and
sends an event with mouse index 4 and 5:

That’s not relevant. Windows is famous to add unuseful abstraction layers and if XFree tells you it’s 2
buttons, well it IS actually at 99% of chance. (Why do you think there isn’t ANY wheel with continuos
movement?)> >On Sat, Jun 01, 2002 at 09:37:50AM +0100, James wrote:

Uhhh, I had one about a year ago which was continuous movement. Using the
thing in X11 was a total bitch. It’s a third axis, not a pair of buttons.
SDL is doing the wrong thing, as is X, pretending otherwise.

It was done this way in X because we’re using a thirty year old protocol
with hack upon layers of other hacks. We can’t risk breaking
compatibility by fixing any of this crap, so we have to suffer through a
broken hackish implementation which takes about four times the memory
footprint of something implemented sanely. All because some company like
Adobe doesn’t have to consider recompiling acroread with a new library.

If there’s one thing that people advocating free software should look to
for good reasons why free software is necessary, the disgusting mess that
is X11 should be all they need. Ignore the political and pseudo-political
crap, we have solid technical reasons why applications without source code
are a bad thing. We’ve been stuck with X11 for the past how many years?
And how many more shall we be stuck with it? Lack of backwards
compatibility seems to kill off every single attempt to replace X11 with
something that does not suck.

Anything that replaces it will need as its very first application an X
server. (But I am now totally off topic, so I’ll STFU…)On Mon, Jun 03, 2002 at 04:46:26PM +0200, CRV?ADER/KY wrote:

That’s really not just like another button. Don’t know about another
mouse axis, but I do know that windows sends a seperate message for
moving the mouse wheel, and I just found out that SDL processes it and
sends an event with mouse index 4 and 5:

That’s not relevant. Windows is famous to add unuseful abstraction layers and if XFree tells you it’s 2
buttons, well it IS actually at 99% of chance. (Why do you think there isn’t ANY wheel with continuos
movement?)


Joseph Carter This thing is an AI

Would it be acceptable to debian policy if we inserted a crontab
by default into potato that emailed bill.gates at microsoft.com
every morning with an email that read, “Don’t worry, linux is a
fad…”

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020603/c8ea5d69/attachment.pgp

Matthew Miller wrote:

[remember to trim quotations properly – I said something in the middle of
the quoted bit, not at the end as a casual glance at might imply]

I don’t think that’s actually so. As far as I can tell, it’s actually
another mouse axis (like moving the mouse around). This is why you put
"ZAxisMapping" in your XFree86 config – this translates that axis into
button presses. It could theoretically be used some other way – a real Z
axis in a 3d environment, for example.
That’s really not just like another button. Don’t know about another
mouse axis, but I do know that windows sends a seperate message for
moving the mouse wheel, and I just found out that SDL processes it and
sends an event with mouse index 4 and 5:
That’s not relevant. Windows is famous to add unuseful abstraction layers
and if XFree tells you it’s 2 buttons, well it IS actually at 99% of
chance. (Why do you think there isn’t ANY wheel with continuos movement?)

XFree86 only tells you that because you tell it to do so, with the
ZAxisMapping configuration directive.On Mon, Jun 03, 2002 at 04:46:26PM +0200, CRV?ADER/KY wrote:


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/