love.keypressed: problem with lshift/rshift/ralt

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Chronoc
Prole
Posts: 5
Joined: Tue Jul 29, 2014 3:26 pm
Location: Germany

love.keypressed: problem with lshift/rshift/ralt

Post by Chronoc »

Hi,

I'm having a problem with the order and combination of pressed keys:
Both shift keys doesn't combine with the keypad-keys, but the holded shift key triggers keypressed again right after releasing the keypad key.

For better understanding I made a simple test script:

Code: Select all

io.stdout:setvbuf( 'no' );
function love.keypressed( key, isrepeat )
	keys = key;
	if isrepeat then keys = keys .. ' (repeat)'; end;
	if love.keyboard.isDown( 'lshift' ) then keys = keys .. ' +lshift'; end;
	if love.keyboard.isDown( 'rshift' ) then keys = keys .. ' +rshift'; end;
	if love.keyboard.isDown( 'lctrl' ) then keys = keys .. ' +lctrl'; end;
	if love.keyboard.isDown( 'rctrl' ) then keys = keys .. ' +rctrl'; end;
	if love.keyboard.isDown( 'lalt' ) then keys = keys .. ' +lalt'; end;
	if love.keyboard.isDown( 'ralt' ) then keys = keys .. ' +ralt'; end;
	print( keys );
end
Pressing the key in following order:
lshift down, right arrow down and up, kp5 down and up, lshift up

I would expect the following output:
lshift +lshift
right +lshift
kp5 +lshift

But instead that, I get the following:
lshift +lshift
right +lshift
kp5
lshift +lshift

I am playing around with a rougue-like game, and shift+direction should let my character run. Am I missing something?

And another question: when I press ralt, the script outputs 'ralt +lctrl +ralt'. Is there a reason, that pressing ralt triggers lctrl?

I have tested this on 0.9.2win64 and 0.10.0win32 (windows7x64 with german locale/keyboard).
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: love.keypressed: problem with lshift/rshift/ralt

Post by pgimeno »

Chronoc wrote: Pressing the key in following order:
lshift down, right arrow down and up, kp5 down and up, lshift up

I would expect the following output:
lshift +lshift
right +lshift
kp5 +lshift

[...]

And another question: when I press ralt, the script outputs 'ralt +lctrl +ralt'. Is there a reason, that pressing ralt triggers lctrl?

I have tested this on 0.9.2win64 and 0.10.0win32 (windows7x64 with german locale/keyboard).
On my Debian Wheezy x86 32 bit it works exactly as you expected:

Code: Select all

lshift +lshift
right +lshift
kp5 +lshift

Code: Select all

rctrl +rctrl
EDIT: Tested with both LÖVE 0.9.1 and 0.9.2 but I suspect that the relevant bit is SDL2. Here are my SDL versions:

Code: Select all

ii  libsdl2-2.0-0:i386       2.0.2+dfsg1-6  i386
ii  libsdl2-dev              2.0.2+dfsg1-6  i386
ii  libsdl2-gfx-1.0-0:i386   1.0.1+dfsg-1   i386
ii  libsdl2-gfx-dev:i386     1.0.1+dfsg-1   i386
ii  libsdl2-image-2.0-0:i386 2.0.0+dfsg-3   i386
ii  libsdl2-image-dev:i386   2.0.0+dfsg-3   i386
ii  libsdl2-mixer-2.0-0:i386 2.0.0+dfsg1-5  i386
ii  libsdl2-mixer-dev:i386   2.0.0+dfsg1-5  i386
ii  libsdl2-ttf-2.0-0:i386   2.0.12+dfsg1-2 i386
ii  libsdl2-ttf-dev:i386     2.0.12+dfsg1-2 i386
User avatar
Chronoc
Prole
Posts: 5
Joined: Tue Jul 29, 2014 3:26 pm
Location: Germany

Re: love.keypressed: problem with lshift/rshift/ralt

Post by Chronoc »

Hi...

Thanks for your help :)

I replaced the sdl2-library with the current version 2.0.3 from libsdl.org (had to use the developer version, the retail version crashed löve), but no change.

After further testing it seems that only the number-keys and the dot (kp0 - kp9 and kp.) are affected, and not the other ones (kpenter, kp/, kp-, kp+, kp* and numlock). And the problem disappears, when numlock is turned off. Unfortunately I don't find a way to turn off numlock within löve. There even seems to be no possibility to check the state (same for capslock and scroll).

I tried to implement the functionality of love.keyboard.isDown on my own for modifier keys, but when holding the shift key and pressing e.g. kp0, the shift key is released right before the keypad key, so this isn't possible.

Can somebody with windows please confirm this behaviour? I would report an issue on bitbucket, when this problem exists not only on my system.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.keypressed: problem with lshift/rshift/ralt

Post by slime »

Maybe it's your keyboard? Microsoft has a web demo and explanation: https://www.microsoft.com/appliedscienc ... ained.mspx
User avatar
Chronoc
Prole
Posts: 5
Joined: Tue Jul 29, 2014 3:26 pm
Location: Germany

Re: love.keypressed: problem with lshift/rshift/ralt

Post by Chronoc »

I don't think it is a ghosting problem: when numlock is deactivated, everything works fine (except the ralt-thing, but thats an other problem).

Probably it's an inconsitency between sdl2 and löve.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests