git.s-ol.nu hw/0x33.board/firmware / de692f8
add traditional piano layout s-ol 3 months ago
2 changed file(s) with 16 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
126126 # LAYOUT
127127 "layout_name": ChoiceSetting(
128128 "KEYBOARD LAYOUT",
129 ['wicki/hayden', 'harmonic table', 'gerhard', 'jankó'],
129 ['wicki/hayden', 'harmonic table', 'gerhard', 'jankó', 'trad piano'],
130130 default='wicki/hayden',
131131 ),
132132 "layout_offset": SliderSetting(
3636 return int(self.offset + 2 * x)
3737
3838
39 class TradPianoLayout(Layout):
40 PITCHES = [0, 1, 2, 3, 4, -1, 5, 6, 7, 8, 9, 10, 11, -1]
41 def get_pitch(self, key: Key) -> int:
42 x, y = key.pos
43
44 p = self.PITCHES[int(2 * x) % 14]
45 o = (2*x) // 14 + y // 2
46
47 if p < 0:
48 return p
49
50 return int(self.offset + p + 12 * o)
51
52
3953 LAYOUTS = {
4054 "wicki/hayden": WickiHaydenLayout,
4155 "harmonic table": HarmonicLayout,
4256 "gerhard": GerhardLayout,
4357 "jankó": JankoLayout,
58 "trad piano": TradPianoLayout,
4459 }