<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>ALLEGRO_KEYBOARD_EVENT -&gt; unichar and CAPS Problem</title>
		<link>http://www.allegro.cc/forums/view/600017</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 24 Apr 2009 00:20:55 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When pressing the a key, keyboard_event-&gt;unichar delivers a.<br />caps + a =&gt; A<br />1 =&gt; 1<br />caps + 1 =&gt; <b><i>1?</i></b></p><p>So thats my roblem... I thought that when pressing caps + 1 it would deliver <b>!</b> because unichar takes the modifiers into account (which it does for the letters).</p><p>Same happens with all the numbers, öäü and , . - and basically everything that isn&#39;t a plain(english?) letter.</p><p>Am I doing something wrong or is this an error/supposed to work like this?</p><p>Still on 4.9.8 btw.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Wed, 22 Apr 2009 03:07:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Type some text into a text editor with caps on. Does 1 turn to !?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 22 Apr 2009 03:20:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes.<br />Both with capslock and pressing caps manually 1+caps turns into ! in any editor I tried (like this one).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Wed, 22 Apr 2009 03:25:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s odd to me. Caps lock for me only capitalizes letters.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 22 Apr 2009 03:58:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Never ever seen that behaviour before. Probably no one else who has worked on the Windows keyboard driver has seen that before either.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Wed, 22 Apr 2009 03:59:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>He meant pressing &#39;1&#39; WHILE pressing SHIFT outputs a &#39;!&#39; whether or not caps lock is on
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 22 Apr 2009 04:00:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, arthur got it right. <br />The problem with allegro keyboard event is happening when using the shift key manually as well as with caps lock.<br />And öä etc ARE letters <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />If allegro is not making 1 to ! with capslock I can live with that. <br />But not beeing able to produce a ! at all is not so good.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Wed, 22 Apr 2009 04:15:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The code uses towupper from the windows api so I don&#39;t know why those accented characters aren&#39;t capitalized, if you have your locale set properly. As for 1 and ! I don&#39;t know what the intended behaviour is there. I could fix it with a table sure, but is there a winapi function that will apply modifiers to those keys?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 22 Apr 2009 04:29:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmm... wouldn&#39;t a table be a crapload of work to implement for different keyboard layouts?</p><p>If there is a winapi function I don&#39;t know... but I thought there HAS to be one.<br />Otherwise I don&#39;t know how windows is knowing that it shoul make shift+1 to ! or shift+ö to Ö.</p><p>Will try to find something out.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Wed, 22 Apr 2009 11:53:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Did toupper in the old 4.2.2 API work correctly for this?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ron Novy)</author>
		<pubDate>Wed, 22 Apr 2009 12:00:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, the old API asked Windows directly for the Unicode character. toupper can never work.</p><p>[Edit:] That is, I misunderstood... this seems to be only for how the CAPS LOCK key works. I have no idea what that does in A4, or what it is supposed to do. but toupper sounds quite reasonable.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 22 Apr 2009 16:14:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m a little bit confused now.</p><p>Is the implementation in a5 not correct or is it not supposed to work like I want it?</p><p>What <i>should</i> happen when pressing:<br />shift + 1?<br />shift + ö?</p><p>What i <i>thought</i> what would happen is this:<br />shift + 1 = !<br />shift + ö = Ö</p><p>What <i>currently is</i> happening is that the chars are not changed at all:<br />shift + 1 = 1<br />shift + ö = ö</p><p>So first thing to know would what <i>should</i> happen?<br />And could it be done like it was in the old api (asking windows for the unicode char?)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Wed, 22 Apr 2009 17:15:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does it output the same characters to the debug window, a file and the screen?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Wed, 22 Apr 2009 17:24:32 +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/600017/807561#target">Christopher Bludau</a> said:</div><div class="quote"><p>
So first thing to know would what should happen?<br />And could it be done like it was in the old api (asking windows for the unicode char?) 
</p></div></div><p>

Are you talking about having CAPS LOCK on or off?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 22 Apr 2009 17:32:02 +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/600017/807565#target">Neil Walker</a> said:</div><div class="quote"><p>
Does it output the same characters to the debug window, a file and the screen? 
</p></div></div><p>

