<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 4.2.2 on OSX </title>
		<link>http://www.allegro.cc/forums/view/597908</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 11 Oct 2008 16:03:05 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
I didn&#39;t have much luck last time I posted a question related to this, so I&#39;ve tried to more clearly explain my question. </p><p>I&#39;m currently porting a title to OSX.</p><p>It&#39;s been a relatively smooth process and the game is running pretty<br />good now. The only real problem I&#39;ve had has been the way that the<br />mouse behaves under OSX.</p><p>The problem has been mostly related to the interaction between two<br />parts of code.</p><p>osx_mouse_handler in qzmouse.m</p><p>osx_mouse_position in qzmouse.m</p><p>link below</p><p><a href="http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/tags/v4-2-2/src/macosx/qzmouse.m?view=markup">http://alleg.svn.sourceforge.net/viewvc/alleg/allegro/tags/v4-2-2/src/macosx/qzmouse.m?view=markup</a></p><p>So osx_mouse_position gets called every frame to stop the mouse<br />leaving the gameplay window and messing up the game play, however<br />mouse mickeys do get used to move the character(s) around the screen,<br />aim and use the software cursor and menus ingame.</p><p>These lines below in osx_mouse_position have made the process a little<br />tricky. Depending on when mouse_position gets called in the game,<br />mickeys may work or not, however it doesn&#39;t seem to matter in Windows, althought I&#39;ve looked and mouse mickeys get zeroed in the windows &quot;mouse_position&quot; method also. </p><div class="source-code snippet"><div class="inner"><pre>mymickey_x <span class="k3">=</span> mymickey_y <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
osx_mouse_warped <span class="k3">=</span> TRUE<span class="k2">;</span>
</pre></div></div><p>

Also later in osx_mouse_handler there is</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">if</span> <span class="k2">(</span>osx_mouse_warped<span class="k2">)</span> <span class="k2">{</span>
      osx_mouse_warped <span class="k3">=</span> FALSE<span class="k2">;</span>
      <span class="k1">return</span><span class="k2">;</span>
  <span class="k2">}</span>
</pre></div></div><p>

before any of the mouse_b, mouse_x or mouse_y gets updated. So<br />unfortunately it seems that calling osx_mouse_position will always<br />reset the mouse button, and <b>possibly</b> depending on when it is called<br />in the frame , will also remove the mouse mickey updates.</p><p>I&#39;ve hacked my allegro included in the game to basically not reset<br />osx_mouse_warped until after updating the mouse_b. This is seems to<br />work fine now, especially when I find the right place to call<br />mouse_position from so as to not cancel out my mouse mickeys.</p><p>However, I&#39;m wondering why it was important in the first place to care<br />about the mouse warp, and why you would reset the mouse mickeys in<br />osx_mouse_position? It seems to me the primary reason for<br />mouse_position is to prevent the os mouse from leaving the window and<br />being able to update the allegro mouse cursor using mouse mickeys? I<br />just want some insight so that I understand if I&#39;m potentially<br />breaking something or not.</p><p>I&#39;m not an allegro expert by any means, it&#39;s the first time I have<br />used the library and for the most part have not had to worry about it,<br />it does the right thing. So perhaps I&#39;m just mistaken and should<br />change the design of the game?</p><p>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?</p><p>Anyway. I much appreciate any time you spend in answering my question,<br />or pointing me in the right direction.</p><p>Thank you!</p><p>Chris K.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (montdidier)</author>
		<pubDate>Tue, 07 Oct 2008 13:39:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;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 &quot;experts&quot; here to help you. Sorry I couldn&#39;t help...:&#39;(
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Sat, 11 Oct 2008 07:04:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, I did have a quick look at this the other day.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
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?
</p></div></div><p>
It seems that OS X does not send mouse movement events after the mouse has left the window (or &quot;tracking rectangle&quot; I think it&#39;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&#39;m guessing it should (optionally) do that in OS X as well. It&#39;s quite possible that no one has looked at it or tried it before in OS X.</p><p>There are a few drawbacks to this, however. First of all, it can be really annoying in windowed applications, although you can usually &quot;jerk&quot; the mouse out of the window.<br />Secondly, you cannot let the operating system draw the mouse cursor for you, which is what you normally want to do if it&#39;s possible (DirectX fullscreen is I think the only platform where it isn&#39;t possible).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 11 Oct 2008 08:23:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is a duplicate of <a href="http://www.allegro.cc/forums/thread/597835/773220#target">this one</a>.</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Sat, 11 Oct 2008 16:03:05 +0000</pubDate>
	</item>
</rss>
