Querying mouse wheel movements with SDL?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Querying mouse wheel movements with SDL?

Dietfrid Mali
Hi,

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

karx11erx


_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Querying mouse wheel movements with SDL?

Alexandre Thomassin
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=[hidden email]
[mailto:sdl-bounces+alexandre.thomassin=[hidden email]] De la
part de karx11erx
Envoyé : mardi 17 janvier 2006 15:30
À : [hidden email]
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
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl



_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Querying mouse wheel movements with SDL?

Alex Barry
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 <[hidden email]> 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=[hidden email]
[mailto:[hidden email]] De la
part de karx11erx
Envoyé: mardi 17 janvier 2006 15:30
À: [hidden email]
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
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl



_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl



--
Smith: "...Why, Mr Anderson, Why - Do - You - Persist?"
Neo: "Because I choose to."
-Matrix Revolutions
_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Querying mouse wheel movements with SDL?

rpmcruz

 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:

> 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 <[hidden email]>
>
> 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=[hidden email]
> > [mailto:sdl-bounces+alexandre.thomassin=[hidden email]] De
> > la
> > part de karx11erx
> > Envoyé: mardi 17 janvier 2006 15:30
> > À: [hidden email]
> > 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.

_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Querying mouse wheel movements with SDL?

FlorianSievert (Bugzilla)
In reply to this post by Alex Barry
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
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Querying mouse wheel movements with SDL?

Alex Barry
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 <[hidden email]> 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
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl



--
Smith: "...Why, Mr Anderson, Why - Do - You - Persist?"
Neo: "Because I choose to."
-Matrix Revolutions
_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Querying mouse wheel movements with SDL?

Dietfrid Mali
In reply to this post by Alexandre Thomassin
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.


_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Querying mouse wheel movements with SDL?

David Olofson
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.

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  --'

_______________________________________________
SDL mailing list
[hidden email]
http://www.libsdl.org/mailman/listinfo/sdl
Loading...