Querying mouse wheel movements with SDL?

Hi,

I haven’t found a way to query mouse wheel movements using SDL. Is it possible?
If yes, how?

karx11erx

Hi,

Mouse wheel is considered as 2 buttons, 4 & 5. event.button.button can be
equal to : 1 (or SDL_BUTTON_LEFT), 2 (or SDL_BUTTON_MIDDLE), 3 (or
SDL_BUTTON_RIGHT), 4 (wheel down), and 5 (wheel up).

Alexandre Thomassin

-----Message d’origine-----
De?: sdl-bounces+alexandre.thomassin=mi-informatique.fr at libsdl.org
[mailto:sdl-bounces+alexandre.thomassin=mi-informatique.fr at libsdl.org] De la
part de karx11erx
Envoy??: mardi 17 janvier 2006 15:30
??: sdl at libsdl.org
Objet?: [SDL] Querying mouse wheel movements with SDL?

Hi,

I haven’t found a way to query mouse wheel movements using SDL. Is it
possible?
If yes, how?

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

I’ve actually been wondering this. I wanted to use teh mouse wheel (not as
a button, but as a scroller)…is there any way of doing that?

Alex~On 1/17/06, Alexandre Thomassin <alexandre.thomassin at mi-informatique.fr> wrote:

Hi,

Mouse wheel is considered as 2 buttons, 4 & 5. event.button.button can be
equal to : 1 (or SDL_BUTTON_LEFT), 2 (or SDL_BUTTON_MIDDLE), 3 (or
SDL_BUTTON_RIGHT), 4 (wheel down), and 5 (wheel up).

Alexandre Thomassin

-----Message d’origine-----
De: sdl-bounces+alexandre.thomassin=mi-informatique.fr at libsdl.org
[mailto:sdl-bounces+alexandre.thomassin=mi-informatique.fr at libsdl.org] De
la
part de karx11erx
Envoy?: mardi 17 janvier 2006 15:30
?: sdl at libsdl.org
Objet: [SDL] Querying mouse wheel movements with SDL?

Hi,

I haven’t found a way to query mouse wheel movements using SDL. Is it
possible?
If yes, how?

karx11erx


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


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


Smith: "…Why, Mr Anderson, Why - Do - You - Persist?"
Neo: “Because I choose to.”
-Matrix Revolutions

But of course.
?
bool scroll_up, scroll_down;
scroll_up = scroll_down = false;
SDL_Event event;

(…)

while(SDL_PollEvents(&event)) {
switch(event.type){
case SDL_MOUSEBUTTONDOWN:
switch(event.type.button.button){
case SDL_BUTTON_WHEELUP:
scroll_up = true;
break;
case SDL_BUTTON_WHEELDOWN:
scroll_down = true;
break;
}
break;
}
case SDL_MOUSEBUTTONUP:
switch(event.type.button.button){
case SDL_BUTTON_WHEELUP:
scroll_up = false;
break;
case SDL_BUTTON_WHEELDOWN:
scroll_down = false;
break;
}
break;
}
}
}
(…)
if(scroll_up)
scroll_y -= 5 * elapsed_time;
if(scroll_down)
scroll_y += 5 * elapsed_time;
?

Anyway, since nobody can scroll the wheel faster than your ordinary frame
rate, I’d just do something like this:

?
(…)
case SDL_MOUSEBUTTONUP:
switch(event.type.button.button){
case SDL_BUTTON_WHEELUP:
scroll_y -= 5;
break;
case SDL_BUTTON_WHEELDOWN:
scroll_y += 5;
break;
(…)
?

Cheers,
RicardoEm Ter?a, 17 de Janeiro de 2006 18:05, o Alex Barry escreveu:

I’ve actually been wondering this. I wanted to use teh mouse wheel (not as
a button, but as a scroller)…is there any way of doing that?

Alex~

On 1/17/06, Alexandre Thomassin <alexandre.thomassin at mi-informatique.fr> wrote:

Hi,

Mouse wheel is considered as 2 buttons, 4 & 5. event.button.button can be
equal to : 1 (or SDL_BUTTON_LEFT), 2 (or SDL_BUTTON_MIDDLE), 3 (or
SDL_BUTTON_RIGHT), 4 (wheel down), and 5 (wheel up).

Alexandre Thomassin

-----Message d’origine-----
De: sdl-bounces+alexandre.thomassin=mi-informatique.fr at libsdl.org
[mailto:sdl-bounces+alexandre.thomassin=mi-informatique.fr at libsdl.org] De
la
part de karx11erx
Envoy?: mardi 17 janvier 2006 15:30
?: sdl at libsdl.org
Objet: [SDL] Querying mouse wheel movements with SDL?

Hi,

I haven’t found a way to query mouse wheel movements using SDL. Is it
possible?
If yes, how?

karx11erx


Don’t kiss an elephant on the lips today.

Hi Alex,

I’ve actually been wondering this. I wanted to use teh mouse wheel
(not as a button, but as a scroller)…is there any way of doing that?
Actually if you want to have a scroller, just count the times the button
event was raised. Because the wheel doesn’t need to be “released”, you
will get a different effect than pressing a normal mouse button.

Regards,
Florian

Ok - i thought the button up and button down was if you were using it like a
button and not as a wheel.
Thanks for the insight

Al~On 1/17/06, Florian Sievert wrote:

Hi Alex,

I’ve actually been wondering this. I wanted to use teh mouse wheel
(not as a button, but as a scroller)…is there any way of doing that?
Actually if you want to have a scroller, just count the times the button
event was raised. Because the wheel doesn’t need to be “released”, you
will get a different effect than pressing a normal mouse button.

Regards,
Florian


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


Smith: "…Why, Mr Anderson, Why - Do - You - Persist?"
Neo: “Because I choose to.”
-Matrix Revolutions

Thanks for the info. Problem is that for every wheel movement,
SDL will deliver a button down event, immediately followed by
a button up, which might require some extra code to properly
process mouse wheel actions.

Well, just ignore the events you don’t want. (Unless you’re doing
mouse capture, focus handling and stuff like that, you generally do
that anyway.)

One wheel “step” corresponds to one click on a virtual up or down
button. There is no such things as a “down state” of these virtual
up/down buttons, and sending down + up events back to back is as
close as a button oriented API gets to emulating these zero duration
clicks. The only thing wrong with it is that the zero duration isn’t
reliably visible through the API.

You’d actually need extra code without these “fake” button up
events, because that would make them different from all other button
events.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Wednesday 18 January 2006 12:52, karx11erx wrote:

Thanks for the info. Problem is that for every wheel movement,
SDL will deliver a button down event, immediately followed by
a button up, which might require some extra code to properly
process mouse wheel actions.