scenes: remove "keys" table and replace it by a source table
This commit is contained in:
parent
0dce34e33a
commit
134edf345a
2 changed files with 24 additions and 13 deletions
|
@ -34,11 +34,8 @@ end
|
|||
function InputManager:initKeys()
|
||||
self.fakekeys = self:getKeyList(1)
|
||||
|
||||
self.sources = {}
|
||||
for i,v in ipairs(self.data) do
|
||||
self.sources[i] = {}
|
||||
self.sources[i].keys = self:getKeyList(i)
|
||||
end
|
||||
self.sources = self:getSources()
|
||||
self.fakesources = self:getSources()
|
||||
end
|
||||
|
||||
function InputManager:isDown(sourceid, padkey)
|
||||
|
@ -54,6 +51,16 @@ function InputManager:isDown(sourceid, padkey)
|
|||
return isdown
|
||||
end
|
||||
|
||||
function InputManager:getSources()
|
||||
local sources = {}
|
||||
for i,v in ipairs(self.data) do
|
||||
sources[i] = {}
|
||||
sources[i].keys = self:getKeyList(i)
|
||||
end
|
||||
|
||||
return sources
|
||||
end
|
||||
|
||||
function InputManager:getKeyList(sourceid)
|
||||
local keys = {}
|
||||
if self.data[sourceid] ~= nil then
|
||||
|
|
|
@ -34,7 +34,7 @@ function Scene:new()
|
|||
|
||||
self.assets = Assets()
|
||||
self.menusystem = MenuSystem()
|
||||
self.keys = core.input:getKeyList()
|
||||
self.sources = core.input:getSources()
|
||||
|
||||
self.inputLocked = false
|
||||
self.inputLockedTimer = 0
|
||||
|
@ -68,30 +68,34 @@ end
|
|||
|
||||
function Scene:setKeys()
|
||||
if (self.inputLocked) then
|
||||
self.keys = core.input.fakekeys
|
||||
self.sources = core.input.fakesources
|
||||
self.inputLockedTimer = self.inputLockedTimer - 1
|
||||
if (self.inputLockedTimer <= 0 ) then
|
||||
self.inputLocked = false
|
||||
end
|
||||
else
|
||||
-- TODO: make the scene input system get all inputs
|
||||
self.keys = core.input.sources[1].keys
|
||||
self.sources = core.input.sources
|
||||
end
|
||||
|
||||
self.menusystem.keys = self.keys
|
||||
self.menusystem.keys = self.sources[1].keys
|
||||
end
|
||||
|
||||
function Scene:getKeys(sourceid)
|
||||
if sourceid == nil then
|
||||
print("WARNING", "no sourceid detected, will default to 1")
|
||||
end
|
||||
|
||||
local sourceid = sourceid or 1
|
||||
if (self.inputLocked) then
|
||||
return self.keys
|
||||
return self.sources[sourceid].keys
|
||||
else
|
||||
return core.input.fakekeys
|
||||
end
|
||||
end
|
||||
|
||||
function Scene:flushKeys()
|
||||
core.input:flushKeys()
|
||||
self.keys = core.input.keys
|
||||
core.input:flushSourceKeys()
|
||||
self.sources = core.input:getSources()
|
||||
self.inputLockedTimer = 1
|
||||
self.inputLocked = true
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue