forked from izaya/LuPPC
Compare commits
8 Commits
ecdc855ee0
...
f847f6a2ca
Author | SHA1 | Date | |
---|---|---|---|
f847f6a2ca | |||
b16fa6aeb7 | |||
4331bdf482 | |||
193afd3853 | |||
300e2d1190 | |||
8260c8f59f | |||
524411062e | |||
8570a59cab |
@ -62,30 +62,30 @@ local keymap = {
|
|||||||
|
|
||||||
[0x60 + 0x01] = 0x1E,
|
[0x60 + 0x01] = 0x1E,
|
||||||
[0x60 + 0x02] = 0x30,
|
[0x60 + 0x02] = 0x30,
|
||||||
[0x60 + 0x04] = 0x2E,
|
[0x60 + 0x03] = 0x2E,
|
||||||
[0x60 + 0x05] = 0x20,
|
[0x60 + 0x04] = 0x20,
|
||||||
[0x60 + 0x06] = 0x12,
|
[0x60 + 0x05] = 0x12,
|
||||||
[0x60 + 0x07] = 0x21,
|
[0x60 + 0x06] = 0x21,
|
||||||
[0x60 + 0x08] = 0x22,
|
[0x60 + 0x07] = 0x22,
|
||||||
[0x60 + 0x09] = 0x23,
|
[0x60 + 0x08] = 0x23,
|
||||||
[0x60 + 0x0A] = 0x17,
|
[0x60 + 0x09] = 0x17,
|
||||||
[0x60 + 0x0B] = 0x24,
|
[0x60 + 0x0A] = 0x24,
|
||||||
[0x60 + 0x0C] = 0x25,
|
[0x60 + 0x0B] = 0x25,
|
||||||
[0x60 + 0x0D] = 0x26,
|
[0x60 + 0x0C] = 0x26,
|
||||||
[0x60 + 0x0E] = 0x32,
|
[0x60 + 0x0D] = 0x32,
|
||||||
[0x60 + 0x0F] = 0x31,
|
[0x60 + 0x0E] = 0x31,
|
||||||
[0x60 + 0x11] = 0x18,
|
[0x60 + 0x0F] = 0x18,
|
||||||
[0x60 + 0x12] = 0x19,
|
[0x60 + 0x10] = 0x19,
|
||||||
[0x60 + 0x13] = 0x10,
|
[0x60 + 0x11] = 0x10,
|
||||||
[0x60 + 0x14] = 0x13,
|
[0x60 + 0x12] = 0x13,
|
||||||
[0x60 + 0x15] = 0x1F,
|
[0x60 + 0x13] = 0x1F,
|
||||||
[0x60 + 0x16] = 0x14,
|
[0x60 + 0x13] = 0x14,
|
||||||
[0x60 + 0x17] = 0x16,
|
[0x60 + 0x14] = 0x16,
|
||||||
[0x60 + 0x18] = 0x2F,
|
[0x60 + 0x16] = 0x2F,
|
||||||
[0x60 + 0x19] = 0x11,
|
[0x60 + 0x17] = 0x11,
|
||||||
[0x60 + 0x1A] = 0x2D,
|
[0x60 + 0x18] = 0x2D,
|
||||||
[0x60 + 0x1B] = 0x15,
|
[0x60 + 0x19] = 0x15,
|
||||||
[0x60 + 0x1C] = 0x2C,
|
[0x60 + 0x1A] = 0x2C,
|
||||||
|
|
||||||
[13] = 28, --Return key
|
[13] = 28, --Return key
|
||||||
[127] = 14, --backspace
|
[127] = 14, --backspace
|
||||||
@ -97,24 +97,88 @@ local asciitr = {
|
|||||||
[127] = 8,
|
[127] = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local escmap = {
|
||||||
|
[65] = 200, -- up
|
||||||
|
[66] = 208, -- down
|
||||||
|
[67] = 205, -- right
|
||||||
|
[68] = 203, -- left
|
||||||
|
}
|
||||||
|
|
||||||
|
local inesc_down = false
|
||||||
|
local esc_down_ctrl = false
|
||||||
function computer.signalTransformers.key_down(s, a, ascii, key, user)
|
function computer.signalTransformers.key_down(s, a, ascii, key, user)
|
||||||
if key ~= -1 then
|
if key ~= -1 then
|
||||||
return s, a, ascii, key, user
|
return s, a, ascii, key, user
|
||||||
end
|
end
|
||||||
|
if ascii == 27 then
|
||||||
|
inesc_down = native.uptime()
|
||||||
|
return nil
|
||||||
|
elseif ascii < 27 and ascii ~= 8 and ascii ~= 13 and ascii ~= 9 then
|
||||||
|
signalQueue[#signalQueue + 1] = {s, a, 0, 29, user}
|
||||||
|
key = keymap[ascii + 96] or -1
|
||||||
|
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
|
||||||
|
if not esc_down_ctrl then
|
||||||
|
--ascii = math.max(0, ascii - 96)
|
||||||
|
else
|
||||||
|
ascii = 0
|
||||||
|
end
|
||||||
|
esc_down_ctrl = false
|
||||||
|
elseif ascii == 91 then
|
||||||
|
esc_down_ctrl = true
|
||||||
|
elseif native.uptime() - inesc_down > 100 then -- 100ms timeout after {ESC}
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
esc_down_ctrl = false
|
||||||
|
inesc_down = false
|
||||||
|
end
|
||||||
|
end
|
||||||
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
|
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local inesc_up = false
|
||||||
|
local esc_up_ctrl = false
|
||||||
function computer.signalTransformers.key_up(s, a, ascii, key, user)
|
function computer.signalTransformers.key_up(s, a, ascii, key, user)
|
||||||
if key ~= -1 then
|
if key ~= -1 then
|
||||||
return s, a, ascii, key, user
|
return s, a, ascii, key, user
|
||||||
end
|
end
|
||||||
|
if ascii == 27 then
|
||||||
|
inesc_up = native.uptime()
|
||||||
|
return nil
|
||||||
|
elseif ascii < 27 and ascii ~= 8 and ascii ~= 13 and ascii ~= 9 then
|
||||||
|
signalQueue[#signalQueue+1] = {s, a, 0, 29, user}
|
||||||
|
key = keymap[ascii + 96] or 0
|
||||||
|
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
|
||||||
|
if not esc_up_ctrl then
|
||||||
|
--ascii = math.max(0, ascii - 96)
|
||||||
|
else
|
||||||
|
ascii = 0
|
||||||
|
end
|
||||||
|
esc_up_ctrl = false
|
||||||
|
elseif ascii == 91 then
|
||||||
|
esc_up_ctrl = true
|
||||||
|
elseif native.uptime() - inesc_up > 100 then -- 100ms timeout after {ESC}
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
esc_up_ctrl = false
|
||||||
|
inesc_up = false
|
||||||
|
end
|
||||||
|
end
|
||||||
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
|
return s, a, math.floor(asciitr[ascii] or ascii), keymap[ascii] or key, user
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
function api.pushSignal(s, ...)
|
function api.pushSignal(s, ...)
|
||||||
signalQueue[#signalQueue + 1] = {computer.signalTransformers[s](s, ...)}
|
local result = table.pack(computer.signalTransformers[s](s, ...))
|
||||||
|
if result.n == 0 or not result[1] then return end
|
||||||
|
result.n = nil
|
||||||
|
signalQueue[#signalQueue + 1] = result
|
||||||
end
|
end
|
||||||
|
|
||||||
function api.pullSignal(timeout)
|
function api.pullSignal(timeout)
|
||||||
|
@ -156,6 +156,7 @@ function textgpu.start()
|
|||||||
function gpu.setForeground(color, ispalette)
|
function gpu.setForeground(color, ispalette)
|
||||||
checkArg(1, color, "number")
|
checkArg(1, color, "number")
|
||||||
checkArg(2, ispalette, "boolean", "nil")
|
checkArg(2, ispalette, "boolean", "nil")
|
||||||
|
local ret = color
|
||||||
if ispalette then
|
if ispalette then
|
||||||
if not palette[color] then
|
if not palette[color] then
|
||||||
error("invalid palette index", 2)
|
error("invalid palette index", 2)
|
||||||
@ -164,12 +165,13 @@ function textgpu.start()
|
|||||||
end
|
end
|
||||||
local index = math.floor(modules.color.nearest(color, mapping))
|
local index = math.floor(modules.color.nearest(color, mapping))
|
||||||
fg = index or fg
|
fg = index or fg
|
||||||
return true
|
return ret, ispalette
|
||||||
end
|
end
|
||||||
|
|
||||||
function gpu.setBackground(color, ispalette)
|
function gpu.setBackground(color, ispalette)
|
||||||
checkArg(1, color, "number")
|
checkArg(1, color, "number")
|
||||||
checkArg(2, ispalette, "boolean", "nil")
|
checkArg(2, ispalette, "boolean", "nil")
|
||||||
|
local ret = color
|
||||||
if ispalette then
|
if ispalette then
|
||||||
if not palette[color] then
|
if not palette[color] then
|
||||||
error("invalid palette index", 2)
|
error("invalid palette index", 2)
|
||||||
@ -178,7 +180,7 @@ function textgpu.start()
|
|||||||
end
|
end
|
||||||
local index = math.floor(modules.color.nearest(color, mapping))
|
local index = math.floor(modules.color.nearest(color, mapping))
|
||||||
bg = index or bg
|
bg = index or bg
|
||||||
return true
|
return ret, ispalette
|
||||||
end
|
end
|
||||||
|
|
||||||
function gpu.setPaletteColor(c, v)
|
function gpu.setPaletteColor(c, v)
|
||||||
|
Loading…
Reference in New Issue
Block a user