setKeyRepeat in 0.9.0

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
TheConfuZzledDude
Prole
Posts: 21
Joined: Fri Nov 02, 2012 10:23 pm

setKeyRepeat in 0.9.0

Post 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?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: setKeyRepeat in 0.9.0

Post by raidho36 »

Because you shouldn't mess with user system settings?
TheConfuZzledDude
Prole
Posts: 21
Joined: Fri Nov 02, 2012 10:23 pm

Re: setKeyRepeat in 0.9.0

Post 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!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: setKeyRepeat in 0.9.0

Post 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.
Help us help you: attach a .love.
TheConfuZzledDude
Prole
Posts: 21
Joined: Fri Nov 02, 2012 10:23 pm

Re: setKeyRepeat in 0.9.0

Post 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?
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: setKeyRepeat in 0.9.0

Post 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.
Last edited by slime on Mon Sep 02, 2013 6:09 pm, edited 1 time in total.
TheConfuZzledDude
Prole
Posts: 21
Joined: Fri Nov 02, 2012 10:23 pm

Re: setKeyRepeat in 0.9.0

Post 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.
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: setKeyRepeat in 0.9.0

Post 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
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests