The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Querying mouse wheel movements with SDL?
karx11erx
Guest

Hi,

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

karx11erx
Querying mouse wheel movements with SDL?
Alexandre Thomassin
Guest

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
Querying mouse wheel movements with SDL?
Alex Barry
Guest

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:
Quote:

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060117/73f9acf7/attachment.html
Querying mouse wheel movements with SDL?
Ricardo Cruz
Guest

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,
Ricardo

Em Ter?a, 17 de Janeiro de 2006 18:05, o Alex Barry escreveu:
Quote:
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:
Quote:
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.
Querying mouse wheel movements with SDL?
Florian Sievert
Guest

Hi Alex,
Quote:
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
Querying mouse wheel movements with SDL?
Alex Barry
Guest

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 <floriansievert at phobeus.de> wrote:
Quote:

Hi Alex,
Quote:
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060117/56b6741b/attachment.htm