hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/kernel/input.rv
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-06 12:49:46 +0200
committerhachem <im@hachem.wtf>2026-10-06 12:49:46 +0200
commit5d4a723a5f157c0ed38a348099a600d1d21c3c2b (patch)
tree70e5fdf560a64cd0eb3a13d88ce046ddd29fd077 /kernel/input.rv
parent52dab7fc85d877e80e3032f0afabae906adebad8 (diff)
feat: gils core utils and other shit
Diffstat (limited to 'kernel/input.rv')
-rw-r--r--kernel/input.rv34
1 files changed, 17 insertions, 17 deletions
diff --git a/kernel/input.rv b/kernel/input.rv
index 7e0d156..26ce545 100644
--- a/kernel/input.rv
+++ b/kernel/input.rv
@@ -1,8 +1,8 @@
# keyboard scancode table
# ts is not a good way to write a driver lmao
-const KBD = " 1234567890-= qwertyuiop[] asdfghjkl;'` \\zxcvbnm,./ "
-const KBD_SHIFT = " !@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"~ |ZXCVBNM<>? "
+const KEYMAP = " 1234567890-= qwertyuiop[] asdfghjkl;'` \\zxcvbnm,./ "
+const KEYMAP_SHIFT = " !@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"~ |ZXCVBNM<>? "
# 8259 pic
fn pic_remap() do
@@ -25,7 +25,7 @@ end
# she stroke my keys till i handle
# no fr this is just a key stroke handler
-global shell = { line = "", shift = :false, ext = :false }
+global shell = { line = "", shift = :false, extended = :false }
fn decode_key(code) do
if code == 0x2a or code == 0x36 do shell.shift = :true return :nil end # shift down
@@ -34,16 +34,16 @@ fn decode_key(code) do
if code == 28 return "\n" # enter
if code == 14 return "\x08" # backspace
if code < 2 return :nil
- if code >= KBD:len() return :nil
- const ch = if shell.shift KBD_SHIFT[code] else KBD[code]
- if ch == " " and code != 0x39 return :nil # blank cells = modifiers/unmapped
- ch
+ if code >= KEYMAP:len() return :nil
+ const character = if shell.shift KEYMAP_SHIFT[code] else KEYMAP[code]
+ if character == " " and code != 0x39 return :nil # blank cells = modifiers/unmapped
+ character
end
global on_key = fn(code) do
- if code == 0xe0 do shell.ext = :true return :nil end
- if shell.ext do
- shell.ext = :false
+ if code == 0xe0 do shell.extended = :true return :nil end
+ if shell.extended do
+ shell.extended = :false
let final = 0
if code == 0x48 do final = 65 end # up
else if code == 0x50 do final = 66 end # down
@@ -56,14 +56,14 @@ global on_key = fn(code) do
end
return :nil
end
- const ch = decode_key(code)
- if ch == :nil return :nil
- if stdin_deliver(ch:ascii()) return :nil
- if ch == "\n" do puts("\n") run(shell.line) shell.line = "" return :nil end
- if ch == "\x08" do
+ const character = decode_key(code)
+ if character == :nil return :nil
+ if stdin_deliver(character:ascii()) return :nil
+ if character == "\n" do puts("\n") run(shell.line) shell.line = "" return :nil end
+ if character == "\x08" do
if shell.line:len() > 0 do shell.line = shell.line:sub(0, shell.line:len() - 1) puts("\x08 \x08") end
return :nil
end
- shell.line ~= ch
- puts(ch)
+ shell.line ~= character
+ puts(character)
end