On a German QWERTZ Keyboard layout, the question mark key is not passed to love.keypressed at all.
Why is that? The question mark is part of the normal Ascii-Table, so it should be easily available in Lua (and, of course, I can print it onto the screen properly) - but I can't type it when trying to create an input box.
Why is '?' not recognized on love.keypressed?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Why is '?' not recognized on love.keypressed?
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Why is '?' not recognized on love.keypressed?
Do you mean that you get nothing if you try something like "if key == '?' then" or "if string.char(unicode) == '?' then" or that love.keypressed isn't even called when you type a question mark? (I don't have a QWERTZ keyboard myself so it is a bit hard to help you out here.)
Help us help you: attach a .love.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Why is '?' not recognized on love.keypressed?
Unfortunately SDL1.2 is a bit picky about keyboards and keycodes, it seems to only pick up keycodes for keys that exist in a us layout (this may depend on the system it was compiled on).
Re: Why is '?' not recognized on love.keypressed?
*repeats bartbes' message because I'm too lazy to edit this*
When you hit a key, the scancode that the keyboard sends gets translated by a few layers. It gets a bit problematic for non-US keyboard when the SDL 1.2 layer comes up because it doesn't recognize/translate all layouts properly. LÖVE then just shrugs off the keypress.
This should be fixed in LÖVE 0.9.0 because it's now using SDL 2 which has much better support in that regard. Check out the development builds. If it still doesn't work, the LÖVE or SDL layer has an issue. Throw a ticket on the issue tracker in that case.
When you hit a key, the scancode that the keyboard sends gets translated by a few layers. It gets a bit problematic for non-US keyboard when the SDL 1.2 layer comes up because it doesn't recognize/translate all layouts properly. LÖVE then just shrugs off the keypress.
This should be fixed in LÖVE 0.9.0 because it's now using SDL 2 which has much better support in that regard. Check out the development builds. If it still doesn't work, the LÖVE or SDL layer has an issue. Throw a ticket on the issue tracker in that case.
Shallow indentations.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: Why is '?' not recognized on love.keypressed?
Hi,
thanks for all the quick responses?
When other keys are pressed it either interprets them correctly or at least prints "unknown" as the key value and gives the unicode, so I could interpret it. But not so with the öäü, ß and ? keys.
However, giving this some more thought: I might actually switch to 0.9.0 for this project, because it'll probably be a few years before it's done.
@bekey: Your method seems nice, but won't really solve my problem, I believe. Of course, this way I can let people use some other key to print the ?, but since the keypressed event is not called and even love.keyboard.isDown doesn't recoginze the ?, I guess there's not way to fix this, without recompiling Löve.
Too bad. I think I'll make the switch to 0.9 then.
Still, thank you all!
thanks for all the quick responses?
Robin, I meant the latter: love.keypressed will be called when I press the lshift button, but not when I press the key the ? is on.Robin wrote:Do you mean that you get nothing if you try something like "if key == '?' then" or "if string.char(unicode) == '?' then" or that love.keypressed isn't even called when you type a question mark? (I don't have a QWERTZ keyboard myself so it is a bit hard to help you out here.)
When other keys are pressed it either interprets them correctly or at least prints "unknown" as the key value and gives the unicode, so I could interpret it. But not so with the öäü, ß and ? keys.
Indeed, it works in Love 0.9, I tried it a few months back. What I was looking for was a workaround for 0.8.0.Boolsheet wrote: This should be fixed in LÖVE 0.9.0 because it's now using SDL 2 which has much better support in that regard. Check out the development builds. If it still doesn't work, the LÖVE or SDL layer has an issue. Throw a ticket on the issue tracker in that case.
However, giving this some more thought: I might actually switch to 0.9.0 for this project, because it'll probably be a few years before it's done.
@bekey: Your method seems nice, but won't really solve my problem, I believe. Of course, this way I can let people use some other key to print the ?, but since the keypressed event is not called and even love.keyboard.isDown doesn't recoginze the ?, I guess there's not way to fix this, without recompiling Löve.
Too bad. I think I'll make the switch to 0.9 then.
Still, thank you all!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: Why is '?' not recognized on love.keypressed?
Follow up problem:
I tried it with Löve 0.9.0. Now I can input the characters just fine, but now font:getWidth() fails on characters like ö, ü, ä ß etc.
The functions I programmed heavily rely on those characters - I'd hate to just throw them away.
Of course I could substitute them in the strings by o,u,a and s, use the new strings for word wrapping and then use the original strings to display the text.
This is extremly inconvenient though, and will be slow. Also, mathing umlauts in Lua is not trivial.
Any suggestions?
I tried it with Löve 0.9.0. Now I can input the characters just fine, but now font:getWidth() fails on characters like ö, ü, ä ß etc.
The functions I programmed heavily rely on those characters - I'd hate to just throw them away.
Of course I could substitute them in the strings by o,u,a and s, use the new strings for word wrapping and then use the original strings to display the text.
This is extremly inconvenient though, and will be slow. Also, mathing umlauts in Lua is not trivial.
Any suggestions?
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
- slime
- Solid Snayke
- Posts: 3132
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Why is '?' not recognized on love.keypressed?
Are the files with those strings saved with UTF-8 encoding?
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: Why is '?' not recognized on love.keypressed?
Uh, that was the problem. Thanks, it's working now!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Who is online
Users browsing this forum: Ahrefs [Bot], keharriso and 87 guests