setKeyRepeat in 0.9.0
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 21
- Joined: Fri Nov 02, 2012 10:23 pm
setKeyRepeat in 0.9.0
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
Because you shouldn't mess with user system settings?
-
- Prole
- Posts: 21
- Joined: Fri Nov 02, 2012 10:23 pm
Re: setKeyRepeat in 0.9.0
Does it directly alter system settings? I would thing it would just be in the program...raidho36 wrote:Because you shouldn't mess with user system settings?
Even so, then there wouldn't be any option to turn of the repeat in 0.9.0 at all!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: setKeyRepeat in 0.9.0
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.
-
- Prole
- Posts: 21
- Joined: Fri Nov 02, 2012 10:23 pm
Re: setKeyRepeat in 0.9.0
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?
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: setKeyRepeat in 0.9.0
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.
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.
-
- Prole
- Posts: 21
- Joined: Fri Nov 02, 2012 10:23 pm
Re: setKeyRepeat in 0.9.0
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.
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: setKeyRepeat in 0.9.0
You can use a timer library like hump.timer, or do something like this: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.
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
Who is online
Users browsing this forum: No registered users and 2 guests