Mouse wheel

I’m interested in Mouse wheel support in SDL. Searching the web site and
source code I couldn’t find any support at the moment. Has anyone had a go
at adding any?

I know how to do it under Windows, but have no idea under X.

Anyone?

Francis

Mouse Wheel support is usually enabled in X via a program called imwheel.
There are good docs on how to get that running included with the
distribution. As far as SDL and the mouse wheel. That is a different
issue.

If you need help with imwheel email me!

DaveOn Wed, 21 Jun 2000 francis.irving at creaturelabs.com wrote:

I’m interested in Mouse wheel support in SDL. Searching the web site and
source code I couldn’t find any support at the moment. Has anyone had a go
at adding any?

I know how to do it under Windows, but have no idea under X.

Anyone?

Francis

Mouse Wheel support is usually enabled in X via a program called imwheel.
There are good docs on how to get that running included with the
distribution. As far as SDL and the mouse wheel. That is a different
issue.

SDL works great with wheeled mice on X11. The trick is the wheel-up event is
reported as button 4 and the wheel-down event is reported as mouse button 5.

How does it work on Windows?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

The buttons sam is referring to must be enabled via the XF86Config file
(XF86Setuo file?)

It is under the pointers section. The XFree 4.0 config file uses a
slightly different format for the configuration. Again if you need help
email me…

DaveOn Wed, 21 Jun 2000, Sam Lantinga wrote:

Mouse Wheel support is usually enabled in X via a program called imwheel.
There are good docs on how to get that running included with the
distribution. As far as SDL and the mouse wheel. That is a different
issue.

SDL works great with wheeled mice on X11. The trick is the wheel-up event is
reported as button 4 and the wheel-down event is reported as mouse button 5.

How does it work on Windows?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote:

Mouse Wheel support is usually enabled in X via a program called imwheel.
There are good docs on how to get that running included with the
distribution. As far as SDL and the mouse wheel. That is a different
issue.

SDL works great with wheeled mice on X11. The trick is the wheel-up event is
reported as button 4 and the wheel-down event is reported as mouse button 5.

How does it work on Windows?

Windows sends out a WM_MOUSEWHEEL message.
For historical (hysterical?) reasons, there seems to be two ways of
getting the ID of this message. For later versions of windows 95 I think
you can just use the predefined message number (although the windows
header files only seem to enable that #define if you’re compiling for
NT. sigh.):

// Get the WM_MOUSEWHEEL message without enabling all the NT-specific
// features in the Windows header files.
// See winuser.h and article Q169088 in the MS knowledge base.
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#define WHEEL_DELTA 120 /* Value for rolling
one detent /
#define WHEEL_PAGESCROLL (UINT_MAX) /
Scroll one
page */
#endif // !WM_MOUSEWHEEL

I think on earlier versions of the Os you need to determine the message
id at runtime:

UINT MouseWheelMessage = RegisterWindowMessage(MSH_MOUSEWHEEL);

The game ‘Creatures 3’ (where I cut & pasted these snippets from) just
uses both methods.

The mousewheel message comes with the following parameters:

LOWORD(wParam) - modifier keystates (shift, ctrl etc)
HIWORD(wParam) - wheel rotation (zDelta)
LOWORD(lParam) - pointer xpos
HIWORD(lParam) - pointer ypos

Wheel rotation is a signed number, -ve values indicate the wheel has
been rolled ‘back’ (ie toward the user).>From the MS documentation:


The zDelta parameter will be a multiple of WHEEL_DELTA, which is set at
120. This is the threshold for action to be taken, and one such action
(for example, scrolling one increment) should occur for each delta.

The delta was set to 120 to allow Microsoft or other vendors to build
finer-resolution wheels in the future, including perhaps a
freely-rotating wheel with no notches. The expectation is that such a
device would send more messages per rotation, but with a smaller value
in each message. To support this possibility, you should either add the
incoming delta values until WHEEL_DELTA is reached (so for a given
delta-rotation you get the same response), or scroll partial lines in
response to the more frequent messages. You could also choose your
scroll granularity and accumulate deltas until it is reached.

Hope this is useful to someone!

Ben.

Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creaturelabs.com