altgr combos

This commit is contained in:
kepler155c@gmail.com 2019-04-22 02:07:34 -04:00
parent d32030bec4
commit 8a030cbc50
1 changed files with 12 additions and 9 deletions

View File

@ -71,6 +71,12 @@ function input:reset()
self.mfired = nil self.mfired = nil
end end
local function isCombo()
-- allow control-alt combinations for certain keyboards
return (keyboard.state[keys.leftAlt] or keyboard.state[keys.rightAlt]) and
(keyboard.state[keys.leftCtrl] or keyboard.state[keys.rightCtrl])
end
function input:translate(event, code, p1, p2) function input:translate(event, code, p1, p2)
if event == 'key' then if event == 'key' then
if p1 then -- key is held down if p1 then -- key is held down
@ -87,19 +93,16 @@ function input:translate(event, code, p1, p2)
end end
else else
self.state[code] = true self.state[code] = true
if self:modifierPressed() and not modifiers[code] then --or code == 57 then self.fired = false
-- why was i firing here ??
--self.fired = true
--return { code = input:toCode(keys.getName(code), code) }
else
self.fired = false
end
end end
elseif event == 'char' then elseif event == 'char' then
local combo = isCombo()
if not self.fired then if not self.fired then
self.fired = true if combo or not (keyboard.state[keys.leftCtrl] or keyboard.state[keys.rightCtrl]) then
return { code = event, ch = code } self.fired = not combo
return { code = event, ch = code }
end
-- return { code = event, ch = input:toCode(code) } -- return { code = event, ch = input:toCode(code) }
end end