fix error when unsetting the joystick while _activeDevice is 'joy'

This commit is contained in:
Andrew Minnich
2020-12-12 16:56:01 -05:00
parent 4d44f220f9
commit e5ca693641
2 changed files with 9 additions and 0 deletions

View File

@@ -191,6 +191,12 @@ end
keyboard or joystick inputs.
]]
function Player:_setActiveDevice()
-- if the joystick is unset, then we should make sure _activeDevice
-- isn't "joy" anymore, otherwise there will be an error later
-- when we try to query a joystick that isn't there
if self._activeDevice == 'joy' and not self.config.joystick then
self._activeDevice = 'none'
end
for _, control in pairs(self._controls) do
for _, source in ipairs(control.sources) do
local type, value = parseSource(source)

View File

@@ -55,6 +55,9 @@ function love.update(dt)
end
function love.keypressed(key)
if key == 'space' then
player.config.joystick = nil
end
if key == 'escape' then
love.event.quit()
end