Eh... I tested only to a file myself.<br />Will test later and report here.</p><p>EDIT:
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600017/807567#target">Elias</a> said:</div><div class="quote"><p>
Are you talking about having CAPS LOCK on or off? 
</p></div></div><p>

caps lock OFF.<br />manually pressing shift + letter of choice.</p><p>Edit2:<br />In my first post I was talking about caps. Because I thought the two keys were named &quot;caps&quot; and &quot;caps lock&quot;. But obviulsy it&#39;s better to use &quot;shift&quot; and &quot;caps lock&quot;? <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Wed, 22 Apr 2009 17:36:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As far as I know, what <i>should</i> happen is the following:</p><p>The <i>key code</i> returned is not affected by modifier keys. So pressing &quot;a&quot; returns the same key code as &quot;shift+a&quot; and &quot;1&quot; is the same key code as &quot;shift+1&quot;. Independent of whether caps lock is on or off.<br />The <i>character code</i> depends on the status of the modifier keys. Pressing &quot;a&quot; returns &quot;a&quot;, pressing &quot;shift+a&quot; returns &quot;A&quot;. Similarly, &quot;shift+1&quot; returns &quot;!&quot; (depending on the keyboard layout I&#39;m sure).<br />Caps lock changes the standard (un-shifted) value of letter keys from lower case to upper case. It does <i>not</i> affect other keys (this is true on all computers I have ever used; it&#39;s obviously not true on typewiters and I suppose there is a way to set this behavior as an option).</p><p>If the above is not the behavior you see (which  I think is what you&#39;re saying), then it&#39;s a bug.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 22 Apr 2009 18:21:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok. So it&#39;s a bug.</p><p>Just want to make sure that with <i>character code</i> you mean the value returned by keyboard_event.unichar?</p><p>EDIT:<br />I noticed another bug.<br />When the <b>first</b> letter that is entered into an allegro app is pressed together with shift <b>ALL</b> letters from now on will be converted to uppercase letters. <br />This happens with the allegro example too.</p><p>Steps to reproduce:</p><p>start ex_keyboard_events<br />press shift + a =&gt; A <b>(correct)</b><br />press b =&gt; B <b>(wrong)</b><br />press c =&gt; C <b>(wrong)</b><br />(even shift is not pressed from now on all letters are uppercase letters)</p><p>This happens not when the first letter is not entered with shift<br />REstart ex_keyboard events<br />press a =&gt; a <b>(correct)</b><br />press shift + b =&gt; B <b>(correct)</b><br />press c =&gt; c <b>(correct)</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Thu, 23 Apr 2009 21:12:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, I guess we figured it was a Windows-port issue, but I went ahead and tested it on OS X anyway and as expected things work fine there apart for one thing - caps lock state is ignored (so pressing &quot;a&quot; with caps lock on produces a lower case &quot;a&quot;). That might be easy to fix though, and it doesn&#39;t relate directly to the Windows port problems anyway.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Thu, 23 Apr 2009 21:51:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just looked at the Windows keyboard code, and it&#39;s completely broken... we don&#39;t handle keyboard state properly at all. To have e.g. SHIFT+A produce a capital A, there is a check if allegro&#39;s shift key is pressed, and then toupper is used to convert an a into an A <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /></p><p>Also the whole idea of receiving DInput events, but then calling GetKeyboardState for each single event instead of using the event information is kinda flawed.</p><p>My advice would be, completely get rid of the DInput keyboard driver and replace by something which is much simpler, has much better performance (although that likely will not matter for handling key pressed), and works 100% perfectly:</p><p>Listen to the WM_KEYDOWN/WN_KEYUP/WM_CHAR messages and generate Allegro&#39;s events from those and only from those. Anyone here has Windows and wants to code it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Thu, 23 Apr 2009 22:41:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have Windows (obviusly <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />) but I&#39;m not even able to compile allegro so I doubt I will be able to do said fix. <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (count)</author>
		<pubDate>Fri, 24 Apr 2009 00:20:55 +0000</pubDate>
	</item>
</rss>
