Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Mac OSX and mouse_position

This thread is locked; no one can reply to it. rss feed Print
Mac OSX and mouse_position
montdidier
Member #10,238
September 2008

Hello Allegro People,

In the OSX version of the game I'm working on, using Allegro 4.2.2 I've had a number of problems using the likes of mouse_position.

The game uses mouse_position to warp the os mouse to the centre of the game screen and uses the mouse mickeys to update the game controls to repsond to user input.

The problem I have is that using mouse_position will distrupt the normal event handling in allegro of mouse buttons. I notice this is by design, in the osx mouse driver within osx_mouse_handler there exists

if (osx_mouse_warp)
{
  osx_mouse_warp = FALSE;
  return;
} 

/* The rest of the mouse handler code follows from here */

osx_mouse_warp gets set to TRUE as a consequence of calling mouse_position. So it seems that calling mouse_position every frame will cause all sorts of problems. However it seems to work fine in Windows. Is there any particular reason we can not continue handling mouse events normally in osx after warping the pointer? Has anybody come across this problem, and/or how have others kept the mouse from leaving the gameplay area in their Allegro OSX titles?

Thanks in Advance.

Chris K.

Peter Hull
Member #1,136
March 2001

montdidier
Member #10,238
September 2008

Thanks for responding Peter. I see you've raised it as a bug. I guess my question was partly to determine if it was by design, as it seemed intentional, however it does respond differently on windows. Unfortunately before reading your response I composed another similar question as I felt I had not properly explained myself here and that was the reason for the lack of initial response. My related question can be found here. http://www.allegro.cc/forums/thread/597908

Peter Hull
Member #1,136
March 2001

I posted a bug because what you're trying seems reasonable and you report that it does work on other platforms. I was hoping for some comment on [ad] but no.

The reason for that code is that, I think, without it, you just get the number of mickeys that were required to warp the mouse back to the middle, not the number you moved the mouse by.

If you look at exmouse, it calls warp every few frames and not every frame, would that work?

I'll have a quick look - the true solution might be to use mouseLocationOutsideOfEventStream instead of the current method.

Pete

Go to: