|
ALLEGRO_KEYBOARD_EVENT -> unichar and CAPS Problem |
count
Member #5,401
January 2005
|
When pressing the a key, keyboard_event->unichar delivers a. So thats my roblem... I thought that when pressing caps + 1 it would deliver ! because unichar takes the modifiers into account (which it does for the letters). Same happens with all the numbers, öäü and , . - and basically everything that isn't a plain(english?) letter. Am I doing something wrong or is this an error/supposed to work like this? Still on 4.9.8 btw.
|
Trent Gamblin
Member #261
April 2000
|
Type some text into a text editor with caps on. Does 1 turn to !?
|
count
Member #5,401
January 2005
|
Yes.
|
Trent Gamblin
Member #261
April 2000
|
That's odd to me. Caps lock for me only capitalizes letters.
|
Peter Wang
Member #23
April 2000
|
Never ever seen that behaviour before. Probably no one else who has worked on the Windows keyboard driver has seen that before either.
|
Arthur Kalliokoski
Second in Command
February 2005
|
He meant pressing '1' WHILE pressing SHIFT outputs a '!' whether or not caps lock is on They all watch too much MSNBC... they get ideas. |
count
Member #5,401
January 2005
|
Yes, arthur got it right.
|
Trent Gamblin
Member #261
April 2000
|
The code uses towupper from the windows api so I don't know why those accented characters aren't capitalized, if you have your locale set properly. As for 1 and ! I don'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?
|
count
Member #5,401
January 2005
|
Hmm... wouldn't a table be a crapload of work to implement for different keyboard layouts? If there is a winapi function I don't know... but I thought there HAS to be one. Will try to find something out.
|
Ron Novy
Member #6,982
March 2006
|
Did toupper in the old 4.2.2 API work correctly for this? ---- |
Elias
Member #358
May 2000
|
No, the old API asked Windows directly for the Unicode character. toupper can never work. [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. -- |
count
Member #5,401
January 2005
|
I'm a little bit confused now. Is the implementation in a5 not correct or is it not supposed to work like I want it? What should happen when pressing: What i thought what would happen is this: What currently is happening is that the chars are not changed at all: So first thing to know would what should happen?
|
Neil Walker
Member #210
April 2000
|
Does it output the same characters to the debug window, a file and the screen? Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Elias
Member #358
May 2000
|
Christopher Bludau said:
So first thing to know would what should happen? Are you talking about having CAPS LOCK on or off? -- |
count
Member #5,401
January 2005
|
Neil Walker said: Does it output the same characters to the debug window, a file and the screen?
Eh... I tested only to a file myself. EDIT: Elias said: Are you talking about having CAPS LOCK on or off?
caps lock OFF. Edit2:
|
Evert
Member #794
November 2000
|
As far as I know, what should happen is the following: The key code returned is not affected by modifier keys. So pressing "a" returns the same key code as "shift+a" and "1" is the same key code as "shift+1". Independent of whether caps lock is on or off. If the above is not the behavior you see (which I think is what you're saying), then it's a bug. |
count
Member #5,401
January 2005
|
Ok. So it's a bug. Just want to make sure that with character code you mean the value returned by keyboard_event.unichar? EDIT: Steps to reproduce: start ex_keyboard_events This happens not when the first letter is not entered with shift
|
Evert
Member #794
November 2000
|
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 "a" with caps lock on produces a lower case "a"). That might be easy to fix though, and it doesn't relate directly to the Windows port problems anyway. |
Elias
Member #358
May 2000
|
I just looked at the Windows keyboard code, and it's completely broken... we don't handle keyboard state properly at all. To have e.g. SHIFT+A produce a capital A, there is a check if allegro's shift key is pressed, and then toupper is used to convert an a into an A 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. 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: Listen to the WM_KEYDOWN/WN_KEYUP/WM_CHAR messages and generate Allegro's events from those and only from those. Anyone here has Windows and wants to code it? -- |
count
Member #5,401
January 2005
|
I have Windows (obviusly ) but I'm not even able to compile allegro so I doubt I will be able to do said fix.
|
|