Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro 4.2.2 on OSX

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

I didn't have much luck last time I posted a question related to this, so I've tried to more clearly explain my question.

I'm currently porting a title to OSX.

It's been a relatively smooth process and the game is running pretty
good now. The only real problem I've had has been the way that the
mouse behaves under OSX.

The problem has been mostly related to the interaction between two
parts of code.

osx_mouse_handler in qzmouse.m

osx_mouse_position in qzmouse.m

link below

http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/tags/v4-2-2/src/macosx/qzmouse.m?view=markup

So osx_mouse_position gets called every frame to stop the mouse
leaving the gameplay window and messing up the game play, however
mouse mickeys do get used to move the character(s) around the screen,
aim and use the software cursor and menus ingame.

These lines below in osx_mouse_position have made the process a little
tricky. Depending on when mouse_position gets called in the game,
mickeys may work or not, however it doesn't seem to matter in Windows, althought I've looked and mouse mickeys get zeroed in the windows "mouse_position" method also.

mymickey_x = mymickey_y = 0;
osx_mouse_warped = TRUE;

Also later in osx_mouse_handler there is

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

before any of the mouse_b, mouse_x or mouse_y gets updated. So
unfortunately it seems that calling osx_mouse_position will always
reset the mouse button, and possibly depending on when it is called
in the frame , will also remove the mouse mickey updates.

I've hacked my allegro included in the game to basically not reset
osx_mouse_warped until after updating the mouse_b. This is seems to
work fine now, especially when I find the right place to call
mouse_position from so as to not cancel out my mouse mickeys.

However, I'm wondering why it was important in the first place to care
about the mouse warp, and why you would reset the mouse mickeys in
osx_mouse_position? It seems to me the primary reason for
mouse_position is to prevent the os mouse from leaving the window and
being able to update the allegro mouse cursor using mouse mickeys? I
just want some insight so that I understand if I'm potentially
breaking something or not.

I'm not an allegro expert by any means, it's the first time I have
used the library and for the most part have not had to worry about it,
it does the right thing. So perhaps I'm just mistaken and should
change the design of the game?

I guess my question boils down to, is it bad to call mouse_position every frame, and if so, why and why does it seem to work happily on windows?

Anyway. I much appreciate any time you spend in answering my question,
or pointing me in the right direction.

Thank you!

Chris K.

Don Freeman
Member #5,110
October 2004
avatar

I'm sorry I do not have a MAC to know how to help you...hopefully me bumping this will spark some of the more seasoned "experts" here to help you. Sorry I couldn't help...:'(

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

Evert
Member #794
November 2000
avatar

Sorry, I did have a quick look at this the other day.

Quote:

I guess my question boils down to, is it bad to call mouse_position every frame, and if so, why and why does it seem to work happily on windows?

It seems that OS X does not send mouse movement events after the mouse has left the window (or "tracking rectangle" I think it's called), so the only way to get infinite mouse mickeys is indeed to constantly warp the mouse to the centre of the window. This is also true of X11 (but not Windows, if I recall correctly), where Allegro will warp the mouse mutton for you once you start polling for mouse mickeys. I'm guessing it should (optionally) do that in OS X as well. It's quite possible that no one has looked at it or tried it before in OS X.

There are a few drawbacks to this, however. First of all, it can be really annoying in windowed applications, although you can usually "jerk" the mouse out of the window.
Secondly, you cannot let the operating system draw the mouse cursor for you, which is what you normally want to do if it's possible (DirectX fullscreen is I think the only platform where it isn't possible).

Peter Hull
Member #1,136
March 2001

This is a duplicate of this one.

Pete

Go to: