From 143cce94eea904ef025c94238fe3541b87ad694e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 5 Apr 2021 22:28:26 -0700 Subject: support for arrow keys Mu's keyboard handling is currently a bit of a mess, and this commit might be a bad idea. Ideally keyboards would return Unicode. Currently Mu returns single bytes. Mostly ASCII. No support for international keyboards yet. ASCII and Unicode have some keyboard scancodes grandfathered in, that don't really make sense for data transmission. Like backspace and delete. However, other keyboard scancodes don't have any place in Unicode. Including arrow keys. So Mu carves out an exception to Unicode for arrow keys. We'll place the arrow keys in a part of Unicode that is set aside for implementation-defined behavior (https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_controls): 0x80: left arrow 0x81: down arrow 0x82: up arrow 0x83: right arrow The order is same as hjkl for mnemonic convenience. I'd _really_ to follow someone else's cannibalization here. If I find one later, I'll switch to it. Applications that blindly assume the keyboard generates Unicode will have a bad time. Events like backspace, delete and arrow keys are intended to be processed early and should not be in text. With a little luck I won't need to modify this convention when I support international keyboards. --- 102keyboard.subx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to '102keyboard.subx') diff --git a/102keyboard.subx b/102keyboard.subx index e8d23962..0c8826e1 100644 --- a/102keyboard.subx +++ b/102keyboard.subx @@ -6,6 +6,18 @@ == code +# Most keys correspond to their ASCII/Unicode values. +# TODO: Support for international keyboards and multi-byte Unicode. +# +# However there are some exceptions that have no assigned place in Unicode +# (and with good reason): +# 0x80 = left arrow ← +# 0x81 = down arrow ↓ +# 0x82 = up arrow ↑ +# 0x83 = right arrow → +# These code points are not used by Unicode and their semantics are agreed to +# be context-sensitive: https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_controls. +# Mu cannibalizes them in yet another non-standard way. read-key: # kbd: (addr keyboard) -> result/eax: byte # . prologue 55/push-ebp -- cgit 1.4.1-2-gfad0