[fixed] setKeyRepeat + toggleFullscreen issue

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
Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

[fixed] setKeyRepeat + toggleFullscreen issue

Post by Saegor »

hello

when i use love.graphics.toggleFullscreen(), it deactivates keyboard.setKeyRepeat(). i WONDER why !

here is a quick test code :

Code: Select all

function love.load()

	x = 0

	love.keyboard.setKeyRepeat(.1, .1)
--	love.graphics.toggleFullscreen()
end

function love.draw()

	love.graphics.print(x, 0, 0)
end

function love.keypressed(key)

	if key == " " then x = x + 1 end
	if key == "escape" then love.event.quit() end
end
it draw a number that increase when space is pressed
hold space and number go to the sky
but if you edit the code to uncomment the fifth line, the setRepeatKey function will go back to default values :shock:
Attachments
fullkeybug_uncommented.love
(296 Bytes) Downloaded 67 times
fullkeybug_commented.love
(298 Bytes) Downloaded 69 times
Last edited by Saegor on Sun Jan 27, 2013 11:44 pm, edited 1 time in total.
Current work : Isömap
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: setKeyRepeat + toggleFullscreen issue

Post by bartbes »

Just fixed, should be in 0.8.1.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: setKeyRepeat + toggleFullscreen issue

Post by miko »

Saegor wrote:hello

when i use love.graphics.toggleFullscreen(), it deactivates keyboard.setKeyRepeat(). i WONDER why !
I bet because SDL uses 2 different APIs: X11 in case of windowed mode (assuming you are on linux), and console (or more direct access, bypassing X11 layer) in case of fullscreen mode. If you want it to work, switch the lines: first set the mode (fullscreen), then set the key repetition.
Anyways, you may want to use isDown() with a timer within love.update() instead.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

Re: setKeyRepeat + toggleFullscreen issue

Post by Saegor »

thanks miko, thanks bartbes !
Current work : Isömap
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: [fixed] setKeyRepeat + toggleFullscreen issue

Post by bartbes »

What miko said is actually wrong, it's simply because the window is recreated, which means most/all settings on it are lost, I just added some code to pull the current keyrepeat settings before executing the internal version of setMode, then restoring them afterwards.

EDIT: For all setModes, btw, not just toggleFullscreen.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: [fixed] setKeyRepeat + toggleFullscreen issue

Post by miko »

bartbes wrote:What miko said is actually wrong, it's simply because the window is recreated
Oh, good to know. I should have checked out the source code first :3
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests