Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Cmd.PhysicalKey

Contents

Description

Handle physical_key layout.

Synopsis

key layout

physical_key :: CallStack.Stack => Char -> Char Source #

Map a physical key, written relative to USA qwerty layout, to whatever character that key actually emits (if the layout is already USA qwerty then it's id of course). This is for layouts which should be done based on physical key position, like piano-style keyboards. It makes the overlapping-ness of non-mapped keys hard to predict though.

Since it's intended to map literal key characters, there is no accomodation for failure. Really this should be done at compile time, so it's conceptually a compile time error.

TODO isn't there some way I can get this at compile time? template haskell?

This uses #ifdef TESTING to avoid depending on Local.KeyLayout in tests. It's hardcoded to dvorak because that's what I used before, if anyone ever cares it could switch to qwerty.

The alternative to CPP would be pass layout in StaticConfig as a runtime parameter. But that would require a bunch of extra work, e.g. keymaps would then need a separate PhysicalKey type wrapper and a resolution step.

pitch_map :: Map Char Pitch.Pitch Source #

Map logical keys to the pitches they emit when kbd entry is on. It's in this module so it can be shared with instruments that also want to take over those keys. I intentionally omit some keys so their editing functions still work in kbd entry.