KeyMap.cpp 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. #include "core/KeyMap.h"
  2. #include "core/ModifierMap.h"
  3. #include <algorithm>
  4. #include <cctype>
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <iterator>
  8. namespace lynx::keys
  9. {
  10. namespace
  11. {
  12. struct KeyName
  13. {
  14. int key;
  15. const char* name;
  16. };
  17. const KeyName keyNames[] = {
  18. { space, "Space" }, { enter, "Enter" }, { escape, "Esc" }, { tab, "Tab" }, { backspace, "Backspace" },
  19. { del, "Delete" }, { insert, "Insert" }, { up, "Up" }, { down, "Down" }, { left, "Left" },
  20. { right, "Right" }, { pageUp, "PageUp" }, { pageDown, "PageDown" }, { home, "Home" }, { end, "End" },
  21. { numpadPlus, "Numpad +" }, { numpadMinus, "Numpad -" }, { numpadMultiply, "Numpad *" }, { numpadDivide, "Numpad /" },
  22. { numpad0, "Numpad 0" }, { numpad1, "Numpad 1" }, { numpad2, "Numpad 2" }, { numpad3, "Numpad 3" }, { numpad4, "Numpad 4" },
  23. { numpad5, "Numpad 5" }, { numpad6, "Numpad 6" }, { numpad7, "Numpad 7" }, { numpad8, "Numpad 8" }, { numpad9, "Numpad 9" },
  24. };
  25. std::string lower (std::string s)
  26. {
  27. for (auto& c : s)
  28. c = (char) std::tolower ((unsigned char) c);
  29. return s;
  30. }
  31. std::string trim (const std::string& s)
  32. {
  33. const auto a = s.find_first_not_of (" \t\r\n");
  34. const auto b = s.find_last_not_of (" \t\r\n");
  35. return a == std::string::npos ? std::string() : s.substr (a, b - a + 1);
  36. }
  37. Chord chord (int key, std::uint8_t mods = none)
  38. {
  39. return { key, mods };
  40. }
  41. std::vector<Action> makeActions()
  42. {
  43. std::vector<Action> list {
  44. // transport and modes
  45. { "transport.playStop", TR_NOOP ("Play / stop (back to where playback started)"), Context::global, { chord (space) } },
  46. { "transport.pause", TR_NOOP ("Play / pause"), Context::global, { chord (space, ctrl) } },
  47. // FL 2026 (checked in FL, round 165s): Shift+Space stops and goes back to the start of the song / pattern, or
  48. // plays from there when stopped; the position clicked on a ruler is ignored (issue #11)
  49. { "transport.playFromStart", TR_NOOP ("Play, or stop at the start of the song or pattern"), Context::global, { chord (space, shift) } },
  50. // issue #195: FL's Home, "Move playback marker to start" (FL 2026 manual, Keyboard shortcuts › Playlist). Checked in
  51. // FL 2026 in round 190jz (shots fl-195-*): the Playlist and the Piano roll take Home, also while playing (the song
  52. // goes on from its start); with the Mixer or the Channel rack focused it does nothing. FL's ShortcutsModule has no
  53. // action for it: those two windows take the key themselves. The global action has no key of its own (bind one in
  54. // the shortcut editor; LYNX's W extra runs it).
  55. { "transport.toStart", TR_NOOP ("Move the playback marker to the start of the song or pattern"), Context::global, {} },
  56. { "transport.toggleMode", TR_NOOP ("Pattern / song mode"), Context::global, { chord ('L') }, true },
  57. { "transport.nextMarker", TR_NOOP ("Jump to the next song marker (Quantize song jumps while playing)"), Context::global, { chord (numpadMultiply, alt) } },
  58. { "transport.previousMarker", TR_NOOP ("Jump to the previous song marker"), Context::global, { chord (numpadDivide, alt) } },
  59. { "view.typingPiano", TR_NOOP ("Typing keyboard to piano on/off"), Context::global, { chord ('T', ctrl) } },
  60. // FL's Options › Switches › "Multilink to controllers" (OptionsToggleMultiLinkAction, Ctrl+J; round 177b-4)
  61. { "options.multilink", TR_NOOP ("Multilink to controllers on/off"), Context::global, { chord ('J', ctrl) } },
  62. { "view.toolbar", TR_NOOP ("Show or hide the toolbar panels"), Context::global, { chord (f11, ctrl) } },
  63. { "view.audioEditor", TR_NOOP ("Open the audio editor"), Context::global, {} },
  64. { "view.tempoTapper", TR_NOOP ("Tempo tapper (tap the tempo)"), Context::global, { chord (f5, ctrl) } },
  65. { "view.sampleBrowser", TR_NOOP ("Sample browser (separate window)"), Context::global, {} },
  66. // round 177d (an FL wishlist item): solo the selected channel from any window, no key by default (bind one in
  67. // the shortcut editor); again = every channel plays (FL's channel solo)
  68. { "channel.soloSelected", TR_NOOP ("Solo the selected channel (from any window)"), Context::global, {} },
  69. // round 190an (CROSS-DAW F13): FL's Add › Automation for last tweaked parameter as a key action. FL gives it
  70. // no key (DFM Add_AutoLastMenu has no ShortCut and ShortcutsModule has no action for it), so none by default
  71. { "automation.lastTweaked", TR_NOOP ("Create automation clip for the last tweaked control"), Context::global, {} },
  72. // workspace panels
  73. { "panel.playlist", TR_NOOP ("Show, focus or hide the Playlist"), Context::global, { chord (f5) } },
  74. { "panel.channelRack", TR_NOOP ("Show, focus or hide the Channel Rack"), Context::global, { chord (f6) } },
  75. { "panel.pianoRoll", TR_NOOP ("Show, focus or hide the Piano Roll"), Context::global, { chord (f7) } },
  76. { "panel.browser", TR_NOOP ("Show, focus or hide the Browser"), Context::global, { chord (f8, alt) } },
  77. // FL's F8 (ShowPluginPickerAction, round 167o): opens the plugin picker, or closes it when it is open
  78. { "panel.quickAdd", TR_NOOP ("Quick-add palette: instruments and effects (press again to close)"), Context::global, {} },
  79. // FL's F8 (ShowPluginPickerAction, ShortCut 119): the Plugin picker view, again = closed (round 169k; the
  80. // quick-add palette that F8 opened since round 167o stays on the toolbar's plug button)
  81. { "view.pluginPicker", TR_NOOP ("Plugin picker: every generator and effect, the categories as tabs (press again to close)"), Context::global, { chord (f8) } },
  82. // FL's Ctrl+F8 (View › Project picker; round 190my): the patterns and channels in the picker's form, again = closed
  83. { "view.projectPicker", TR_NOOP ("Project picker: the patterns and channels (press again to close)"), Context::global, { chord (f8, ctrl) } },
  84. { "panel.mixer", TR_NOOP ("Show, focus or hide the Mixer"), Context::global, { chord (f9) } },
  85. // FL 2026's other window keys (its shortcut list, REA round 165a)
  86. { "view.pluginDatabase", TR_NOOP ("Plugin database (in the Browser)"), Context::global, { chord (f8, shift) } },
  87. // F10 / F11 toggle like FL's (round 167o, settingsKeyPress): Settings on another page switches to this one
  88. { "view.midiSettings", TR_NOOP ("MIDI settings (press again to close)"), Context::global, { chord (f10) } },
  89. { "view.projectInfo", TR_NOOP ("Project info (press again to close)"), Context::global, { chord (f11) } },
  90. // Issue #181 (LYNX's own, beside FL's F10 / F11): Ctrl+, (Cmd+, on macOS), the settings key of most apps. It opens
  91. // Settings on the page shown last (General at first) and closes it when it is open.
  92. { "view.settings", TR_NOOP ("Settings (press again to close)"), Context::global, { chord (',', ctrl) } },
  93. { "view.closeWindows", TR_NOOP ("Close all windows (plugins, channel settings, tools)"), Context::global, { chord (f12) } },
  94. // Round 183a: the Clip-launch workflow's detail view, with the reference DAW's keys (its View menu, Live 12.4
  95. // [SHOT] detail183a/live/d05). They do nothing in Pattern workflow, where the keys keep their old meaning.
  96. { "view.detailToggle", TR_NOOP ("Clip-launch workflow: show or hide the detail view"), Context::global, { chord ('L', ctrl | alt) } },
  97. { "view.detailClip", TR_NOOP ("Clip-launch workflow: clip view"), Context::global, { chord ('3', ctrl | alt) } },
  98. { "view.detailDevices", TR_NOOP ("Clip-launch workflow: device view"), Context::global, { chord ('4', ctrl | alt) } },
  99. { "view.detailSwitch", TR_NOOP ("Clip-launch workflow: switch between clip view and device view"), Context::global, { chord (tab, shift) } },
  100. // Round 190jn (design190ia CL-23, DL-64): Live's ? key (Shift+/) shows or hides its Info View
  101. { "view.detailInfo", TR_NOOP ("Clip-launch workflow: show or hide the Info View"), Context::global, { chord ('/', shift) } },
  102. // Round 190ce: the reference DAW's hot-swap key (its lesson "Hot-Swapping Presets": Q links the Browser to the
  103. // selected device and Q again ends it; docs/analise/REA_rodada190ce.md §2). The typing keyboard keeps Q while on.
  104. { "view.hotSwap", TR_NOOP ("Hot-swap: link the Browser to the selected device, instrument or sample (again: end)"), Context::global, { chord ('Q') } },
  105. { "view.closePluginWindows", TR_NOOP ("Close all plugin windows"), Context::global, { chord (f12, alt) } },
  106. // FL's CloseAllUnfocusedWindowsAction (Ctrl+F12) and ShowTouchControllerAction (Alt+F7), round 167o
  107. { "view.closeUnfocusedWindows", TR_NOOP ("Close all windows except the focused one"), Context::global, { chord (f12, ctrl) } },
  108. // FL's AlignAllChannelEditorsAction, ShortCut 8315 = Shift+F12 (round 169k)
  109. { "view.alignChannelEditors", TR_NOOP ("Align all channel editors"), Context::global, { chord (f12, shift) } },
  110. { "view.touchKeyboard", TR_NOOP ("Show or hide the Touch keyboard"), Context::global, { chord (f7, alt) } },
  111. // round 190nw (0.1.31): LYNX's tracker editor (a view of the patterns' notes). No key by default: the proposed
  112. // Shift+F7 waits for a check of FL's own use of it (study190nd owner decision 6); bind one in the shortcut editor
  113. { "view.tracker", TR_NOOP ("Show or hide the Tracker (the pattern's notes as rows and channels)"), Context::global, {} },
  114. { "panel.maximisePlaylist", TR_NOOP ("Maximize or restore the Playlist"), Context::global, { chord (enter) } },
  115. // patterns
  116. { "pattern.next", TR_NOOP ("Next pattern"), Context::global, { chord (numpadPlus) } },
  117. { "pattern.previous", TR_NOOP ("Previous pattern"), Context::global, { chord (numpadMinus) } },
  118. { "pattern.nextEmpty", TR_NOOP ("Next empty pattern (and name it)"), Context::global, { chord (f4) } },
  119. { "pattern.firstEmpty", TR_NOOP ("First empty pattern (and name it)"), Context::global, { chord (f4, shift) } },
  120. { "pattern.nextEmptyNoName", TR_NOOP ("Next empty pattern (no naming)"), Context::global, { chord (f4, ctrl) } },
  121. { "pattern.rename", TR_NOOP ("Rename and color the pattern"), Context::global, { chord (f2) } },
  122. { "pattern.insert", TR_NOOP ("Insert an empty pattern before the current one"), Context::global, { chord (insert, ctrl | shift) } },
  123. { "pattern.clone", TR_NOOP ("Clone the current pattern"), Context::global, { chord ('C', ctrl | shift), chord ('C', alt) } },
  124. { "pattern.delete", TR_NOOP ("Delete the current pattern"), Context::global, { chord (del, ctrl | shift) } },
  125. { "pattern.moveUp", TR_NOOP ("Move the current pattern up"), Context::global, { chord (up, ctrl | shift) } },
  126. { "pattern.moveDown", TR_NOOP ("Move the current pattern down"), Context::global, { chord (down, ctrl | shift) } },
  127. // recording
  128. { "transport.record", TR_NOOP ("Recording on/off"), Context::global, { chord ('R') } },
  129. { "transport.metronome", TR_NOOP ("Metronome on/off"), Context::global, { chord ('M', ctrl) } },
  130. { "record.countIn", TR_NOOP ("Count-in before recording on/off"), Context::global, { chord ('P', ctrl) } },
  131. { "record.waitForInput", TR_NOOP ("Recording waits for the first note on/off"), Context::global, { chord ('I', ctrl) } },
  132. // round 170e3: FL's Options › Blend recorded notes (Ctrl+B), Loop record and Step edit (Ctrl+E) [DFM ShortcutsModule]
  133. { "record.blend", TR_NOOP ("Blend recorded notes on/off (off: replace)"), Context::global, { chord ('B', ctrl) } },
  134. { "record.loop", TR_NOOP ("Loop record on/off"), Context::global, {} },
  135. { "record.stepEdit", TR_NOOP ("Step edit on/off"), Context::global, { chord ('E', ctrl) } },
  136. { "record.punch", TR_NOOP ("Punch in/out on the loop region on/off"), Context::global, {} },
  137. { "record.quickAudio", TR_NOOP ("Record audio now: arm the selected insert and record (press again to stop)"), Context::global, { chord ('R', shift) } },
  138. { "record.captureMidi", TR_NOOP ("Capture MIDI: the notes just played without recording into the pattern"), Context::global, { chord ('R', ctrl | shift | alt) } },
  139. // files and history
  140. { "file.new", TR_NOOP ("New project"), Context::global, { chord ('N', ctrl) } },
  141. { "file.open", TR_NOOP ("Open project"), Context::global, { chord ('O', ctrl) } },
  142. { "file.save", TR_NOOP ("Save project"), Context::global, { chord ('S', ctrl) } },
  143. { "file.saveAs", TR_NOOP ("Save project as"), Context::global, { chord ('S', ctrl | shift) } },
  144. { "file.saveNewVersion", TR_NOOP ("Save new version (Song_2, Song_3...)"), Context::global, { chord ('S', ctrl | alt) } },
  145. // FL's File › Recent projects: Alt+1 … Alt+0 open the ten most recent (FL manual, File menu; round 190ih)
  146. { "file.recent1", TR_NOOP ("Open recent project 1"), Context::global, { chord ('1', alt) } },
  147. { "file.recent2", TR_NOOP ("Open recent project 2"), Context::global, { chord ('2', alt) } },
  148. { "file.recent3", TR_NOOP ("Open recent project 3"), Context::global, { chord ('3', alt) } },
  149. { "file.recent4", TR_NOOP ("Open recent project 4"), Context::global, { chord ('4', alt) } },
  150. { "file.recent5", TR_NOOP ("Open recent project 5"), Context::global, { chord ('5', alt) } },
  151. { "file.recent6", TR_NOOP ("Open recent project 6"), Context::global, { chord ('6', alt) } },
  152. { "file.recent7", TR_NOOP ("Open recent project 7"), Context::global, { chord ('7', alt) } },
  153. { "file.recent8", TR_NOOP ("Open recent project 8"), Context::global, { chord ('8', alt) } },
  154. { "file.recent9", TR_NOOP ("Open recent project 9"), Context::global, { chord ('9', alt) } },
  155. { "file.recent10", TR_NOOP ("Open recent project 10"), Context::global, { chord ('0', alt) } },
  156. { "file.export", TR_NOOP ("Export audio"), Context::global, { chord ('R', ctrl) } },
  157. { "file.exportMp3", TR_NOOP ("Export an MP3 file"), Context::global, { chord ('R', ctrl | shift) } },
  158. { "file.exportMidi", TR_NOOP ("Export a MIDI file"), Context::global, { chord ('M', ctrl | shift) } },
  159. // FL's File › Export › Master... (FileExportMasterAction, Ctrl+Alt+M; REA round 168e)
  160. { "file.exportMaster", TR_NOOP ("Export and master the project"), Context::global, { chord ('M', ctrl | alt) } },
  161. // FL's Tools › Consolidate playlist selection (EERenderPLSelectionLengthAction Ctrl+Alt+C, EEPLRenderSongLengthAction
  162. // Ctrl+Shift+Alt+C; REA round 168e)
  163. { "tools.consolidateSelection", TR_NOOP ("Consolidate playlist selection (from selection start)"), Context::global, { chord ('C', ctrl | alt) } },
  164. { "tools.consolidateSelectionSongStart", TR_NOOP ("Consolidate playlist selection (from song start)"), Context::global, { chord ('C', ctrl | shift | alt) } },
  165. { "edit.undo", TR_NOOP ("Undo"), Context::global, { chord ('Z', ctrl) } },
  166. // FL's Edit › "Undo backwards" (EditUndoBackwardsAction, Ctrl+Alt+Z; round 167k): one more step back
  167. { "edit.undoBackwards", TR_NOOP ("Undo backwards"), Context::global, { chord ('Z', ctrl | alt) } },
  168. { "edit.redo", TR_NOOP ("Redo"), Context::global, { chord ('Y', ctrl), chord ('Z', ctrl | shift) } },
  169. // FL's Tools › Macros › Stop sound (MacroStopSoundAction, Ctrl+H; round 170h2): the Undo history moved to
  170. // Ctrl+Alt+H, free in FL and in LYNX
  171. { "edit.history", TR_NOOP ("Undo history"), Context::global, { chord ('H', ctrl | alt) } },
  172. { "tools.stopSound", TR_NOOP ("Stop sound (all notes off)"), Context::global, { chord ('H', ctrl) } },
  173. { "help.shortcuts", TR_NOOP ("Shortcut sheet (press again to close)"), Context::global, { chord (f1) } },
  174. // #228 (round 190nq, LYNX extra): the action search. "?" opens it wherever the Clip-launch Info View (Live's "?")
  175. // doesn't use the key (MainComponent::keyPressed); no other key until the user gives it one
  176. { "help.searchActions", TR_NOOP ("Search every LYNX action and run it"), Context::global, {} },
  177. // round 190on (research190oe P2, owner decision O-2): the command palette — the same box with the menus, the LYNX
  178. // extras, the Settings pages and the recent projects. O-2's keys are all taken: Ctrl+Shift+P is FL's "Open in
  179. // project browser" (its Patterns menu; live check 190on), Ctrl+Shift+Space starts FL's playback (live check) and
  180. // is Live 12's "Move Insert Marker to Playhead Position", Ctrl+Alt+P Live's "Hide/Show Open Plug-In Windows". The
  181. // first free one: Ctrl+Shift+Y — in no list of Live 12's (its manual's chapter 42), nothing in FL 2026 with the
  182. // Playlist, Channel rack, Piano roll, Mixer or Browser focused (live check 190on), free in LYNX
  183. { "view.commandPalette", TR_NOOP ("Command palette: find and run any command, menu item, LYNX extra or setting"), Context::global, { chord ('Y', ctrl | shift) } },
  184. { "browser.search", TR_NOOP ("Search the Browser"), Context::global, { chord ('F', ctrl) } },
  185. // Channel Rack (focused)
  186. { "rack.selectPrevious", TR_NOOP ("Select the channel above"), Context::channelRack, { chord (up) } },
  187. { "rack.selectNext", TR_NOOP ("Select the channel below"), Context::channelRack, { chord (down) } },
  188. { "rack.extendUp", TR_NOOP ("Extend the selection up"), Context::channelRack, { chord (up, shift) } },
  189. { "rack.extendDown", TR_NOOP ("Extend the selection down"), Context::channelRack, { chord (down, shift) } },
  190. { "rack.moveUp", TR_NOOP ("Move the selected channels up"), Context::channelRack, { chord (up, alt) } },
  191. { "rack.moveDown", TR_NOOP ("Move the selected channels down"), Context::channelRack, { chord (down, alt) } },
  192. { "rack.selectAll", TR_NOOP ("Select all channels"), Context::channelRack, { chord ('A', ctrl) } },
  193. { "rack.clone", TR_NOOP ("Clone the selected channels"), Context::channelRack, { chord ('C', alt) } },
  194. { "rack.deleteSelected", TR_NOOP ("Delete the selected channels"), Context::channelRack, { chord (del, alt) } },
  195. // FL's Edit › Cut / Copy / Paste with the rack focused (REA round 170a §1): the selected channels' steps and notes
  196. { "rack.cut", TR_NOOP ("Cut the selected channels' steps"), Context::channelRack, { chord ('X', ctrl) } },
  197. { "rack.copy", TR_NOOP ("Copy the selected channels' steps"), Context::channelRack, { chord ('C', ctrl) } },
  198. { "rack.paste", TR_NOOP ("Paste steps into the selected channels"), Context::channelRack, { chord ('V', ctrl) } },
  199. { "rack.sendToInserts", TR_NOOP ("Send the selected channels to free mixer inserts"), Context::channelRack, { chord ('L', ctrl) } },
  200. { "rack.graphEditor", TR_NOOP ("Step graph lanes on/off"), Context::channelRack, { chord ('K', ctrl) } },
  201. { "rack.pianoRollView", TR_NOOP ("Piano-roll view of all channels on/off"), Context::channelRack, {} },
  202. { "rack.follow", TR_NOOP ("Follow the playhead (page along with the playing step) on/off"), Context::channelRack, {} },
  203. { "rack.groupSelected", TR_NOOP ("Put the selected channels in a new filter group"), Context::channelRack, { chord ('G', alt) } },
  204. // issue #201 (round 190ll): the channel menu's "Rename and color... F2" with the rack focused (a new colour goes to
  205. // every selected channel)
  206. { "rack.rename", TR_NOOP ("Rename and color the selected channel"), Context::channelRack, { chord (f2) } },
  207. // issue #220 (round 190ng): F3 opens the icon picker (FL has no key for it; in FL's name dialog the icon is F5)
  208. { "rack.changeIcon", TR_NOOP ("Change the selected channel's icon"), Context::channelRack, { chord (f3) } },
  209. { "rack.rotateLeft", TR_NOOP ("Rotate the selected channels' steps left"), Context::channelRack, { chord (left, ctrl | shift) } },
  210. { "rack.rotateRight", TR_NOOP ("Rotate the selected channels' steps right"), Context::channelRack, { chord (right, ctrl | shift) } },
  211. // FL's Channel rack (manual "Channel Rack › Filter"; round 190ld, DE-37): Page Up / Page Down = the previous / next
  212. // filter group, in the group menu's order
  213. { "rack.filterPrevious", TR_NOOP ("Previous filter group"), Context::channelRack, { chord (pageUp) } },
  214. { "rack.filterNext", TR_NOOP ("Next filter group"), Context::channelRack, { chord (pageDown) } },
  215. // FL 2026's Channel rack menu › Options › "Show mixer track selectors" (Alt+M) (round 190ld, DE-26)
  216. { "rack.mixerSelectors", TR_NOOP ("Show mixer track selectors"), Context::channelRack, { chord ('M', alt) } },
  217. // FL's Channel rack menu › Options › "Zip selected" (Alt+Z) / "Unzip all" (Alt+U) (round 190mk, DE-38)
  218. { "rack.zipSelected", TR_NOOP ("Zip selected"), Context::channelRack, { chord ('Z', alt) } },
  219. { "rack.unzipAll", TR_NOOP ("Unzip all"), Context::channelRack, { chord ('U', alt) } },
  220. { "rack.restretchAll", TR_NOOP ("Restretch all"), Context::channelRack, { chord ('R', ctrl | alt) } }, // (round 190mp, DE-38)
  221. // Piano Roll (focused): tool dialogs and zoom
  222. { "pianoRoll.toStart", TR_NOOP ("Move the playback marker to start"), Context::pianoRoll, { chord (home) } }, // (issue #195)
  223. { "pianoRoll.arpeggiate", TR_NOOP ("Arpeggiate..."), Context::pianoRoll, { chord ('A', alt) } },
  224. { "pianoRoll.strum", TR_NOOP ("Strum..."), Context::pianoRoll, { chord ('S', alt) } },
  225. { "pianoRoll.flip", TR_NOOP ("Flip..."), Context::pianoRoll, { chord ('Y', alt) } },
  226. { "pianoRoll.randomise", TR_NOOP ("Randomise..."), Context::pianoRoll, { chord ('R', alt) } },
  227. { "pianoRoll.scaleLevels", TR_NOOP ("Scale levels..."), Context::pianoRoll, { chord ('X', alt) } },
  228. { "pianoRoll.limit", TR_NOOP ("Limit to a range..."), Context::pianoRoll, { chord ('K', alt) } },
  229. // the other tools with FL's keys (REA round 143: the piano roll Tools menu)
  230. { "pianoRoll.quantize", TR_NOOP ("Quantize..."), Context::pianoRoll, { chord ('Q', alt) } },
  231. { "pianoRoll.chop", TR_NOOP ("Chop..."), Context::pianoRoll, { chord ('U', alt) } },
  232. // round 190hr: the reference's clip editor keys, acting only in the Clip-launch layout's docked editor (core/LiveGrid.h)
  233. { "pianoRoll.liveGridNarrower", TR_NOOP ("Clip-launch editor: narrow the grid"), Context::pianoRoll, { chord ('1', ctrl) } },
  234. { "pianoRoll.liveGridWider", TR_NOOP ("Clip-launch editor: widen the grid"), Context::pianoRoll, { chord ('2', ctrl) } },
  235. { "pianoRoll.liveGridTriplet", TR_NOOP ("Clip-launch editor: triplet grid"), Context::pianoRoll, { chord ('3', ctrl) } },
  236. { "pianoRoll.liveGridSnap", TR_NOOP ("Clip-launch editor: snap to grid"), Context::pianoRoll, { chord ('4', ctrl) } },
  237. { "pianoRoll.liveGridFixed", TR_NOOP ("Clip-launch editor: fixed or adaptive grid"), Context::pianoRoll, { chord ('5', ctrl) } },
  238. { "pianoRoll.liveQuantize", TR_NOOP ("Clip-launch editor: quantize"), Context::pianoRoll, { chord ('U', ctrl) } },
  239. { "pianoRoll.liveQuantizeSettings", TR_NOOP ("Clip-launch editor: quantize settings..."), Context::pianoRoll, { chord ('U', ctrl | shift) } },
  240. { "pianoRoll.flam", TR_NOOP ("Flam..."), Context::pianoRoll, { chord ('F', alt) } },
  241. { "pianoRoll.claw", TR_NOOP ("Claw machine..."), Context::pianoRoll, { chord ('W', alt) } },
  242. { "pianoRoll.lfo", TR_NOOP ("LFO..."), Context::pianoRoll, { chord ('O', alt) } },
  243. { "pianoRoll.articulate", TR_NOOP ("Articulate..."), Context::pianoRoll, { chord ('L', alt) } },
  244. { "pianoRoll.riffMachine", TR_NOOP ("Riff machine..."), Context::pianoRoll, { chord ('E', alt) } },
  245. { "pianoRoll.chordProgression", TR_NOOP ("Generate chord progression..."), Context::pianoRoll, { chord ('P', alt) } },
  246. // LYNX's Chord helper (round 190mc, discussion #105): no key of its own (FL has no such tool; the user may give it one)
  247. { "pianoRoll.chordHelper", TR_NOOP ("Chord helper..."), Context::pianoRoll, {} },
  248. // FL's "Run last script again" (Piano roll scripts, round 190as)
  249. { "pianoRoll.runLastScript", TR_NOOP ("Run last script again"), Context::pianoRoll, { chord ('Y', ctrl | alt) } },
  250. // note colours and the Select menu (REA round 153: FL's keys from its piano roll manual)
  251. { "pianoRoll.colourSelected", TR_NOOP ("Colour the selected notes with the note colour"), Context::pianoRoll, { chord ('C', alt) } },
  252. { "pianoRoll.selectByColour", TR_NOOP ("Select the notes of the same colour"), Context::pianoRoll, { chord ('C', shift) } },
  253. { "pianoRoll.invertSelection", TR_NOOP ("Invert the note selection"), Context::pianoRoll, { chord ('I', shift) } },
  254. { "pianoRoll.groupNotes", TR_NOOP ("Group the selected notes"), Context::pianoRoll, { chord ('G', shift) } },
  255. { "pianoRoll.ungroupNotes", TR_NOOP ("Ungroup the selected notes"), Context::pianoRoll, { chord ('G', alt) } },
  256. { "pianoRoll.zoomIn", TR_NOOP ("Zoom in"), Context::pianoRoll, { chord (pageUp) } },
  257. { "pianoRoll.zoomOut", TR_NOOP ("Zoom out"), Context::pianoRoll, { chord (pageDown) } },
  258. { "pianoRoll.zoom1", TR_NOOP ("Zoom: one bar"), Context::pianoRoll, { chord ('1', shift) }, true },
  259. { "pianoRoll.zoom2", TR_NOOP ("Zoom: four bars"), Context::pianoRoll, { chord ('2', shift) }, true },
  260. { "pianoRoll.zoom3", TR_NOOP ("Zoom: sixteen bars"), Context::pianoRoll, { chord ('3', shift) }, true },
  261. { "pianoRoll.zoomAll", TR_NOOP ("Zoom to show everything"), Context::pianoRoll, { chord ('4', shift) }, true },
  262. { "pianoRoll.zoomSelection", TR_NOOP ("Zoom to the selection"), Context::pianoRoll, { chord ('5', shift) }, true },
  263. { "pianoRoll.centrePlayhead", TR_NOOP ("Centre the view on the playhead"), Context::pianoRoll, { chord ('0', shift) }, true },
  264. // quick quantize (round 162, issue #9): FL's Ctrl+Q / Shift+Q, plus a 50% one to give a key of your own
  265. { "pianoRoll.quickQuantize", TR_NOOP ("Quick quantize (starts and lengths)"), Context::pianoRoll, { chord ('Q', ctrl) } },
  266. { "pianoRoll.quantizeStarts", TR_NOOP ("Quantize starts"), Context::pianoRoll, { chord ('Q', shift) }, true },
  267. { "pianoRoll.quantizeHalf", TR_NOOP ("Quantize starts 50% (halfway to the grid)"), Context::pianoRoll, {} },
  268. { "pianoRoll.follow", TR_NOOP ("Follow the playhead (auto scrolling) on/off"), Context::pianoRoll, {} },
  269. // FL's piano roll splitter (round 190fz, its hint "Right-click / shift+enter for alternate size"): the event
  270. // editor swaps with its alternate size (folded away by default) and back
  271. { "pianoRoll.eventPaneAlternate", TR_NOOP ("Event editor: alternate size"), Context::pianoRoll, { chord (enter, shift) } },
  272. // FL's Piano roll menu (round 168g, REA_rodada168g.md: the ShortcutsModule / EEMenu keys): View, Select, Stamp,
  273. // Edit and File items
  274. { "pianoRoll.gridHighlights", TR_NOOP ("Note grid highlights on/off"), Context::pianoRoll, { chord ('B', alt) } },
  275. { "pianoRoll.backgroundWave", TR_NOOP ("Background waveform on/off"), Context::pianoRoll, { chord ('N', alt) } },
  276. { "pianoRoll.showChordName", TR_NOOP ("Show chord name for selection on/off"), Context::pianoRoll, {} },
  277. { "pianoRoll.songBarsRuler", TR_NOOP ("Piano roll ruler: song bars on/off"), Context::pianoRoll, {} },
  278. { "pianoRoll.selectRandomOne", TR_NOOP ("Select one at random"), Context::pianoRoll, { chord ('R', shift) }, true },
  279. { "pianoRoll.selectRandomMore", TR_NOOP ("Select more at random"), Context::pianoRoll, { chord ('M', shift) }, true },
  280. { "pianoRoll.selectOddSteps", TR_NOOP ("Select odd (swung) notes"), Context::pianoRoll, { chord ('O', shift) }, true },
  281. { "pianoRoll.stampNone", TR_NOOP ("Stamp: none (single notes)"), Context::pianoRoll, { chord ('N', shift) }, true },
  282. { "pianoRoll.insertSpace", TR_NOOP ("Insert space (the time selection)"), Context::pianoRoll, { chord (insert, ctrl) } },
  283. { "pianoRoll.sliceInsertSpace", TR_NOOP ("Slice & insert space"), Context::pianoRoll, { chord (insert, ctrl | alt) } },
  284. { "pianoRoll.deleteSpace", TR_NOOP ("Delete space (the time selection)"), Context::pianoRoll, { chord (del, ctrl) } },
  285. { "pianoRoll.trimSpace", TR_NOOP ("Trim to the time selection"), Context::pianoRoll, {} },
  286. { "pianoRoll.deleteAll", TR_NOOP ("Delete all the channel's notes"), Context::pianoRoll, {} },
  287. { "pianoRoll.insertControllerValue", TR_NOOP ("Insert current controller value"), Context::pianoRoll, { chord ('I', ctrl) } },
  288. { "pianoRoll.importMidi", TR_NOOP ("Import MIDI file..."), Context::pianoRoll, { chord ('M', ctrl) } },
  289. { "pianoRoll.exportMidi", TR_NOOP ("Export as MIDI file..."), Context::pianoRoll, { chord ('M', ctrl | shift) } },
  290. { "pianoRoll.pasteMidiClipboard", TR_NOOP ("Paste from MIDI clipboard..."), Context::pianoRoll, { chord ('V', ctrl | shift) } },
  291. { "pianoRoll.copyMidiClipboard", TR_NOOP ("Copy to MIDI clipboard"), Context::pianoRoll, {} },
  292. { "pianoRoll.openScore", TR_NOOP ("Open score..."), Context::pianoRoll, {} },
  293. { "pianoRoll.saveScore", TR_NOOP ("Save score as..."), Context::pianoRoll, {} },
  294. { "pianoRoll.browseScores", TR_NOOP ("Browse scores"), Context::pianoRoll, {} },
  295. // FL's Piano roll › Time markers: the same EEMarker* items as the Playlist's, on the pattern's markers (round 168g)
  296. { "pianoRoll.markerAdd", TR_NOOP ("Pattern time markers: Add one..."), Context::pianoRoll, { chord ('T', alt) } },
  297. { "pianoRoll.markerAuto", TR_NOOP ("Pattern time markers: Add auto"), Context::pianoRoll, { chord ('T', ctrl) } },
  298. { "pianoRoll.markerSignature", TR_NOOP ("Pattern time markers: Add time signature change..."), Context::pianoRoll, { chord ('T', shift | alt) } },
  299. // the tools and the other single letters (FL's keys; issue #12: they were fixed in the editor and won over a
  300. // global shortcut given the same key)
  301. { "pianoRoll.tool.pencil", TR_NOOP ("Tool: Draw"), Context::pianoRoll, { chord ('P') } },
  302. { "pianoRoll.tool.brush", TR_NOOP ("Tool: Paint"), Context::pianoRoll, { chord ('B') } },
  303. { "pianoRoll.tool.drumPaint", TR_NOOP ("Tool: Paint drum sequencer"), Context::pianoRoll, { chord ('N') } },
  304. { "pianoRoll.tool.eraser", TR_NOOP ("Tool: Delete"), Context::pianoRoll, { chord ('D') } },
  305. { "pianoRoll.tool.mute", TR_NOOP ("Tool: Mute"), Context::pianoRoll, { chord ('T') } },
  306. { "pianoRoll.tool.knife", TR_NOOP ("Tool: Slice"), Context::pianoRoll, { chord ('C') } },
  307. { "pianoRoll.tool.lasso", TR_NOOP ("Tool: Select"), Context::pianoRoll, { chord ('E') } },
  308. { "pianoRoll.tool.zoom", TR_NOOP ("Tool: Zoom"), Context::pianoRoll, { chord ('Z') } },
  309. { "pianoRoll.tool.listen", TR_NOOP ("Tool: Playback"), Context::pianoRoll, { chord ('Y') } },
  310. { "pianoRoll.slide", TR_NOOP ("Slide notes on/off (new notes)"), Context::pianoRoll, { chord ('S') } },
  311. // round 190an (LYNX's own option; FL has none, so no key by default): the Piano roll's Snap to scale switch
  312. { "pianoRoll.scaleSnap", TR_NOOP ("Snap notes to the scale on/off"), Context::pianoRoll, {} },
  313. { "pianoRoll.previousChannel", TR_NOOP ("Previous channel"), Context::pianoRoll, { chord ('G') } },
  314. { "pianoRoll.nextChannel", TR_NOOP ("Next channel"), Context::pianoRoll, { chord ('K') } },
  315. { "pianoRoll.previousChannelWithNotes", TR_NOOP ("Previous channel with notes"), Context::pianoRoll, { chord ('H') } },
  316. { "pianoRoll.nextChannelWithNotes", TR_NOOP ("Next channel with notes"), Context::pianoRoll, { chord ('J') } },
  317. // Playlist (focused)
  318. { "playlist.zoomIn", TR_NOOP ("Zoom in"), Context::playlist, { chord (pageUp) } },
  319. { "playlist.zoomOut", TR_NOOP ("Zoom out"), Context::playlist, { chord (pageDown) } },
  320. { "playlist.zoom1", TR_NOOP ("Zoom: one bar"), Context::playlist, { chord ('1', shift) }, true },
  321. { "playlist.zoom2", TR_NOOP ("Zoom: four bars"), Context::playlist, { chord ('2', shift) }, true },
  322. { "playlist.zoom3", TR_NOOP ("Zoom: sixteen bars"), Context::playlist, { chord ('3', shift) }, true },
  323. { "playlist.zoomAll", TR_NOOP ("Zoom to show everything"), Context::playlist, { chord ('4', shift) }, true },
  324. { "playlist.zoomSelection", TR_NOOP ("Zoom to the selection"), Context::playlist, { chord ('5', shift) }, true },
  325. { "playlist.centrePlayhead", TR_NOOP ("Centre the view on the playhead"), Context::playlist, { chord ('0', shift) }, true },
  326. { "playlist.rippleDelete", TR_NOOP ("Delete the selected clips and close the gaps"), Context::playlist, { chord (del, shift) } },
  327. { "playlist.ripple", TR_NOOP ("Ripple editing on/off"), Context::playlist, { chord ('S', shift) } },
  328. // FL's Playlist › Edit › "Automatic crossfades (current project)" (round 166e)
  329. { "playlist.autoCrossfades", TR_NOOP ("Automatic crossfades (current project) on/off"), Context::playlist, {} },
  330. // LYNX extra (round 190gz, issue #170): Playlist tracks linked to mixer tracks
  331. { "playlist.linkTracks", TR_NOOP ("Link Playlist tracks to mixer tracks (current project) on/off"), Context::playlist, {} },
  332. // LYNX extra (round 190ht, issue #154): the linked headers list their mixer track's insert effects
  333. { "playlist.trackInserts", TR_NOOP ("Show insert effects on linked tracks on/off"), Context::playlist, {} },
  334. // FL's legacy Pattern Blocks (round 170f, issue #60)
  335. { "playlist.patternBlocks", TR_NOOP ("Pattern blocks (current project) on/off"), Context::playlist, {} },
  336. { "playlist.automationLanes", TR_NOOP ("Automation lanes on/off"), Context::playlist, {} },
  337. // LYNX extra (round 190iu, issue #186): the wheel scrolls over the track headers and zooms over the arrangement
  338. { "playlist.wheelZones", TR_NOOP ("Wheel: scroll over the track headers, zoom over the arrangement on/off"), Context::playlist, {} },
  339. { "editing.tempTools", TR_NOOP ("Hold a tool key for a temporary tool on/off"), Context::playlist, {} },
  340. // LYNX extras (round 190jq: issues #191, #191.3, #164)
  341. { "playlist.pointerClick", TR_NOOP ("Pointer click (a click on an empty spot selects and moves the song position) on/off"), Context::playlist, {} },
  342. { "playlist.clipLanes", TR_NOOP ("Automation clips as lanes under their tracks on/off"), Context::playlist, {} },
  343. { "playlist.headerWidth", TR_NOOP ("Drag the track header column's right edge to widen it on/off"), Context::playlist, {} },
  344. { "playlist.midiDrop", TR_NOOP ("MIDI files dropped on the Playlist become pattern clips on/off"), Context::playlist, {} },
  345. { "playlist.clipsToLanes", TR_NOOP ("Move automation clips into their tracks' lanes"), Context::playlist, {} },
  346. { "layout.trackOnly", TR_NOOP ("Track-only mode on/off"), Context::playlist, {} },
  347. // FL's Playlist menu › Picker panel › Enable (EEPatternsShowMenu; FL's shortcut page: Alt+P, issue #175)
  348. { "playlist.pickerPanel", TR_NOOP ("Picker panel on / off"), Context::playlist, { chord ('P', alt) } },
  349. { "playlist.blocksToClips", TR_NOOP ("Turn pattern blocks into clips"), Context::playlist, {} },
  350. // FL's Select › time (round 167k: EESelAroundSelAction, EESelPrevAction / EESelNextAction, Playlist focused)
  351. { "playlist.selectTimeAround", TR_NOOP ("Select time around selection"), Context::playlist, { chord (enter, ctrl) } },
  352. // comping (round 177c, Live's select + Enter; no key yet: Enter is FL's "Maximize or restore the Playlist")
  353. { "playlist.swipeSelectionToComp", TR_NOOP ("Send the time selection of the take lane to its comp"), Context::playlist, {} },
  354. { "playlist.timePrevious", TR_NOOP ("Select previous time"), Context::playlist, { chord (left, ctrl) } },
  355. { "playlist.timeNext", TR_NOOP ("Select next time"), Context::playlist, { chord (right, ctrl) } },
  356. // round 190on (research190oe P8, core/TransientNav.h): Pro Tools' Tab to transient, a LYNX extra. No default key in
  357. // any layout: Tab is FL's (Pattern), Shift+Tab Live's clip / device switch (Clip-launch), Alt+Left / Right the
  358. // Playlist's nudge (Simple's tracks are the Playlist's); the user picks keys in the Shortcut manager
  359. { "playlist.nextTransient", TR_NOOP ("Song position to the next transient of the selected audio clips"), Context::playlist, {} },
  360. { "playlist.prevTransient", TR_NOOP ("Song position to the previous transient of the selected audio clips"), Context::playlist, {} },
  361. { "playlist.extendToNextTransient", TR_NOOP ("Extend the time selection to the next transient"), Context::playlist, {} },
  362. { "playlist.extendToPrevTransient", TR_NOOP ("Extend the time selection to the previous transient"), Context::playlist, {} },
  363. { "audioEditor.nextTransient", TR_NOOP ("Audio editor / Clip View: cursor to the next transient"), Context::global, {} },
  364. { "audioEditor.prevTransient", TR_NOOP ("Audio editor / Clip View: cursor to the previous transient"), Context::global, {} },
  365. { "audioEditor.extendToNextTransient", TR_NOOP ("Audio editor / Clip View: extend the selection to the next transient"), Context::global, {} },
  366. { "audioEditor.extendToPrevTransient", TR_NOOP ("Audio editor / Clip View: extend the selection to the previous transient"), Context::global, {} },
  367. // FL 2026's Playlist › Time markers (round 167k: EEMarkerAdd2Menu 32852, EEMarkerAddAutoMenu 16468,
  368. // EEMarkerAddTSChangeMenu 41044, EEMarkerAddSongLoopMenu 8276); Ctrl+T stays the typing piano elsewhere
  369. { "playlist.markerAdd", TR_NOOP ("Time markers: Add one..."), Context::playlist, { chord ('T', alt) } },
  370. { "playlist.markerAuto", TR_NOOP ("Time markers: Add auto"), Context::playlist, { chord ('T', ctrl) } },
  371. { "playlist.markerSignature", TR_NOOP ("Time markers: Add time signature change..."), Context::playlist, { chord ('T', shift | alt) } },
  372. { "playlist.markerLoop", TR_NOOP ("Time markers: Place loop"), Context::playlist, { chord ('T', shift) } },
  373. // FL 2026's Playlist › Edit (round 167k: EEPitchSelectedAudioClipsDown/UpAction, EEReverseSelectedAudioClipsAction)
  374. { "playlist.pitchClipsDown", TR_NOOP ("Pitch selected audio clips one semitone down"), Context::playlist, { chord ('7') } },
  375. { "playlist.pitchClipsUp", TR_NOOP ("Pitch selected audio clips one semitone up"), Context::playlist, { chord ('8') } },
  376. { "playlist.reverseClips", TR_NOOP ("Reverse selected audio clips"), Context::playlist, { chord ('9') } },
  377. { "playlist.quantizeStarts", TR_NOOP ("Quantize the clips' starts"), Context::playlist, { chord ('Q', ctrl) } },
  378. { "playlist.quantizeHalf", TR_NOOP ("Quantize the clips' starts 50% (halfway to the grid)"), Context::playlist, {} },
  379. { "playlist.follow", TR_NOOP ("Follow the playhead (auto scrolling) on/off"), Context::playlist, {} },
  380. { "playlist.tool.pencil", TR_NOOP ("Tool: Draw"), Context::playlist, { chord ('P') } },
  381. { "playlist.tool.brush", TR_NOOP ("Tool: Paint"), Context::playlist, { chord ('B') } },
  382. { "playlist.tool.eraser", TR_NOOP ("Tool: Delete"), Context::playlist, { chord ('D') } },
  383. { "playlist.tool.mute", TR_NOOP ("Tool: Mute"), Context::playlist, { chord ('T') } },
  384. { "playlist.tool.knife", TR_NOOP ("Tool: Slice"), Context::playlist, { chord ('C') } },
  385. { "playlist.tool.lasso", TR_NOOP ("Tool: Select"), Context::playlist, { chord ('E') } },
  386. { "playlist.tool.zoom", TR_NOOP ("Tool: Zoom"), Context::playlist, { chord ('Z') } },
  387. { "playlist.tool.listen", TR_NOOP ("Tool: Playback"), Context::playlist, { chord ('Y') } },
  388. { "playlist.tool.slip", TR_NOOP ("Tool: Slip"), Context::playlist, { chord ('S') } },
  389. // issue #219 (round 190ng): FL's snap key (the main snap's hint "BkSp: Main snap", REA r168s f05), now in the key
  390. // map; "snap.toggle" is the same from any window, without a key until one is given (e.g. Alt+S)
  391. { "playlist.snapToggle", TR_NOOP ("Snap on/off (the main snap)"), Context::playlist, { chord (backspace) } },
  392. { "playlist.changeIcon", TR_NOOP ("Change the selected tracks' icon"), Context::playlist, { chord (f3) } },
  393. { "pianoRoll.snapToggle", TR_NOOP ("Snap on/off (the main snap)"), Context::pianoRoll, { chord (backspace) } },
  394. { "snap.toggle", TR_NOOP ("Snap on/off, from any window (the main snap)"), Context::global, {} },
  395. // FL's Performance mode (round 165m; Ctrl+P on FL's Playlist menu [DFM])
  396. { "playlist.performanceMode", TR_NOOP ("Performance mode on/off (launch the clips before the Start marker)"), Context::playlist, { chord ('P', ctrl) } },
  397. { "playlist.zoomPerformance", TR_NOOP ("Zoom on the performance clips"), Context::playlist, { chord ('6', shift) }, true },
  398. { "playlist.perfClipProgress", TR_NOOP ("Show the performance clips' progress"), Context::playlist, {} },
  399. { "playlist.perfTrackProgress", TR_NOOP ("Show the performance tracks' progress"), Context::playlist, {} },
  400. // round 168f: FL's Playlist keys and menu items ([DFM ShortcutsModule] EEMergeAction Ctrl+G, EEClonePLTracksAction
  401. // Ctrl+Shift+B, EEMakeUniqueAction Ctrl+Shift+V; the STRETCH button's hint "Shift+M")
  402. { "playlist.mergePatternClips", TR_NOOP ("Merge pattern clips"), Context::playlist, { chord ('G', ctrl) } },
  403. // round 180c: [DFM ShortcutsModule] EEMergeSimAction Ctrl+Shift+G, EEMergeAutoClipsAction Ctrl+Alt+G
  404. { "playlist.mergeSimilarClips", TR_NOOP ("Merge similar pattern clips"), Context::playlist, { chord ('G', ctrl | shift) } },
  405. { "playlist.mergeAutomationClips", TR_NOOP ("Merge automation clips"), Context::playlist, { chord ('G', ctrl | alt) } },
  406. { "playlist.cloneTracks", TR_NOOP ("Clone selected playlist track(s)"), Context::playlist, { chord ('B', ctrl | shift) } },
  407. { "playlist.makeUnique", TR_NOOP ("Make the selected clips unique"), Context::playlist, { chord ('V', ctrl | shift) } },
  408. // FL's Alt+M / Shift+Alt+M (EEMuteAction / EEUnmuteAction, issue #53): the selected clips, or all of them
  409. { "playlist.muteClips", TR_NOOP ("Mute the selected clips (all when none is selected)"), Context::playlist, { chord ('M', alt) } },
  410. { "playlist.unmuteClips", TR_NOOP ("Unmute the selected clips (all when none is selected)"), Context::playlist, { chord ('M', shift | alt) } },
  411. { "playlist.stretchMode", TR_NOOP ("Stretch audio when resizing audio clips on/off"), Context::playlist, { chord ('M', shift) } },
  412. { "playlist.createVariants", TR_NOOP ("Create variants when stretching audio clips on/off"), Context::playlist, {} },
  413. { "playlist.lockAllToContent", TR_NOOP ("Lock all playlist tracks to content"), Context::playlist, {} },
  414. { "playlist.unlockAllFromContent", TR_NOOP ("Unlock all playlist tracks from content"), Context::playlist, {} },
  415. { "playlist.resetEmptyTracks", TR_NOOP ("Reset empty playlist tracks"), Context::playlist, {} },
  416. { "playlist.collapseAllGroups", TR_NOOP ("Collapse all grouped tracks"), Context::playlist, {} },
  417. { "playlist.expandAllGroups", TR_NOOP ("Expand all grouped tracks"), Context::playlist, {} },
  418. { "playlist.purgeUnusedAudio", TR_NOOP ("Purge unused audio clips"), Context::playlist, {} },
  419. // round 189e: FL's Playlist Edit / Select items it lacked (EEMenu as the Playlist enables it, FL 2026 shots f04/f06)
  420. { "playlist.shiftLeft", TR_NOOP ("Shift the selected clips left (one snap step)"), Context::playlist, { chord (left, shift) } },
  421. { "playlist.shiftRight", TR_NOOP ("Shift the selected clips right (one snap step)"), Context::playlist, { chord (right, shift) } },
  422. { "playlist.shiftUp", TR_NOOP ("Shift the selected clips up (one track)"), Context::playlist, { chord (up, shift) } },
  423. { "playlist.shiftDown", TR_NOOP ("Shift the selected clips down (one track)"), Context::playlist, { chord (down, shift) } },
  424. // round 190ag (issue #147): FL's editor KeyDown (FUN_00e52360) sends Left / Right with Alt held, with or without
  425. // Shift, to the same shift as Shift+Left / Right (FUN_00e51730), which then steps by a pixel's worth of ticks
  426. { "playlist.nudgeLeft", TR_NOOP ("Nudge the selected clips left (fine step, no snap)"), Context::playlist, { chord (left, alt), chord (left, alt | shift) } },
  427. { "playlist.nudgeRight", TR_NOOP ("Nudge the selected clips right (fine step, no snap)"), Context::playlist, { chord (right, alt), chord (right, alt | shift) } },
  428. { "playlist.sliceInsertSpace", TR_NOOP ("Slice & insert space"), Context::playlist, { chord (insert, ctrl | alt) } },
  429. { "playlist.trimSpace", TR_NOOP ("Trim selection (keep only the time selection)"), Context::playlist, {} },
  430. // round 190cg: Live's arrangement commands on the time selection (no default keys: FL's stay as they are)
  431. { "playlist.loopSwitch", TR_NOOP ("Loop the time selection on/off (the range stays)"), Context::playlist, {} },
  432. { "playlist.loopHalve", TR_NOOP ("Halve the time selection"), Context::playlist, {} },
  433. { "playlist.loopDouble", TR_NOOP ("Double the time selection"), Context::playlist, {} },
  434. { "playlist.duplicateTime", TR_NOOP ("Duplicate time"), Context::playlist, {} },
  435. // round 190ne (core/TrackClips.h): Bitwig's "Duplicate as Alias" (Ctrl+Alt+D) on FL's Duplicate key
  436. { "playlist.duplicateLinked", TR_NOOP ("Duplicate the selected clips as linked copies (track clips share their notes)"), Context::playlist, { chord ('B', ctrl | alt) } },
  437. { "playlist.cutTime", TR_NOOP ("Cut time"), Context::playlist, {} },
  438. { "playlist.copyTime", TR_NOOP ("Copy time"), Context::playlist, {} },
  439. { "playlist.pasteTime", TR_NOOP ("Paste time"), Context::playlist, {} },
  440. { "playlist.cropClips", TR_NOOP ("Crop the selected clips to the time selection"), Context::playlist, {} },
  441. { "playlist.automationFollowsClips", TR_NOOP ("Automation follows clips on/off"), Context::playlist, {} },
  442. { "playlist.deselect", TR_NOOP ("Deselect (clips and time)"), Context::playlist, { chord ('D', ctrl) } },
  443. { "playlist.selectBySource", TR_NOOP ("Select by selected source"), Context::playlist, { chord ('C', shift) } },
  444. { "playlist.invertSelection", TR_NOOP ("Invert selection"), Context::playlist, { chord ('I', shift) } },
  445. // round 189g: FL's Edit / Select options ([DFM ShortcutsModule] EEMakeUniqueAsSampleAction, EELeftResizingAction
  446. // ShortCut 49188 = Ctrl+Alt+Home, EEShiftMouseWheelNudgeAction, EECreateNewClipsWithManualFadesAction,
  447. // EESnapFadeHandlesAction, EESelMagicAction)
  448. { "playlist.makeUniqueAsSample", TR_NOOP ("Make the selected audio clips unique as samples"), Context::playlist, {} },
  449. { "playlist.toStart", TR_NOOP ("Move the playback marker to start"), Context::playlist, { chord (home) } }, // (issue #195)
  450. { "playlist.leftResizing", TR_NOOP ("Allow resizing clips from the left on/off"), Context::playlist, { chord (home, ctrl | alt) } },
  451. { "playlist.wheelNudging", TR_NOOP ("Nudge clips with Shift+mouse wheel on/off"), Context::playlist, {} },
  452. { "playlist.manualFades", TR_NOOP ("Create new clips with manual fades on/off"), Context::playlist, {} },
  453. { "playlist.snapFadeHandles", TR_NOOP ("Snap fade handles on/off"), Context::playlist, {} },
  454. { "playlist.magicLasso", TR_NOOP ("Magic lasso (circle clips with the mouse to select them) on/off"), Context::playlist, {} },
  455. // Browser (focused)
  456. { "browser.previous", TR_NOOP ("Previous file (preview)"), Context::browser, { chord (up) } },
  457. { "browser.next", TR_NOOP ("Next file (preview)"), Context::browser, { chord (down) } },
  458. { "browser.swapPrevious", TR_NOOP ("Previous file into the selected channel"), Context::browser, { chord (up, shift) } },
  459. { "browser.swapNext", TR_NOOP ("Next file into the selected channel"), Context::browser, { chord (down, shift) } },
  460. { "browser.load", TR_NOOP ("Load the file into the selected channel"), Context::browser, { chord (enter) } },
  461. // round 190ld (DL-98): Live's Shift+Enter preview; it acts in the Clip-launch layout only
  462. { "browser.previewLive", TR_NOOP ("Preview the selected file (Clip-launch layout)"), Context::browser, { chord (enter, shift) } },
  463. { "browser.closeFolder", TR_NOOP ("Close the folder (or go to the parent folder)"), Context::browser, { chord (left) } },
  464. { "browser.openFolder", TR_NOOP ("Open the folder"), Context::browser, { chord (right) } },
  465. { "browser.rename", TR_NOOP ("Rename the selected plugin (Plugin database)"), Context::browser, { chord (f2) } },
  466. // round 190lr (DF-97): FL's "Use (F3) to skip to the next matching item" of a search (Shift+F3: the previous one)
  467. { "browser.findNext", TR_NOOP ("Next search match"), Context::browser, { chord (f3) } },
  468. { "browser.findPrevious", TR_NOOP ("Previous search match"), Context::browser, { chord (f3, shift) } },
  469. // round 190lr (DF-96 FL's navigation history; DL-102 Live's Ctrl+[ / Ctrl+])
  470. { "browser.historyBack", TR_NOOP ("Previous location"), Context::browser, { chord (backspace), chord ('[', ctrl) } },
  471. { "browser.historyForward", TR_NOOP ("Next location"), Context::browser, { chord (backspace, shift), chord (']', ctrl) } },
  472. // Round 190ce: the Browser's collections with the reference DAW's keys (1-7 put the selected item into a colour
  473. // collection or take it out, 0 takes it out of all; docs/analise/REA_rodada190ce.md §1). Plain keys: the typing
  474. // keyboard keeps them while it is on.
  475. { "browser.collection1", TR_NOOP ("Collection 1 (Starred): add or remove the selected item"), Context::browser, { chord ('1') } },
  476. { "browser.collection2", TR_NOOP ("Collection 2: add or remove the selected item"), Context::browser, { chord ('2') } },
  477. { "browser.collection3", TR_NOOP ("Collection 3: add or remove the selected item"), Context::browser, { chord ('3') } },
  478. { "browser.collection4", TR_NOOP ("Collection 4: add or remove the selected item"), Context::browser, { chord ('4') } },
  479. { "browser.collection5", TR_NOOP ("Collection 5: add or remove the selected item"), Context::browser, { chord ('5') } },
  480. { "browser.collection6", TR_NOOP ("Collection 6: add or remove the selected item"), Context::browser, { chord ('6') } },
  481. { "browser.collection7", TR_NOOP ("Collection 7: add or remove the selected item"), Context::browser, { chord ('7') } },
  482. { "browser.clearCollections", TR_NOOP ("Remove the selected item from every collection"), Context::browser, { chord ('0') } },
  483. // Mixer (focused)
  484. { "mixer.moveLeft", TR_NOOP ("Move the selected inserts left"), Context::mixer, { chord (left, alt) } },
  485. { "mixer.moveRight", TR_NOOP ("Move the selected inserts right"), Context::mixer, { chord (right, alt) } },
  486. // #225 (round 190nq): FL 2026 selects the previous / next mixer track with Left / Right, and with Ctrl or Shift held
  487. // too (checked in FL, [SHOT] 190nq mixkeys); Alt moves the tracks (above)
  488. { "mixer.selectPrevious", TR_NOOP ("Select the previous mixer track"), Context::mixer, { chord (left), chord (left, ctrl), chord (left, shift) } },
  489. { "mixer.selectNext", TR_NOOP ("Select the next mixer track"), Context::mixer, { chord (right), chord (right, ctrl), chord (right, shift) } },
  490. { "mixer.linkChannels", TR_NOOP ("Link the selected channels to the selected insert"), Context::mixer, { chord ('L', ctrl) } },
  491. { "mixer.linkChannelsFrom", TR_NOOP ("Link the selected channels to inserts starting from the selected one"), Context::mixer, { chord ('L', ctrl | shift) } },
  492. { "mixer.selectLinkedChannels", TR_NOOP ("Select the channels linked to the selected insert"), Context::mixer, { chord ('L', alt) } },
  493. { "mixer.waveforms", TR_NOOP ("Waveforms instead of the peak meters"), Context::mixer, { chord ('W', alt) } }, // round 190lr (DF-60)
  494. // FL's mixer track menu keys (round 167k, the DFM's ShortCut values: F2, S, Alt+R, Shift+Alt+R)
  495. { "mixer.rename", TR_NOOP ("Rename, color and icon of the selected mixer track"), Context::mixer, { chord (f2) } },
  496. { "mixer.changeIcon", TR_NOOP ("Change the selected mixer track's icon"), Context::mixer, { chord (f3) } },
  497. { "mixer.audioEditor", TR_NOOP ("Open the audio editor"), Context::mixer, { chord ('E', ctrl) } },
  498. { "mixer.audioEditorRecord", TR_NOOP ("Open the audio editor and record"), Context::mixer, { chord ('E', shift) } },
  499. { "mixer.soloSelected", TR_NOOP ("Solo the selected mixer track(s)"), Context::mixer, { chord ('S') } },
  500. { "mixer.altSoloSelected", TR_NOOP ("Alt solo the selected mixer track(s) (with the tracks that feed them)"), Context::mixer, { chord ('S', alt) } },
  501. { "mixer.renderArmed", TR_NOOP ("Disk recording: render the armed tracks to wave file(s)"), Context::mixer, { chord ('R', alt) } },
  502. { "mixer.renderSelected", TR_NOOP ("Disk recording: render the selected tracks to wave file(s)"), Context::mixer, { chord ('R', shift | alt) } },
  503. // FL 2026 (round 186c, checked by hand): Del deletes the selected mixer tracks (with FL's question); it never removes
  504. // an effect, except with the slot's menu open (issue #11, handled by that menu). The effect action stays, unbound.
  505. { "mixer.deleteTracks", TR_NOOP ("Delete the selected mixer tracks"), Context::mixer, { chord (del) } },
  506. { "mixer.deleteEffect", TR_NOOP ("Delete the selected effect slot's plugin"), Context::mixer, {} },
  507. };
  508. // numeric keypad 1-9: select patterns 1-9
  509. static const char* patternIds[] = { "pattern.select1", "pattern.select2", "pattern.select3", "pattern.select4", "pattern.select5",
  510. "pattern.select6", "pattern.select7", "pattern.select8", "pattern.select9" };
  511. for (int i = 0; i < 9; ++i)
  512. list.push_back ({ patternIds[i], TR_NOOP ("Select pattern {0}"), Context::global, { chord (numpad1 + i) } });
  513. // number keys: mute (plain) / solo (Ctrl) channels 1-10 while the rack has focus
  514. static const char* muteIds[] = { "rack.mute1", "rack.mute2", "rack.mute3", "rack.mute4", "rack.mute5",
  515. "rack.mute6", "rack.mute7", "rack.mute8", "rack.mute9", "rack.mute10" };
  516. static const char* soloIds[] = { "rack.solo1", "rack.solo2", "rack.solo3", "rack.solo4", "rack.solo5",
  517. "rack.solo6", "rack.solo7", "rack.solo8", "rack.solo9", "rack.solo10" };
  518. for (int i = 0; i < 10; ++i)
  519. {
  520. const auto digit = i == 9 ? '0' : (char) ('1' + i);
  521. list.push_back ({ muteIds[i], TR_NOOP ("Mute or unmute channel {0}"), Context::channelRack, { chord (digit) } });
  522. list.push_back ({ soloIds[i], TR_NOOP ("Solo channel {0}"), Context::channelRack, { chord (digit, ctrl) } });
  523. }
  524. return list;
  525. }
  526. bool contextsOverlap (Context a, Context b)
  527. {
  528. return a == b;
  529. }
  530. // --- tiny JSON reader for {"id": "chord" | ["chord", ...], ...} ---------------------------------
  531. struct Json
  532. {
  533. const std::string& s;
  534. std::size_t i = 0;
  535. void skip()
  536. {
  537. while (i < s.size() && std::isspace ((unsigned char) s[i]))
  538. ++i;
  539. }
  540. bool eat (char c)
  541. {
  542. skip();
  543. if (i < s.size() && s[i] == c)
  544. {
  545. ++i;
  546. return true;
  547. }
  548. return false;
  549. }
  550. std::optional<std::string> string()
  551. {
  552. skip();
  553. if (i >= s.size() || s[i] != '"')
  554. return std::nullopt;
  555. std::string out;
  556. for (++i; i < s.size(); ++i)
  557. {
  558. const auto c = s[i];
  559. if (c == '"')
  560. {
  561. ++i;
  562. return out;
  563. }
  564. if (c == '\\' && i + 1 < s.size())
  565. {
  566. const auto n = s[++i];
  567. out += n == 'n' ? '\n' : n == 't' ? '\t' : n;
  568. }
  569. else
  570. out += c;
  571. }
  572. return std::nullopt;
  573. }
  574. };
  575. } // namespace
  576. bool Chord::isPrintable() const noexcept
  577. {
  578. return key > ' ' && key < 0x7f;
  579. }
  580. std::string displayString (const Chord& c)
  581. {
  582. return modmap::keyNames (toString (c), modmap::hostOs());
  583. }
  584. std::string toString (const Chord& c)
  585. {
  586. std::string out;
  587. if (c.mods & ctrl)
  588. out += "Ctrl+";
  589. if (c.mods & shift)
  590. out += "Shift+";
  591. if (c.mods & alt)
  592. out += "Alt+";
  593. if (c.key >= f1 && c.key <= f12)
  594. return out + "F" + std::to_string (c.key - f1 + 1);
  595. for (const auto& k : keyNames)
  596. if (k.key == c.key)
  597. return out + k.name;
  598. if (c.isPrintable())
  599. return out + std::string (1, (char) c.key);
  600. return out + "?";
  601. }
  602. std::optional<Chord> parseChord (const std::string& text)
  603. {
  604. auto rest = trim (text);
  605. Chord c;
  606. // modifiers first ("+" alone, or "Numpad +", is a key, so only split on "+" followed by more text)
  607. for (;;)
  608. {
  609. const auto l = lower (rest);
  610. auto take = [&] (const char* prefix, std::uint8_t mod) {
  611. const std::string p (prefix);
  612. if (l.size() > p.size() && l.compare (0, p.size(), p) == 0)
  613. {
  614. c.mods |= mod;
  615. rest = trim (rest.substr (p.size()));
  616. return true;
  617. }
  618. return false;
  619. };
  620. if (! (take ("ctrl+", ctrl) || take ("shift+", shift) || take ("alt+", alt)))
  621. break;
  622. }
  623. const auto name = lower (rest);
  624. if (name.empty())
  625. return std::nullopt;
  626. if (name.size() >= 2 && name[0] == 'f' && std::all_of (name.begin() + 1, name.end(), [] (char ch) { return std::isdigit ((unsigned char) ch); }))
  627. {
  628. const auto n = std::stoi (name.substr (1));
  629. if (n < 1 || n > 12)
  630. return std::nullopt;
  631. c.key = f1 + n - 1;
  632. return c;
  633. }
  634. for (const auto& k : keyNames)
  635. if (lower (k.name) == name)
  636. {
  637. c.key = k.key;
  638. return c;
  639. }
  640. if (name == "del")
  641. c.key = del;
  642. else if (name == "ins")
  643. c.key = insert;
  644. else if (name == "escape")
  645. c.key = escape;
  646. else if (name == "return")
  647. c.key = enter;
  648. else if (rest.size() == 1 && rest[0] > ' ' && rest[0] < 0x7f)
  649. c.key = std::toupper ((unsigned char) rest[0]);
  650. else
  651. return std::nullopt;
  652. return c;
  653. }
  654. const std::vector<Action>& actions()
  655. {
  656. static const auto list = makeActions();
  657. return list;
  658. }
  659. const Action* findAction (const std::string& id)
  660. {
  661. for (const auto& a : actions())
  662. if (id == a.id)
  663. return &a;
  664. return nullptr;
  665. }
  666. int typingPianoNote (int key, int octave, int root) noexcept
  667. {
  668. const auto base = 12 * typingpiano::clampOctave (octave) + typingpiano::clampRoot (root); // octave 4 -> 48
  669. const auto inRange = [] (int n) { return n >= 0 && n <= 127 ? n : -1; };
  670. static const char lowerRow[] = "ZSXDCVGBHNJM";
  671. static const char upperRow[] = "Q2W3ER5T6Y7UI9O0P";
  672. const auto c = key >= 'a' && key <= 'z' ? key - 'a' + 'A' : key;
  673. for (int i = 0; lowerRow[i] != 0; ++i)
  674. if (lowerRow[i] == c)
  675. return inRange (base + i);
  676. for (int i = 0; upperRow[i] != 0; ++i)
  677. if (upperRow[i] == c)
  678. return inRange (base + 12 + i);
  679. return -1;
  680. }
  681. namespace
  682. {
  683. struct TypingLayout
  684. {
  685. const char* name;
  686. const char* keys; // one token per layoutKeys character: notes at octave 4, root C ("60,64,67" a chord), "-" LOCK, "~" FREE
  687. };
  688. // The printable keys of FL's .scr files, in their line order (FL reads a file's lines as the scan codes 2..0x35 of a US
  689. // keyboard: number row, Q row, A row with ` , \ then the Z row; the Backspace, Tab, Enter, Ctrl / Caps and Shift lines
  690. // are FREE in every file, so they are left out). LYNX matches the keys by character.
  691. constexpr char layoutKeys[] = "1234567890-=QWERTYUIOP[]ASDFGHJKL;'`\\ZXCVBNM,./";
  692. // FL 2026's System/Config/Typing to piano/*.scr, written as data (note names converted with C5 = 60), in the order of
  693. // FL's Layout menu (by name). FL's parser (FUN_00661f70) reads FREE as -2: the key sends no note and stays a shortcut;
  694. // LOCK as -1: no note and no shortcut. A key missing from a file is FREE (FUN_01182670 fills the table with -2 first).
  695. const TypingLayout typingLayouts[] = {
  696. { "Layout FPC (C4)", "49 55 51 53 88 89 90 91 - - - - 48 47 45 43 84 85 86 87 - - - - 40 38 46 44 80 81 82 83 - - - ~ ~ 37 36 42 54 76 77 78 79 - -" },
  697. { "Layout Janko", "57 59 61 63 65 67 69 71 73 75 77 79 58 60 62 64 66 68 70 72 74 76 78 80 59 61 63 65 67 69 71 73 75 77 79 ~ ~ 60 62 64 66 68 70 72 74 76 78" },
  698. { "Layout Performance mode", "0 1 2 3 4 48 49 50 51 52 - - 12 13 14 15 16 60 61 62 63 64 - - 24 25 26 27 28 72 73 74 75 76 - ~ ~ 36 37 38 39 40 84 85 86 87 88" },
  699. { "Layout Piano", "- 61 63 - 66 68 70 - 73 75 - 78 60 62 64 65 67 69 71 72 74 76 77 79 ~ 49 51 - 54 56 58 - 61 63 - ~ ~ 48 50 52 53 55 57 59 60 62 64" },
  700. { "Layout Slicex (C4)", "84 85 86 87 88 89 90 91 - - - - 76 77 78 79 80 81 82 83 - - - - 68 69 70 71 72 73 74 75 - - - ~ ~ 60 61 62 63 64 65 66 67 - -" },
  701. { "Major", "84 86 88 89 91 93 95 96 98 100 101 103 72 74 76 77 79 81 83 84 86 88 89 91 60 62 64 65 67 69 71 72 74 76 77 ~ ~ 48 50 52 53 55 57 59 60 62 64" },
  702. { "Major + Chords", "60,64,67 62,65,69 64,67,71 65,69,72 67,71,74 69,72,76 71,74,77 72,76,79 74,77,81 76,79,83 77,81,84 79,83,86 72 74 76 77 79 81 83 84 86 88 89 91 60 62 64 65 67 69 71 72 74 76 77 ~ ~ 48 50 52 53 55 57 59 60 62 64" },
  703. { "Major Bebop", "84 86 88 89 91 92 93 95 96 98 100 101 72 74 76 77 79 80 81 83 84 86 88 89 60 62 64 65 67 68 69 71 72 74 76 ~ ~ 48 50 52 53 55 56 57 59 60 62" },
  704. { "Major Chordmap", "64,67,72 65,69,74 64,67,71 65,69,72 62,67,71 64,69,72 62,65,71 64,67,72 65,69,74 64,67,71 65,69,72 62,67,71 60,64,67 62,65,69 59,64,67 60,65,69 59,62,67 60,64,69 59,62,65 60,64,67 62,65,69 59,64,67 60,65,69 59,62,67 55,60,64 57,62,65 55,59,64 57,60,65 55,59,62 57,60,64 53,59,62 55,60,64 57,62,65 55,59,64 57,60,65 ~ ~ 36 38 40 41 43 45 47 48 50 52" },
  705. { "Major Pentatonic", "84 86 88 91 93 96 98 100 103 105 108 110 72 74 76 79 81 84 86 88 91 93 96 98 60 62 64 67 69 72 74 76 79 81 84 ~ ~ 48 50 52 55 57 60 62 64 67 69" },
  706. { "Minor Harmonic", "84 86 87 89 91 92 95 96 98 99 101 103 72 74 75 77 79 80 83 84 86 87 89 91 60 62 63 65 67 68 71 72 74 75 77 ~ ~ 48 50 51 53 55 56 59 60 62 63" },
  707. { "Minor Hungarian", "84 86 87 90 91 92 95 96 98 99 102 103 72 74 75 78 79 80 83 84 86 87 90 91 60 62 63 66 67 68 71 72 74 75 78 ~ ~ 48 50 51 54 55 56 59 60 62 63" },
  708. { "Minor Melodic", "84 86 87 89 91 93 95 96 98 99 101 103 72 74 75 77 79 81 83 84 86 87 89 91 60 62 63 65 67 69 71 72 74 75 77 ~ ~ 48 50 51 53 55 57 59 60 62 63" },
  709. { "Minor Natural (Aeolian)", "84 86 87 89 91 92 94 96 98 99 101 103 72 74 75 77 79 80 82 84 86 87 89 91 60 62 63 65 67 68 70 72 74 75 77 ~ ~ 48 50 51 53 55 56 58 60 62 63" },
  710. { "Minor Natural + Chords", "60,63,67 62,65,68 63,67,70 65,68,72 67,70,74 68,72,75 70,74,77 72,75,79 74,77,80 75,79,82 77,80,84 79,82,86 72 74 75 77 79 80 82 84 86 87 89 91 60 62 63 65 67 68 70 72 74 75 77 ~ ~ 48 50 51 53 55 56 58 60 62 63" },
  711. { "Minor Natural Chordmap", "63,67,72 65,68,74 63,67,70 65,68,72 62,67,70 63,68,72 62,65,70 63,67,72 65,68,74 63,67,70 65,68,72 62,67,70 60,63,67 62,65,68 58,63,67 60,65,68 58,62,67 60,63,68 58,62,65 60,63,67 62,65,68 58,63,67 60,65,68 58,62,67 55,60,63 56,62,65 55,58,63 56,60,65 55,58,62 56,60,63 53,58,62 55,60,63 56,62,65 55,58,63 56,60,65 ~ ~ 36 38 39 41 43 44 46 48 50 51" },
  712. { "Minor Neopolitan", "84 85 87 89 91 92 95 96 97 99 101 103 72 73 75 77 79 80 83 84 85 87 89 91 60 61 63 65 67 68 71 72 73 75 77 ~ ~ 48 49 51 53 55 56 59 60 61 63" },
  713. { "Minor Pentatonic", "84 87 89 91 94 96 99 101 103 106 108 111 72 75 77 79 82 84 87 89 91 94 96 99 60 63 65 67 70 72 75 77 79 82 84 ~ ~ 48 51 53 55 58 60 63 65 67 70" },
  714. { "Other Arabic", "84 85 88 89 91 92 95 96 97 100 101 103 72 73 76 77 79 80 83 84 85 88 89 91 60 61 64 65 67 68 71 72 73 76 77 ~ ~ 48 49 52 53 55 56 59 60 61 64" },
  715. { "Other Blues", "84 87 89 90 91 94 96 99 101 102 103 106 72 75 77 78 79 82 84 87 89 90 91 94 60 63 65 66 67 70 72 75 77 78 79 ~ ~ 48 51 53 54 55 58 60 63 65 66" },
  716. { "Other Diminished", "84 86 87 89 90 92 93 95 96 98 99 101 72 74 75 77 78 80 81 83 84 86 87 89 60 62 63 65 66 68 69 71 72 74 75 ~ ~ 48 50 51 53 54 56 57 59 60 62" },
  717. { "Other Dominant Bebop", "84 86 88 89 91 93 94 95 96 98 100 101 72 74 76 77 79 81 82 83 84 86 88 89 60 62 64 65 67 69 70 71 72 74 76 ~ ~ 48 50 52 53 55 57 58 59 60 62" },
  718. { "Other Dorian", "84 86 87 89 91 93 94 96 98 99 101 103 72 74 75 77 79 81 82 84 86 87 89 91 60 62 63 65 67 69 70 72 74 75 77 ~ ~ 48 50 51 53 55 57 58 60 62 63" },
  719. { "Other Enigmatic", "84 85 88 90 92 94 95 97 98 101 103 105 72 73 76 78 80 82 83 85 86 89 91 93 60 61 64 66 68 70 71 73 74 77 79 ~ ~ 48 49 52 54 56 58 59 61 62 65" },
  720. { "Other Japanese Insen", "84 85 89 91 94 96 97 101 103 106 108 109 72 73 77 79 82 84 85 89 91 94 96 97 60 61 65 67 70 72 73 77 79 82 84 ~ ~ 48 49 53 55 58 60 61 65 67 70" },
  721. { "Other Locrian", "84 85 87 89 90 92 94 96 97 99 101 102 72 73 75 77 78 80 82 84 85 87 89 90 60 61 63 65 66 68 70 72 73 75 77 ~ ~ 48 49 51 53 54 56 58 60 61 63" },
  722. { "Other Lydian", "84 86 88 90 91 93 95 96 98 100 102 103 72 74 76 78 79 81 83 84 86 88 90 91 60 62 64 66 67 69 71 72 74 76 78 ~ ~ 48 50 52 54 55 57 59 60 62 64" },
  723. { "Other Mixolydian", "84 86 88 89 91 93 94 96 98 100 101 103 72 74 76 77 79 81 82 84 86 88 89 91 60 62 64 65 67 69 70 72 74 76 77 ~ ~ 48 50 52 53 55 57 58 60 62 64" },
  724. { "Other Neopolitan", "84 85 87 89 91 93 95 96 97 99 101 103 72 73 75 77 79 81 83 84 85 87 89 91 60 61 63 65 67 69 71 72 73 75 77 ~ ~ 48 49 51 53 55 57 59 60 61 63" },
  725. { "Other Phrygian", "84 85 87 89 91 92 94 96 97 99 101 103 72 73 75 77 79 80 82 84 85 87 89 91 60 61 63 65 67 68 70 72 73 75 77 ~ ~ 48 49 51 53 55 56 58 60 61 63" },
  726. { "Other Whole Tone", "84 86 88 90 92 94 96 98 100 102 104 106 72 74 76 78 80 82 84 86 88 90 92 94 60 62 64 66 68 70 72 74 76 78 80 ~ ~ 48 50 52 54 56 58 60 62 64 66" },
  727. };
  728. // The token of `key` in `layout` (pointing into its string), nullptr when the key is not one of layoutKeys.
  729. const char* layoutToken (int key, int layout) noexcept
  730. {
  731. const auto c = key >= 'a' && key <= 'z' ? key - 'a' + 'A' : key;
  732. const auto* found = c > 0 && c < 0x7f ? std::strchr (layoutKeys, c) : nullptr;
  733. if (found == nullptr || layout < 0 || layout >= (int) std::size (typingLayouts))
  734. return nullptr;
  735. const auto* token = typingLayouts[layout].keys;
  736. for (auto i = found - layoutKeys; i > 0 && token != nullptr; --i) // skip one space-separated token per key before it
  737. if ((token = std::strchr (token, ' ')) != nullptr)
  738. ++token;
  739. return token;
  740. }
  741. } // namespace
  742. int typingpiano::layoutCount() noexcept
  743. {
  744. return (int) std::size (typingLayouts);
  745. }
  746. const char* typingpiano::layoutName (int layout) noexcept
  747. {
  748. return layout >= 0 && layout < layoutCount() ? typingLayouts[layout].name : "";
  749. }
  750. int typingpiano::layoutIndex (const std::string& name) noexcept
  751. {
  752. for (int i = 0; i < layoutCount(); ++i)
  753. if (name == typingLayouts[i].name)
  754. return i;
  755. return pianoLayout();
  756. }
  757. int typingpiano::pianoLayout() noexcept
  758. {
  759. for (int i = 0; i < layoutCount(); ++i)
  760. if (std::strcmp (typingLayouts[i].name, "Layout Piano") == 0)
  761. return i;
  762. return 0;
  763. }
  764. int typingpiano::performanceLayout() noexcept
  765. {
  766. for (int i = 0; i < layoutCount(); ++i)
  767. if (std::strcmp (typingLayouts[i].name, "Layout Performance mode") == 0)
  768. return i;
  769. return -1;
  770. }
  771. TypingKey typingPianoKey (int key, int octave, int root, int layout)
  772. {
  773. TypingKey out;
  774. const auto* token = layoutToken (key, layout);
  775. if (token == nullptr || *token == '~') // FREE (or not in the layout): the key stays a shortcut
  776. return out;
  777. out.taken = true; // (FL's key handler FUN_011828c0 reports any token but FREE as handled, even with no note)
  778. // FL's note: the table's + root + 12 x the octave offset (KbC2..KbC6 = -2..2), for every layout (FUN_011828c0)
  779. const auto shift = 12 * (typingpiano::clampOctave (octave) - typingpiano::defaultOctave) + typingpiano::clampRoot (root);
  780. for (char* end = nullptr; *token >= '0' && *token <= '9'; token = *end == ',' ? end + 1 : end)
  781. if (const auto n = (int) std::strtol (token, &end, 10) + shift; n >= 0 && n <= 127)
  782. out.notes.push_back (n);
  783. return out;
  784. }
  785. std::vector<int> typingPianoNotes (int key, int octave, int root, int layout)
  786. {
  787. return typingPianoKey (key, octave, root, layout).notes;
  788. }
  789. namespace
  790. {
  791. // layoutKeys by PC scan code (set 1): 0x02..0x0D the number row, 0x10..0x1B the Q row, 0x1E..0x28 the A row, 0x29 `,
  792. // 0x2B \, 0x2C..0x35 the Z row (the gaps are Backspace / Tab, Enter / Ctrl and the left Shift)
  793. constexpr int firstTypingScanCode = 0x02, lastTypingScanCode = 0x35;
  794. constexpr char usKeyByScanCode[] = "1234567890-=\0\0QWERTYUIOP[]\0\0ASDFGHJKL;'`\0\\ZXCVBNM,./";
  795. static_assert (sizeof (usKeyByScanCode) - 1 == lastTypingScanCode - firstTypingScanCode + 1);
  796. } // namespace
  797. int typingpiano::usKeyOfScanCode (int scanCode) noexcept
  798. {
  799. return scanCode >= firstTypingScanCode && scanCode <= lastTypingScanCode ? (int) (unsigned char) usKeyByScanCode[scanCode - firstTypingScanCode] : 0;
  800. }
  801. int typingpiano::scanCodeOfUsKey (int key) noexcept
  802. {
  803. const auto c = key >= 'a' && key <= 'z' ? key - 'a' + 'A' : key;
  804. for (int scan = firstTypingScanCode; scan <= lastTypingScanCode; ++scan)
  805. if (c > 0 && usKeyOfScanCode (scan) == c)
  806. return scan;
  807. return 0;
  808. }
  809. int typingpiano::physicalKey (int keyCode, const ScanCodeLookup& scanCodeOf)
  810. {
  811. const auto scanCode = scanCodeOf != nullptr ? scanCodeOf (keyCode) : 0;
  812. return scanCode > 0 ? usKeyOfScanCode (scanCode) : keyCode;
  813. }
  814. KeyMap::KeyMap()
  815. {
  816. resetToDefaults();
  817. }
  818. void KeyMap::resetToDefaults()
  819. {
  820. chords.clear();
  821. for (const auto& a : actions())
  822. chords.push_back (a.defaults);
  823. }
  824. bool KeyMap::playsNote (const Chord& c, bool typingPiano) noexcept
  825. {
  826. return typingPiano && (c.mods & (ctrl | alt | shift)) == 0 && typingPianoNote (c.key) >= 0;
  827. }
  828. std::string KeyMap::findFromSecondaryWindow (const Chord& c, bool typingIntoText, bool typingPiano) const
  829. {
  830. if (! c.isValid() || c.key == escape) // (Esc closes the window)
  831. return {};
  832. const auto editingKey = c.isPrintable() || c.key == space || c.key == enter || c.key == tab || c.key == backspace || c.key == del
  833. || c.key == insert || (c.key >= up && c.key <= end);
  834. if (typingIntoText && editingKey && (c.mods & (ctrl | alt)) == 0)
  835. return {};
  836. if (auto own = findUserBound (c, Context::global, typingPiano); ! own.empty())
  837. return own;
  838. return find (c, Context::global, typingPiano);
  839. }
  840. std::string KeyMap::findUserBound (const Chord& c, Context focus, bool typingPiano) const
  841. {
  842. if (! c.isValid() || playsNote (c, typingPiano))
  843. return {};
  844. const auto plainPrintable = c.isPrintable() && (c.mods & (ctrl | alt)) == 0;
  845. const auto& list = actions();
  846. const Action* globalMatch = nullptr;
  847. for (std::size_t i = 0; i < list.size(); ++i)
  848. {
  849. const auto& a = list[i];
  850. if ((a.context != Context::global && a.context != focus) || chords[i] == a.defaults)
  851. continue;
  852. if (std::find (chords[i].begin(), chords[i].end(), c) == chords[i].end()
  853. || std::find (a.defaults.begin(), a.defaults.end(), c) != a.defaults.end())
  854. continue; // (a default key keeps its usual priority)
  855. if (typingPiano && plainPrintable && ! a.whilePiano)
  856. continue;
  857. if (a.context == focus && focus != Context::global)
  858. return a.id;
  859. if (globalMatch == nullptr)
  860. globalMatch = &a;
  861. }
  862. return globalMatch != nullptr ? globalMatch->id : std::string();
  863. }
  864. std::vector<std::string> KeyMap::shadowedBy (const Chord& c, const std::string& actionId) const
  865. {
  866. std::vector<std::string> out;
  867. const auto* owner = findAction (actionId);
  868. if (owner == nullptr || ! c.isValid())
  869. return out;
  870. const auto& list = actions();
  871. for (std::size_t i = 0; i < list.size(); ++i)
  872. {
  873. const auto& a = list[i];
  874. if (actionId == a.id || a.context == owner->context)
  875. continue;
  876. if (owner->context != Context::global && a.context != Context::global)
  877. continue; // two different panels never meet
  878. if (std::find (chords[i].begin(), chords[i].end(), c) != chords[i].end())
  879. out.push_back (a.id);
  880. }
  881. return out;
  882. }
  883. std::string KeyMap::find (const Chord& c, Context focus, bool typingPiano) const
  884. {
  885. if (! c.isValid() || playsNote (c, typingPiano))
  886. return {};
  887. const auto plainPrintable = c.isPrintable() && (c.mods & (ctrl | alt)) == 0;
  888. const auto& list = actions();
  889. const Action* globalMatch = nullptr;
  890. for (std::size_t i = 0; i < list.size(); ++i)
  891. {
  892. const auto& a = list[i];
  893. if (a.context != Context::global && a.context != focus)
  894. continue;
  895. if (std::find (chords[i].begin(), chords[i].end(), c) == chords[i].end())
  896. continue;
  897. if (typingPiano && plainPrintable && ! a.whilePiano)
  898. continue;
  899. if (a.context == focus && focus != Context::global)
  900. return a.id; // the focused panel wins
  901. if (globalMatch == nullptr)
  902. globalMatch = &a;
  903. }
  904. return globalMatch != nullptr ? globalMatch->id : std::string();
  905. }
  906. const std::vector<Chord>& KeyMap::chordsFor (const std::string& actionId) const
  907. {
  908. static const std::vector<Chord> empty;
  909. const auto& list = actions();
  910. for (std::size_t i = 0; i < list.size(); ++i)
  911. if (actionId == list[i].id)
  912. return chords[i];
  913. return empty;
  914. }
  915. void KeyMap::setChords (const std::string& actionId, std::vector<Chord> newChords)
  916. {
  917. const auto& list = actions();
  918. for (std::size_t i = 0; i < list.size(); ++i)
  919. if (actionId == list[i].id)
  920. chords[i] = std::move (newChords);
  921. }
  922. bool KeyMap::loadJson (const std::string& json, std::vector<std::string>* errors)
  923. {
  924. Json p { json };
  925. auto fail = [&] (const std::string& message) {
  926. if (errors != nullptr)
  927. errors->push_back (message);
  928. };
  929. if (! p.eat ('{'))
  930. return false;
  931. if (p.eat ('}'))
  932. return true;
  933. for (;;)
  934. {
  935. const auto id = p.string();
  936. if (! id || ! p.eat (':'))
  937. return false;
  938. std::vector<std::string> values;
  939. if (p.eat ('['))
  940. {
  941. if (! p.eat (']'))
  942. for (;;)
  943. {
  944. const auto v = p.string();
  945. if (! v)
  946. return false;
  947. values.push_back (*v);
  948. if (p.eat (']'))
  949. break;
  950. if (! p.eat (','))
  951. return false;
  952. }
  953. }
  954. else if (const auto v = p.string())
  955. {
  956. if (! trim (*v).empty())
  957. values.push_back (*v);
  958. }
  959. else
  960. return false;
  961. if (findAction (*id) == nullptr)
  962. fail ("unknown action: " + *id);
  963. else
  964. {
  965. std::vector<Chord> parsed;
  966. for (const auto& v : values)
  967. if (const auto c = parseChord (v))
  968. parsed.push_back (*c);
  969. else
  970. fail ("unreadable key for " + *id + ": " + v);
  971. setChords (*id, parsed);
  972. }
  973. if (p.eat ('}'))
  974. return true;
  975. if (! p.eat (','))
  976. return false;
  977. }
  978. }
  979. std::string KeyMap::toJson() const
  980. {
  981. std::string out = "{\n";
  982. const auto& list = actions();
  983. for (std::size_t i = 0; i < list.size(); ++i)
  984. {
  985. out += " \"" + std::string (list[i].id) + "\": [";
  986. for (std::size_t k = 0; k < chords[i].size(); ++k)
  987. out += (k > 0 ? ", \"" : "\"") + toString (chords[i][k]) + "\"";
  988. out += i + 1 < list.size() ? "],\n" : "]\n";
  989. }
  990. return out + "}\n";
  991. }
  992. std::vector<KeyMap::Binding> KeyMap::functionKeyBindings() const
  993. {
  994. std::vector<Binding> out;
  995. const auto& list = actions();
  996. for (std::size_t i = 0; i < list.size(); ++i)
  997. for (const auto& c : chords[i])
  998. if (c.key >= f1 && c.key <= f12)
  999. out.push_back ({ c, list[i].id, list[i].context });
  1000. // plain, Shift, Ctrl, Alt, then the combinations; global before a panel's own
  1001. auto modRank = [] (std::uint8_t m) {
  1002. switch (m)
  1003. {
  1004. case none: return 0;
  1005. case shift: return 1;
  1006. case ctrl: return 2;
  1007. case alt: return 3;
  1008. default: return 4 + (int) m;
  1009. }
  1010. };
  1011. std::stable_sort (out.begin(), out.end(), [&] (const Binding& a, const Binding& b) {
  1012. if (a.chord.key != b.chord.key)
  1013. return a.chord.key < b.chord.key;
  1014. if (a.chord.mods != b.chord.mods)
  1015. return modRank (a.chord.mods) < modRank (b.chord.mods);
  1016. return (int) a.context < (int) b.context;
  1017. });
  1018. return out;
  1019. }
  1020. std::vector<std::pair<std::string, std::string>> KeyMap::conflicts() const
  1021. {
  1022. std::vector<std::pair<std::string, std::string>> out;
  1023. const auto& list = actions();
  1024. for (std::size_t a = 0; a < list.size(); ++a)
  1025. for (std::size_t b = a + 1; b < list.size(); ++b)
  1026. {
  1027. if (! contextsOverlap (list[a].context, list[b].context))
  1028. continue;
  1029. for (const auto& c : chords[a])
  1030. if (std::find (chords[b].begin(), chords[b].end(), c) != chords[b].end())
  1031. {
  1032. out.push_back ({ list[a].id, list[b].id });
  1033. break;
  1034. }
  1035. }
  1036. return out;
  1037. }
  1038. std::vector<std::string> KeyMap::actionsWith (const Chord& chord, Context context, const std::string& except) const
  1039. {
  1040. std::vector<std::string> out;
  1041. const auto& list = actions();
  1042. for (std::size_t i = 0; i < list.size(); ++i)
  1043. if (list[i].context == context && except != list[i].id
  1044. && std::find (chords[i].begin(), chords[i].end(), chord) != chords[i].end())
  1045. out.push_back (list[i].id);
  1046. return out;
  1047. }
  1048. bool KeyMap::isDefault (const std::string& actionId) const
  1049. {
  1050. const auto& list = actions();
  1051. for (std::size_t i = 0; i < list.size(); ++i)
  1052. if (actionId == list[i].id)
  1053. return chords[i] == list[i].defaults;
  1054. return true;
  1055. }
  1056. std::string KeyMap::overridesJson() const
  1057. {
  1058. std::string out = "{\n";
  1059. const auto& list = actions();
  1060. bool first = true;
  1061. for (std::size_t i = 0; i < list.size(); ++i)
  1062. {
  1063. if (chords[i] == list[i].defaults)
  1064. continue;
  1065. out += first ? "" : ",\n";
  1066. first = false;
  1067. out += " \"" + std::string (list[i].id) + "\": [";
  1068. for (std::size_t k = 0; k < chords[i].size(); ++k)
  1069. out += (k > 0 ? ", \"" : "\"") + toString (chords[i][k]) + "\"";
  1070. out += "]";
  1071. }
  1072. return out + (first ? "}\n" : "\n}\n");
  1073. }
  1074. } // namespace lynx::keys