Mouse wheel in allegro
CursedTyrant

Is there a way (or rather, a specific function), that would let me use the mouse wheel in my program (And detect if it's been "scrolled")? I'm coding a scrollable list of elements, and it would be nice if I could scroll it using said wheel.

Thomas Fjellstrom

mouse_z is your friend.

SonShadowCat

Check out mouse_z, I believe that deals with the wheel. http://allegro.cc/manual/api/mouse-routines/

Edit: 2 seconds late!

HoHo

There is a variable called mouse_z thats value changes when wheel is scrolled.

[edit]
Three minutes late because I thought there was some kind of longer explanation about it in manual but seems there isn't

CursedTyrant

Oh well, it would be much more readable if it would be called mouse_wheel, but I guess it'll have to do. One other thing, is there something like get_mouse_mickeys() which returns the wheel movement, or do I have to code it myself (I'm lazy, I know :P)?

ixilom

Maybe something like this

void get_mouse_mickeys_ex(int *mickeyx, int *mickeyy, int *mickeyz)
{
  get_mouse_mickeys(mickeyx,mickeyy);
  static int mz = mouse_z;
  if(mouse_z != mz)
    *mickeyz = mouse_z - mz;
  else
    *mickeyz = 0;
  mz = mouse_z;
}

Havent tested it, probably not thinking straight either because I just woke up, use it at your own risk ;D

Thread #587597. Printed from Allegro.cc