there is now a 100ms timeout so it shouldn't get stuck in escape mode for more than 100ms **ever**

This commit is contained in:
ocawesome101 2021-06-04 16:43:46 -04:00
parent 4331bdf482
commit b16fa6aeb7
1 changed files with 8 additions and 4 deletions

View File

@ -110,15 +110,17 @@ function computer.signalTransformers.key_down(s, a, ascii, key, user)
return s, a, ascii, key, user
end
if ascii == 27 then
inesc_down = true
inesc_down = native.uptime() / 1000
return nil
elseif inesc_down then
if (ascii < 48 or ascii > 57) and ascii ~= 59 and ascii ~= 91 then
inesc_down = false
key = escmap[ascii] or 0
ascii = 0
else
elseif native.uptime() - inesc_down > 100 then -- 100ms timeout after {ESC}
return nil
else
inesc_down = false
end
end
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
@ -130,15 +132,17 @@ function computer.signalTransformers.key_up(s, a, ascii, key, user)
return s, a, ascii, key, user
end
if ascii == 27 then
inesc_up = true
inesc_up = native.uptime() / 1000
return nil
elseif inesc_up then
if (ascii < 48 or ascii > 57) and ascii ~= 59 and ascii ~= 91 then
inesc_up = false
key = escmap[ascii] or 0
ascii = 0
else
elseif native.uptime() - inesc_up > 100 then -- 100ms timeout after {ESC}
return nil
else
inesc_up = false
end
end
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user