<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>User Events?</title>
		<link>http://www.allegro.cc/forums/view/607803</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 09 Jul 2011 09:43:44 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried reading it in the docs, but I became hopelessly lost, really really fast, right around here:<br /><span class="source-code"><span class="k1">bool</span> <a href="http://www.allegro.cc/manual/al_emit_user_event"><span class="a">al_emit_user_event</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_EVENT_SOURCE"><span class="a">ALLEGRO_EVENT_SOURCE</span></a> <span class="k3">*</span>src,<a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a> <span class="k3">*</span>event, <span class="k1">void</span> <span class="k2">(</span><span class="k3">*</span>dtor<span class="k2">)</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_USER_EVENT"><span class="a">ALLEGRO_USER_EVENT</span></a> <span class="k3">*</span><span class="k2">)</span><span class="k2">)</span></span><br />I understand that I have to make an event source, then register it. But what is the normal event argument and what&#39;s dtor? D:
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Sat, 09 Jul 2011 00:33:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>RTFM some more? There&#39;s more to the documentation than the function signature...</p><p>Essentially though, the use case would be like this:</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_EVENT_SOURCE"><span class="a">ALLEGRO_EVENT_SOURCE</span></a> source<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_init_user_event_source"><span class="a">al_init_user_event_source</span></a><span class="k2">(</span><span class="k3">&amp;</span>source<span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/ALLEGRO_EVENT_QUEUE"><span class="a">ALLEGRO_EVENT_QUEUE</span></a><span class="k3">*</span> queue <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_event_queue"><span class="a">al_create_event_queue</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_register_event_source"><span class="a">al_register_event_source</span></a><span class="k2">(</span>queue, <span class="k3">&amp;</span>source<span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a> event<span class="k2">;</span>
event.user.data1 <span class="k3">=</span> <span class="n">5</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/al_emit_user_event"><span class="a">al_emit_user_event</span></a><span class="k2">(</span><span class="k3">&amp;</span>source, <span class="k3">&amp;</span>event, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a> event2<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_wait_for_event"><span class="a">al_wait_for_event</span></a><span class="k2">(</span>queue, <span class="k3">&amp;</span>event2<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%d\n"</span>, <span class="k2">(</span><span class="k1">int</span><span class="k2">)</span>event2.user.data1<span class="k2">)</span><span class="k2">;</span> <span class="c">// will print 5</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 09 Jul 2011 00:49:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So if a user source can emit normal events, then what&#39;s the point of user events?<br />Also, I have no idea what manual you&#39;re reading, but hell, I&#39;d love to get my hands on it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Sat, 09 Jul 2011 01:00:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607803/924105#target">Aaron Santiago</a> said:</div><div class="quote"><p>
So if a user source can emit normal events
</p></div></div><p>
How did you arrive at this conclusion? A user source can only emit user events.</p><p>EDIT: <s>Well, looking at the source I guess it would work. But that&#39;s an implementational detail, it certainly is not documented.</s> Nvm, it is not guaranteed to work.</p><p>Either way, user events are useful because they have 4 separate data fields that you can fill with anything you desire. No other event type has the same.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 09 Jul 2011 01:24:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s what the code you posted did, it emitted a normal event.<br />The user events aren&#39;t that well documented, and it would seem that what you posted wouldn&#39;t work.
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a> event<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_USER_EVENT"><span class="a">ALLEGRO_USER_EVENT</span></a> userEvent<span class="k2">;</span> <span class="c">//?</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Sat, 09 Jul 2011 03:35:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607803/924117#target">Aaron Santiago</a> said:</div><div class="quote"><p>That&#39;s what the code you posted did, it emitted a normal event.</p></div></div><p>
You&#39;re misunderstaning.<br />It emits an <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a></span>, as all event sources do. One particular type of event is an <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_USER_EVENT"><span class="a">ALLEGRO_USER_EVENT</span></a></span>, others are <span class="source-code">ALLEGRO_KEYBOARD_EVENT</span> or <span class="source-code">ALLEGRO_DISPLAY_EVENT</span>.<br />To access the fields of that particular event type from an <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_EVENT"><span class="a">ALLEGRO_EVENT</span></a></span> you use the &quot;user&quot;, &quot;keyboard&quot;, &quot;display&quot; etc. fields. Alternatively, you could cast the ALLEGRO_EVENT to the event type you&#39;re using.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 09 Jul 2011 04:39:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That makes sense.<br />The thing is, in the docs it says that an ALLEGRO_USER_EVENT is its own object, horribly confusing.<br />So then, SiegeLord&#39;s code should work as posted, correct?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Sat, 09 Jul 2011 06:17:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you looked at ex_user_events.c?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sat, 09 Jul 2011 07:42:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t think the documentation for user events is that great either. The <a href="http://www.allegro.cc/manual/5/allegro_event">manual entry for ALLEGRO_EVENT</a> doesn&#39;t mention how to test for a user event type when processing events from a queue. Are we supposed to set event.type to some magic number that we remember later or what? Also, the &#39;user&#39; field of an ALLEGRO_EVENT that represents an ALLEGRO_USER_EVENT is not documented anywhere either, and it should probably be on the ALLEGRO_EVENT manual page.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 09 Jul 2011 09:31:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, the user field kind of blew my mind a little. There&#39;s like 0 documentation on this, really.<br />But ex_user_events.c did clear enough of it up that I think I can use it as a reference to utilize user events for myself.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Sat, 09 Jul 2011 09:43:44 +0000</pubDate>
	</item>
</rss>
