Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Unlimited mouse movement

Credits go to gnolam for helping out!
This thread is locked; no one can reply to it. rss feed Print
Unlimited mouse movement
Christopher Bludau
Member #5,401
January 2005

Note: I'm using openlayer for my program.

I want my program to scroll when the rightmouse button is pressed.
I want a unlimited movementrange for that.

I'm using this code:

int mouseXMovement, mouseYMovement;
get_mouse_mickeys( &mouseXMovement, &mouseYMovement );   
if( mouse_b == 2 ) {
  worldX += mouseXMovement;
  worldY += mouseYMovement;
}

But when the mouse cursor reaches the DESKTOP Borders the mouse stops moving and the mickeys will stay at zero.
(This has nothing to do with the borders of my program. Just the windows desktop border)
Is there an option to disable the desktop mousecursor as long as my program is active?

This happens WINDOWED and FULLSCREEN.
[EDIT] Sorry. Happens only in WINDOWED mode[/EDIT]

I can't remember, but i think this method worked with plain allegro.
But with openlayer I get this desktop border problem.
How do I achieve unlimited mouse range?

gnolam
Member #2,030
March 2002
avatar

int mouseXMovement, mouseYMovement;
get_mouse_mickeys( &mouseXMovement, &mouseYMovement );
position_mouse(SCREEN_W/2, SCREEN_H/2);
if( mouse_b == 2 ) {
  worldX += mouseXMovement;
  worldY += mouseYMovement;
}

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Christopher Bludau
Member #5,401
January 2005

Easy and effective!
Thank you!

Richard Phipps
Member #1,632
November 2001
avatar

Just be careful if you want to Alt-tab away because if your program isn't paused your mouse will not be properly movable. :)

Christopher Bludau
Member #5,401
January 2005

Hmm.. true.

Just changed the code to this:

if( mouse_b == 2 ) {

  int mouseXMovement, mouseYMovement;
  get_mouse_mickeys( &mouseXMovement, &mouseYMovement );   
  position_mouse(SCREEN_W/2, SCREEN_H/2);

  worldX += mouseXMovement;
  worldY += mouseYMovement;
}

So the code still works and the alt-tab problem is solved.

Thank you for noting that!

Go to: