input rework - again

This commit is contained in:
kepler155c@gmail.com 2019-05-26 11:05:37 -04:00
parent 310879a801
commit 82ec4db50f
1 changed files with 11 additions and 7 deletions

View File

@ -92,28 +92,32 @@ function input:translate(event, code, p1, p2)
return { code = ch } return { code = ch }
end end
elseif code then elseif code then
self.state[code] = true --self.fired = true
self.fired = false local ch = input:toCode(keys.getName(code), code)
if #ch ~= 1 then
return { code = ch }
end
-- self.state[code] = true
end end
elseif event == 'char' then elseif event == 'char' then
local combo = isCombo() local combo = isCombo()
if not self.fired then --if not self.fired then
if combo or not (keyboard.state[keys.leftCtrl] or keyboard.state[keys.rightCtrl]) then if combo or not (keyboard.state[keys.leftCtrl] or keyboard.state[keys.rightCtrl]) then
self.fired = not combo self.fired = not combo
return { code = event, ch = code } return { code = event, ch = code }
end --end
-- return { code = event, ch = input:toCode(code) } -- return { code = event, ch = input:toCode(code) }
end end
elseif event == 'key_up' then elseif event == 'key_upx' then
if not self.fired then if not self.fired then
if self.state[code] then --if self.state[code] then
self.fired = true self.fired = true
local ch = input:toCode(keys.getName(code), code) local ch = input:toCode(keys.getName(code), code)
self.state[code] = nil self.state[code] = nil
return { code = ch } return { code = ch }
end --end
end end
self.state[code] = nil self.state[code] = nil