Page 1 of 1

setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 4:52 pm
by TheConfuZzledDude
So I was looking at love.keyboard.setKeyRepeat on the wiki, and I noticed that in 0.9.0, you aren't able to set the delay anymore, and instead you're only able to say whether key repeat is on at all. Does anyone know why it is like this?

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 5:02 pm
by raidho36
Because you shouldn't mess with user system settings?

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 5:17 pm
by TheConfuZzledDude
raidho36 wrote:Because you shouldn't mess with user system settings?
Does it directly alter system settings? I would thing it would just be in the program...

Even so, then there wouldn't be any option to turn of the repeat in 0.9.0 at all!

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 5:31 pm
by Robin
You can't turn it off, but you can ignore it. IIRC, in 0.9.0 love.keypressed has an argument is_repeat or something like that (can't find it on the wiki, though :( ). If you check for that, you can ignore repeated keypresses.

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 5:40 pm
by TheConfuZzledDude
The function still remains the same in effect if you want to turn of repeating. However, in 0.8.0, you can also set the delay before it starts auto repeating, and how many times per second it repeats, which is just a useful little feature. Could it have something to do with the unicode part of of love.keypresesd being split up into love.textinput?

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 5:41 pm
by slime
In 0.9.0 key repeat for keypress events is disabled by default just like in 0.8.0, but when enabled it uses the computer's settings for the delay between repeats. This is what users will expect, since it's consistent with every other program they'll run, rather than the delay being some random number different for each game.

Repeat text input events (see love.textinput) can't be disabled or detected (and you shouldn't need to do either), since text input is separate from key presses now, and the events are again generated based on what the user inputs rather than what the game decides.

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 5:53 pm
by TheConfuZzledDude
I see why now, but having the delay and interval settings for other key presses, independent from the text input, can be quite handy for adding in easy auto-fire buttons, even if it is just for debugging.

Re: setKeyRepeat in 0.9.0

Posted: Mon Sep 02, 2013 6:18 pm
by slime
TheConfuZzledDude wrote:I see why now, but having the delay and interval settings for other key presses, independent from the text input, can be quite handy for adding in easy auto-fire buttons, even if it is just for debugging.
You can use a timer library like hump.timer, or do something like this:

Code: Select all

local repeat_timer = 0
local repeat_delay = 0.1 -- seconds

function love.update(dt)
	if love.keyboard.isDown("mykey") then
		if repeat_timer >= repeat_delay then
			DoThings()
			repeat_timer = 0
		else
			repeat_timer = repeat_timer + dt
		end
	else
		repeat_timer = 0
	end
end