-
Notifications
You must be signed in to change notification settings - Fork 2
Keyboard Input Handling: Row Editor (FamiTrackerView.cpp)
Keyboard input is handled by class CFamiTrackerView.
Keyboard input comes from OnKeyDown and OnChar.
-
Keycode
isint64_t
(TODO change types), since it helps catch function signature errors.- Keycodes encompass A-Z, 0-9, and a series of Win32/MFC VK_... constants, and do not match ASCII/Unicode in general.
- This was the only method of input in FamiTracker and 0CC.
-
Character
is astrong_typedef
ofint
, which does not support arithmetic operations.- Characters are CP1252 (eventually Unicode?) and match ASCII.
-
Input
is astd::variant<Keycode, Character>
.
All keys with associated characters trigger both OnKeyDown and OnChar. OnKeyDown handles alphanumeric keys and special mappings. OnChar handles non-alphanumeric characters (effect names only, at the moment). If you add special mappings (Clear, Repeat, Echo Buffer...) on top of non-alphanumeric effects (=00), OnKeyDown (mapping) triggers, then OnChar (=00).
-
OnKeyDown handles keycodes, and passes HandleKeyboardInput a
Keycode
.- HandleKeyboardInput's children process alphanumeric keycodes and special mappings.
- Children ignore non-alphanumeric keys, if they're not special keys.
-
OnChar handles characters, and passes HandleKeyboardInput a non-alphanumeric
Character
.- OnChar drops all alphanumeric characters.
- OnChar drops key repeats (if desired).
-
HandleKeyboardInput takes an
Input
(Keycode or Character). If input isKeycode
, HandleKeyboardInput drops key repeats (if desired).- Most child functions are never called on
Character
inputs, and only get passedKeycode
s. -
Character
inputs are ignored unless the cursor is in the effect name column. - If the cursor is in the effect name column, EditEffNumberColumn gets called.
- Most child functions are never called on
-
EditEffNumberColumn takes an
Input
, unlike other functions.- Effect names are expressed in ASCII, so EditEffNumberColumn aborts on non-alphanumeric
Keycode
s (which don't match ASCII).
- Effect names are expressed in ASCII, so EditEffNumberColumn aborts on non-alphanumeric
Lessons learned: std::variant is a pain to work with. https://github.com/solodon4/Mach7 supports pattern-matching, but only on boost::variant. I can't tell if it's a precompiler or a library.