1
0

CommandSet.h 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. /*
  2. * CommandSet.h
  3. * ------------
  4. * Purpose: Header file for custom key handling: List of supported keyboard shortcuts and class for them.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include <string>
  12. #include "openmpt/base/FlagSet.hpp"
  13. #include <map>
  14. #include <bitset>
  15. OPENMPT_NAMESPACE_BEGIN
  16. #define HOTKEYF_MIDI 0x10 // modifier mask for MIDI CCs
  17. #define HOTKEYF_RSHIFT 0x20 // modifier mask for right Shift key
  18. #define HOTKEYF_RCONTROL 0x40 // modifier mask for right Ctrl key
  19. #define HOTKEYF_RALT 0x80 // modifier mask for right Alt key
  20. enum InputTargetContext : int8
  21. {
  22. kCtxUnknownContext = -1,
  23. kCtxAllContexts = 0,
  24. kCtxViewGeneral,
  25. kCtxViewPatterns,
  26. kCtxViewPatternsNote,
  27. kCtxViewPatternsIns,
  28. kCtxViewPatternsVol,
  29. kCtxViewPatternsFX,
  30. kCtxViewPatternsFXparam,
  31. kCtxViewSamples,
  32. kCtxViewInstruments,
  33. kCtxViewComments,
  34. kCtxViewTree,
  35. kCtxInsNoteMap,
  36. kCtxVSTGUI,
  37. kCtxCtrlGeneral,
  38. kCtxCtrlPatterns,
  39. kCtxCtrlSamples,
  40. kCtxCtrlInstruments,
  41. kCtxCtrlComments,
  42. kCtxCtrlOrderlist,
  43. kCtxChannelSettings,
  44. kCtxMaxInputContexts
  45. };
  46. enum KeyEventType : int8
  47. {
  48. kKeyEventNone = 0,
  49. kKeyEventDown = 1 << 0,
  50. kKeyEventUp = 1 << 1,
  51. kKeyEventRepeat = 1 << 2,
  52. kNumKeyEvents = 1 << 3
  53. };
  54. DECLARE_FLAGSET(KeyEventType)
  55. enum CommandID
  56. {
  57. kcCommandSetNumNotes = 33, // kcVPEndNotes - kcVPStartNotes
  58. kcNull = -1,
  59. kcFirst,
  60. //Global
  61. kcGlobalStart = kcFirst,
  62. kcStartFile = kcGlobalStart,
  63. kcFileNew = kcGlobalStart,
  64. kcFileOpen,
  65. kcFileAppend,
  66. kcFileClose,
  67. kcFileCloseAll,
  68. kcFileSave,
  69. kcFileSaveAs,
  70. kcFileSaveCopy,
  71. kcFileSaveTemplate,
  72. kcFileSaveAsWave,
  73. kcFileSaveAsMP3,
  74. kcFileSaveMidi,
  75. kcFileSaveOPL,
  76. kcFileExportCompat,
  77. kcPrevDocument,
  78. kcNextDocument,
  79. kcFileImportMidiLib,
  80. kcFileAddSoundBank,
  81. kcEndFile = kcFileAddSoundBank,
  82. kcStartPlayCommands,
  83. kcPlayPauseSong = kcStartPlayCommands,
  84. kcPauseSong,
  85. kcStopSong,
  86. kcPlaySongFromStart,
  87. kcPlaySongFromCursor,
  88. kcPlaySongFromPattern,
  89. kcPlayPatternFromStart,
  90. kcPlayPatternFromCursor,
  91. kcToggleLoopSong,
  92. kcPanic,
  93. kcEstimateSongLength,
  94. kcApproxRealBPM,
  95. kcMidiRecord,
  96. kcTempoIncrease,
  97. kcTempoDecrease,
  98. kcTempoIncreaseFine,
  99. kcTempoDecreaseFine,
  100. kcSpeedIncrease,
  101. kcSpeedDecrease,
  102. kcEndPlayCommands = kcSpeedDecrease,
  103. kcStartEditCommands,
  104. kcEditUndo = kcStartEditCommands,
  105. kcEditRedo,
  106. kcEditCut,
  107. kcEditCopy,
  108. kcEditPaste,
  109. kcEditMixPaste,
  110. kcEditMixPasteITStyle,
  111. kcEditPasteFlood,
  112. kcEditPushForwardPaste,
  113. kcEditSelectAll,
  114. kcEditFind,
  115. kcEditFindNext,
  116. kcEndEditCommands = kcEditFindNext,
  117. /*
  118. kcWindowNew,
  119. kcWindowCascade,
  120. kcWindowTileHorz,
  121. kcWindowTileVert,
  122. */
  123. kcStartView,
  124. kcViewGeneral = kcStartView,
  125. kcViewPattern,
  126. kcViewSamples,
  127. kcViewInstruments,
  128. kcViewComments,
  129. kcViewGraph,
  130. kcViewMain,
  131. kcViewTree,
  132. kcViewOptions,
  133. kcViewChannelManager,
  134. kcViewAddPlugin,
  135. kcViewSongProperties,
  136. kcViewTempoSwing,
  137. kcShowMacroConfig,
  138. kcViewMIDImapping,
  139. kcViewEditHistory,
  140. kcViewToggle,
  141. kcSwitchToInstrLibrary,
  142. kcHelp,
  143. kcEndView = kcHelp,
  144. kcStartMisc,
  145. kcPrevInstrument = kcStartMisc,
  146. kcNextInstrument,
  147. kcPrevOctave,
  148. kcNextOctave,
  149. kcPrevOrder,
  150. kcNextOrder,
  151. kcEndMisc = kcNextOrder,
  152. kcDummyShortcut,
  153. kcGlobalEnd = kcDummyShortcut,
  154. //Pattern Navigation
  155. kcStartPatNavigation,
  156. kcStartJumpSnap = kcStartPatNavigation,
  157. kcPatternJumpDownh1 = kcStartJumpSnap,
  158. kcPatternJumpUph1,
  159. kcPatternJumpDownh2,
  160. kcPatternJumpUph2,
  161. kcPatternSnapDownh1,
  162. kcPatternSnapUph1,
  163. kcPatternSnapDownh2,
  164. kcPatternSnapUph2,
  165. kcPrevEntryInColumn,
  166. kcNextEntryInColumn,
  167. kcEndJumpSnap = kcNextEntryInColumn,
  168. kcStartPlainNavigate,
  169. kcNavigateDown = kcStartPlainNavigate,
  170. kcNavigateUp,
  171. kcNavigateDownBySpacing,
  172. kcNavigateUpBySpacing,
  173. kcNavigateLeft,
  174. kcNavigateRight,
  175. kcNavigateNextChan,
  176. kcNavigatePrevChan,
  177. kcEndPlainNavigate = kcNavigatePrevChan,
  178. kcStartHomeEnd,
  179. kcHomeHorizontal = kcStartHomeEnd,
  180. kcHomeVertical,
  181. kcHomeAbsolute,
  182. kcEndHorizontal,
  183. kcEndVertical,
  184. kcEndAbsolute,
  185. kcEndHomeEnd = kcEndAbsolute,
  186. kcEndPatNavigation = kcEndHomeEnd,
  187. // with select. Order must match above.
  188. kcStartPatNavigationSelect,
  189. kcPatternJumpDownh1Select = kcStartPatNavigationSelect,
  190. kcPatternJumpUph1Select,
  191. kcPatternJumpDownh2Select,
  192. kcPatternJumpUph2Select,
  193. kcPatternSnapDownh1Select,
  194. kcPatternSnapUph1Select,
  195. kcPatternSnapDownh2Select,
  196. kcPatternSnapUph2Select,
  197. kcPrevEntryInColumnSelect,
  198. kcNextEntryInColumnSelect,
  199. kcNavigateDownSelect,
  200. kcNavigateUpSelect,
  201. kcNavigateDownBySpacingSelect,
  202. kcNavigateUpBySpacingSelect,
  203. kcNavigateLeftSelect,
  204. kcNavigateRightSelect,
  205. kcNavigateNextChanSelect,
  206. kcNavigatePrevChanSelect,
  207. kcHomeHorizontalSelect,
  208. kcHomeVerticalSelect,
  209. kcHomeAbsoluteSelect,
  210. kcEndHorizontalSelect,
  211. kcEndVerticalSelect,
  212. kcEndAbsoluteSelect,
  213. kcEndPatNavigationSelect = kcEndAbsoluteSelect,
  214. //Pattern Editing
  215. kcStartPatternEditing,
  216. kcStartSelect = kcStartPatternEditing,
  217. kcSelect = kcStartSelect,
  218. kcSelectWithNav,
  219. kcSelectOff,
  220. kcSelectOffWithNav,
  221. kcSelectWithCopySelect,
  222. kcSelectOffWithCopySelect,
  223. kcCopySelect,
  224. kcCopySelectOff,
  225. kcCopySelectWithNav,
  226. kcCopySelectOffWithNav,
  227. kcCopySelectWithSelect,
  228. kcCopySelectOffWithSelect,
  229. kcSelectChannel,
  230. kcSelectColumn,
  231. kcSelectRow,
  232. kcSelectEvent,
  233. kcSelectBeat,
  234. kcSelectMeasure,
  235. kcLoseSelection,
  236. kcCopyAndLoseSelection,
  237. kcEndSelect = kcCopyAndLoseSelection,
  238. kcStartPatternClipboard,
  239. kcCutPatternChannel = kcStartPatternClipboard,
  240. kcCutPattern,
  241. kcCopyPatternChannel,
  242. kcCopyPattern,
  243. kcPastePatternChannel,
  244. kcPastePattern,
  245. kcToggleClipboardManager,
  246. kcClipboardPrev,
  247. kcClipboardNext,
  248. kcEndPatternClipboard = kcClipboardNext,
  249. kcStartPatternEditMisc,
  250. kcToggleFollowSong = kcStartPatternEditMisc,
  251. kcCursorCopy,
  252. kcCursorPaste,
  253. kcFindInstrument,
  254. kcPatternRecord,
  255. kcPatternPlayRow,
  256. kcSetSpacing,
  257. kcSetSpacing0,
  258. kcSetSpacing1,
  259. kcSetSpacing2,
  260. kcSetSpacing3,
  261. kcSetSpacing4,
  262. kcSetSpacing5,
  263. kcSetSpacing6,
  264. kcSetSpacing7,
  265. kcSetSpacing8,
  266. kcSetSpacing9,
  267. kcIncreaseSpacing,
  268. kcDecreaseSpacing,
  269. kcSwitchToOrderList,
  270. kcNewPattern,
  271. kcDuplicatePattern,
  272. kcSplitPattern,
  273. kcPatternEditPCNotePlugin,
  274. kcTogglePluginEditor,
  275. kcShowNoteProperties,
  276. kcShowPatternProperties,
  277. kcShowSplitKeyboardSettings,
  278. kcChordEditor,
  279. kcChangeLoopStatus,
  280. kcShowEditMenu,
  281. kcShowChannelCtxMenu,
  282. kcShowChannelPluginCtxMenu,
  283. kcTimeAtRow,
  284. kcLockPlaybackToRows,
  285. kcQuantizeSettings,
  286. kcTogglePatternPlayRow,
  287. kcToggleOverflowPaste,
  288. kcToggleNoteOffRecordPC,
  289. kcToggleNoteOffRecordMIDI,
  290. kcEndPatternEditMisc = kcToggleNoteOffRecordMIDI,
  291. kcStartChannelKeys,
  292. kcChannelMute = kcStartChannelKeys,
  293. kcChannelSolo,
  294. kcChannelUnmuteAll,
  295. kcToggleChanMuteOnPatTransition,
  296. kcUnmuteAllChnOnPatTransition,
  297. kcSoloChnOnPatTransition,
  298. kcChannelRecordSelect,
  299. kcChannelSplitRecordSelect,
  300. kcChannelReset,
  301. kcChannelTranspose,
  302. kcChannelDuplicate,
  303. kcChannelAddBefore,
  304. kcChannelAddAfter,
  305. kcChannelRemove,
  306. kcChannelMoveLeft,
  307. kcChannelMoveRight,
  308. kcChannelSettings,
  309. kcEndChannelKeys = kcChannelSettings,
  310. kcBeginTranspose,
  311. kcTransposeUp = kcBeginTranspose,
  312. kcTransposeDown,
  313. kcTransposeOctUp,
  314. kcTransposeOctDown,
  315. kcTransposeCustom,
  316. kcTransposeCustomQuick,
  317. kcDataEntryUp,
  318. kcDataEntryDown,
  319. kcDataEntryUpCoarse,
  320. kcDataEntryDownCoarse,
  321. kcEndTranspose = kcDataEntryDownCoarse,
  322. kcPatternAmplify,
  323. kcPatternInterpolateNote,
  324. kcPatternInterpolateInstr,
  325. kcPatternInterpolateVol,
  326. kcPatternInterpolateEffect,
  327. kcPatternVisualizeEffect,
  328. kcPatternOpenRandomizer,
  329. kcPatternGoto,
  330. kcPatternSetInstrument,
  331. kcPatternSetInstrumentNotEmpty,
  332. kcPatternGrowSelection,
  333. kcPatternShrinkSelection,
  334. // kcClearSelection,
  335. kcClearRow,
  336. kcClearField,
  337. kcClearFieldITStyle,
  338. kcClearRowStep,
  339. kcClearFieldStep,
  340. kcClearFieldStepITStyle,
  341. kcDeleteRow,
  342. kcDeleteWholeRow,
  343. kcDeleteRowGlobal,
  344. kcDeleteWholeRowGlobal,
  345. kcInsertRow,
  346. kcInsertWholeRow,
  347. kcInsertRowGlobal,
  348. kcInsertWholeRowGlobal,
  349. kcPrevPattern,
  350. kcNextPattern,
  351. kcPrevSequence,
  352. kcNextSequence,
  353. kcEndPatternEditing = kcNextSequence,
  354. //Notes
  355. kcVPStartNotes,
  356. kcVPNoteC_0 = kcVPStartNotes,
  357. kcVPNoteCS0,
  358. kcVPNoteD_0,
  359. kcVPNoteDS0,
  360. kcVPNoteE_0,
  361. kcVPNoteF_0,
  362. kcVPNoteFS0,
  363. kcVPNoteG_0,
  364. kcVPNoteGS0,
  365. kcVPNoteA_1,
  366. kcVPNoteAS1,
  367. kcVPNoteB_1,
  368. kcVPNoteC_1,
  369. kcVPNoteCS1,
  370. kcVPNoteD_1,
  371. kcVPNoteDS1,
  372. kcVPNoteE_1,
  373. kcVPNoteF_1,
  374. kcVPNoteFS1,
  375. kcVPNoteG_1,
  376. kcVPNoteGS1,
  377. kcVPNoteA_2,
  378. kcVPNoteAS2,
  379. kcVPNoteB_2,
  380. kcVPNoteC_2,
  381. kcVPNoteCS2,
  382. kcVPNoteD_2,
  383. kcVPNoteDS2,
  384. kcVPNoteE_2,
  385. kcVPNoteF_2,
  386. kcVPNoteFS2,
  387. kcVPNoteG_2,
  388. kcVPNoteGS2,
  389. kcVPNoteA_3,
  390. kcVPEndNotes = kcVPNoteA_3,
  391. //Note stops
  392. kcVPStartNoteStops,
  393. kcVPNoteStopC_0 = kcVPStartNoteStops,
  394. kcVPNoteStopCS0,
  395. kcVPNoteStopD_0,
  396. kcVPNoteStopDS0,
  397. kcVPNoteStopE_0,
  398. kcVPNoteStopF_0,
  399. kcVPNoteStopFS0,
  400. kcVPNoteStopG_0,
  401. kcVPNoteStopGS0,
  402. kcVPNoteStopA_1,
  403. kcVPNoteStopAS1,
  404. kcVPNoteStopB_1,
  405. kcVPNoteStopC_1,
  406. kcVPNoteStopCS1,
  407. kcVPNoteStopD_1,
  408. kcVPNoteStopDS1,
  409. kcVPNoteStopE_1,
  410. kcVPNoteStopF_1,
  411. kcVPNoteStopFS1,
  412. kcVPNoteStopG_1,
  413. kcVPNoteStopGS1,
  414. kcVPNoteStopA_2,
  415. kcVPNoteStopAS2,
  416. kcVPNoteStopB_2,
  417. kcVPNoteStopC_2,
  418. kcVPNoteStopCS2,
  419. kcVPNoteStopD_2,
  420. kcVPNoteStopDS2,
  421. kcVPNoteStopE_2,
  422. kcVPNoteStopF_2,
  423. kcVPNoteStopFS2,
  424. kcVPNoteStopG_2,
  425. kcVPNoteStopGS2,
  426. kcVPNoteStopA_3,
  427. kcVPEndNoteStops = kcVPNoteStopA_3,
  428. //Chords
  429. kcVPStartChords,
  430. kcVPChordC_0 = kcVPStartChords,
  431. kcVPChordCS0,
  432. kcVPChordD_0,
  433. kcVPChordDS0,
  434. kcVPChordE_0,
  435. kcVPChordF_0,
  436. kcVPChordFS0,
  437. kcVPChordG_0,
  438. kcVPChordGS0,
  439. kcVPChordA_1,
  440. kcVPChordAS1,
  441. kcVPChordB_1,
  442. kcVPChordC_1,
  443. kcVPChordCS1,
  444. kcVPChordD_1,
  445. kcVPChordDS1,
  446. kcVPChordE_1,
  447. kcVPChordF_1,
  448. kcVPChordFS1,
  449. kcVPChordG_1,
  450. kcVPChordGS1,
  451. kcVPChordA_2,
  452. kcVPChordAS2,
  453. kcVPChordB_2,
  454. kcVPChordC_2,
  455. kcVPChordCS2,
  456. kcVPChordD_2,
  457. kcVPChordDS2,
  458. kcVPChordE_2,
  459. kcVPChordF_2,
  460. kcVPChordFS2,
  461. kcVPChordG_2,
  462. kcVPChordGS2,
  463. kcVPChordA_3,
  464. kcVPEndChords = kcVPChordA_3,
  465. //Chord Stops
  466. kcVPStartChordStops,
  467. kcVPChordStopC_0 = kcVPStartChordStops,
  468. kcVPChordStopCS0,
  469. kcVPChordStopD_0,
  470. kcVPChordStopDS0,
  471. kcVPChordStopE_0,
  472. kcVPChordStopF_0,
  473. kcVPChordStopFS0,
  474. kcVPChordStopG_0,
  475. kcVPChordStopGS0,
  476. kcVPChordStopA_1,
  477. kcVPChordStopAS1,
  478. kcVPChordStopB_1,
  479. kcVPChordStopC_1,
  480. kcVPChordStopCS1,
  481. kcVPChordStopD_1,
  482. kcVPChordStopDS1,
  483. kcVPChordStopE_1,
  484. kcVPChordStopF_1,
  485. kcVPChordStopFS1,
  486. kcVPChordStopG_1,
  487. kcVPChordStopGS1,
  488. kcVPChordStopA_2,
  489. kcVPChordStopAS2,
  490. kcVPChordStopB_2,
  491. kcVPChordStopC_2,
  492. kcVPChordStopCS2,
  493. kcVPChordStopD_2,
  494. kcVPChordStopDS2,
  495. kcVPChordStopE_2,
  496. kcVPChordStopF_2,
  497. kcVPChordStopFS2,
  498. kcVPChordStopG_2,
  499. kcVPChordStopGS2,
  500. kcVPChordStopA_3,
  501. kcVPEndChordStops = kcVPChordStopA_3,
  502. //Set octave from note column
  503. kcSetOctave0,
  504. kcSetOctave1,
  505. kcSetOctave2,
  506. kcSetOctave3,
  507. kcSetOctave4,
  508. kcSetOctave5,
  509. kcSetOctave6,
  510. kcSetOctave7,
  511. kcSetOctave8,
  512. kcSetOctave9,
  513. // Release set octave key
  514. kcSetOctaveStop0,
  515. kcSetOctaveStop1,
  516. kcSetOctaveStop2,
  517. kcSetOctaveStop3,
  518. kcSetOctaveStop4,
  519. kcSetOctaveStop5,
  520. kcSetOctaveStop6,
  521. kcSetOctaveStop7,
  522. kcSetOctaveStop8,
  523. kcSetOctaveStop9,
  524. //Note Misc
  525. kcStartNoteMisc,
  526. kcChordModifier = kcStartNoteMisc,
  527. kcNoteCutOld,
  528. kcNoteOffOld,
  529. kcNoteFadeOld,
  530. kcNoteCut,
  531. kcNoteOff,
  532. kcNoteFade,
  533. kcNotePC,
  534. kcNotePCS,
  535. kcEndNoteMisc = kcNotePCS,
  536. //Set instruments
  537. kcSetIns0,
  538. kcSetIns1,
  539. kcSetIns2,
  540. kcSetIns3,
  541. kcSetIns4,
  542. kcSetIns5,
  543. kcSetIns6,
  544. kcSetIns7,
  545. kcSetIns8,
  546. kcSetIns9,
  547. //Volume stuff
  548. kcSetVolumeStart,
  549. kcSetVolume0 = kcSetVolumeStart,
  550. kcSetVolume1,
  551. kcSetVolume2,
  552. kcSetVolume3,
  553. kcSetVolume4,
  554. kcSetVolume5,
  555. kcSetVolume6,
  556. kcSetVolume7,
  557. kcSetVolume8,
  558. kcSetVolume9,
  559. kcSetVolumeVol, //v
  560. kcSetVolumePan, //p
  561. kcSetVolumeVolSlideUp, //c
  562. kcSetVolumeVolSlideDown, //d
  563. kcSetVolumeFineVolUp, //a
  564. kcSetVolumeFineVolDown, //b
  565. kcSetVolumeVibratoSpd, //u
  566. kcSetVolumeVibrato, //h
  567. kcSetVolumeXMPanLeft, //l
  568. kcSetVolumeXMPanRight, //r
  569. kcSetVolumePortamento, //g
  570. kcSetVolumeITPortaUp, //f
  571. kcSetVolumeITPortaDown, //e
  572. kcSetVolumeITUnused, //:
  573. kcSetVolumeITOffset, //o
  574. kcSetVolumeEnd = kcSetVolumeITOffset,
  575. //Effect params
  576. kcSetFXParam0,
  577. kcSetFXParam1,
  578. kcSetFXParam2,
  579. kcSetFXParam3,
  580. kcSetFXParam4,
  581. kcSetFXParam5,
  582. kcSetFXParam6,
  583. kcSetFXParam7,
  584. kcSetFXParam8,
  585. kcSetFXParam9,
  586. kcSetFXParamA,
  587. kcSetFXParamB,
  588. kcSetFXParamC,
  589. kcSetFXParamD,
  590. kcSetFXParamE,
  591. kcSetFXParamF,
  592. //Effect commands. ORDER IS CRUCIAL.
  593. kcSetFXStart,
  594. kcFixedFXStart = kcSetFXStart,
  595. kcSetFXarp = kcSetFXStart, //0,j
  596. kcSetFXportUp, //1,f
  597. kcSetFXportDown, //2,e
  598. kcSetFXport, //3,g
  599. kcSetFXvibrato, //4,h
  600. kcSetFXportSlide, //5,l
  601. kcSetFXvibSlide, //6,k
  602. kcSetFXtremolo, //7,r
  603. kcSetFXpan, //8,x
  604. kcSetFXoffset, //9,o
  605. kcSetFXvolSlide, //a,d
  606. kcSetFXgotoOrd, //b,b
  607. kcSetFXsetVol, //c,?
  608. kcSetFXgotoRow, //d,c
  609. kcSetFXretrig, //r,q
  610. kcSetFXspeed, //?,a
  611. kcSetFXtempo, //f,t
  612. kcSetFXtremor, //t,i
  613. kcSetFXextendedMOD, //e,?
  614. kcSetFXextendedS3M, //?,s
  615. kcSetFXchannelVol, //?,m
  616. kcSetFXchannelVols, //?,n
  617. kcSetFXglobalVol, //g,v
  618. kcSetFXglobalVols, //h,w
  619. kcSetFXkeyoff, //k,?
  620. kcSetFXfineVib, //?,u
  621. kcSetFXpanbrello, //y,y
  622. kcSetFXextendedXM, //x,?
  623. kcSetFXpanSlide, //p,p
  624. kcSetFXsetEnvPos, //l,?
  625. kcSetFXmacro, //z,z
  626. kcFixedFXend = kcSetFXmacro,
  627. kcSetFXmacroSlide, //?,\ ,
  628. kcSetFXdelaycut, //?,:
  629. kcSetFXextension, //?,#
  630. kcSetFXFinetune, //?,+
  631. kcSetFXFinetuneSmooth, //?,*
  632. kcSetFXEnd = kcSetFXFinetuneSmooth,
  633. kcStartInstrumentMisc,
  634. kcInstrumentLoad = kcStartInstrumentMisc,
  635. kcInstrumentSave,
  636. kcInstrumentNew,
  637. kcInstrumentEnvelopeLoad,
  638. kcInstrumentEnvelopeSave,
  639. kcInstrumentEnvelopeZoomIn,
  640. kcInstrumentEnvelopeZoomOut,
  641. kcInstrumentEnvelopeScale,
  642. kcInstrumentEnvelopeSwitchToVolume,
  643. kcInstrumentEnvelopeSwitchToPanning,
  644. kcInstrumentEnvelopeSwitchToPitch,
  645. kcInstrumentEnvelopeToggleVolume,
  646. kcInstrumentEnvelopeTogglePanning,
  647. kcInstrumentEnvelopeTogglePitch,
  648. kcInstrumentEnvelopeToggleFilter,
  649. kcInstrumentEnvelopeToggleLoop,
  650. kcInstrumentEnvelopeSelectLoopStart,
  651. kcInstrumentEnvelopeSelectLoopEnd,
  652. kcInstrumentEnvelopeToggleSustain,
  653. kcInstrumentEnvelopeSelectSustainStart,
  654. kcInstrumentEnvelopeSelectSustainEnd,
  655. kcInstrumentEnvelopeToggleCarry,
  656. kcInstrumentEnvelopePointPrev,
  657. kcInstrumentEnvelopePointNext,
  658. kcInstrumentEnvelopePointMoveLeft,
  659. kcInstrumentEnvelopePointMoveRight,
  660. kcInstrumentEnvelopePointMoveLeftCoarse,
  661. kcInstrumentEnvelopePointMoveRightCoarse,
  662. kcInstrumentEnvelopePointMoveUp,
  663. kcInstrumentEnvelopePointMoveUp8,
  664. kcInstrumentEnvelopePointMoveDown,
  665. kcInstrumentEnvelopePointMoveDown8,
  666. kcInstrumentEnvelopePointInsert,
  667. kcInstrumentEnvelopePointRemove,
  668. kcInstrumentEnvelopeSetLoopStart,
  669. kcInstrumentEnvelopeSetLoopEnd,
  670. kcInstrumentEnvelopeSetSustainLoopStart,
  671. kcInstrumentEnvelopeSetSustainLoopEnd,
  672. kcInstrumentEnvelopeToggleReleaseNode,
  673. kcEndInstrumentMisc = kcInstrumentEnvelopeToggleReleaseNode,
  674. kcStartInstrumentCtrlMisc,
  675. kcInstrumentCtrlLoad = kcStartInstrumentCtrlMisc,
  676. kcInstrumentCtrlSave,
  677. kcInstrumentCtrlNew,
  678. kcInstrumentCtrlDuplicate,
  679. kcInsNoteMapEditSampleMap,
  680. kcInsNoteMapEditSample,
  681. kcInsNoteMapCopyCurrentNote,
  682. kcInsNoteMapCopyCurrentSample,
  683. kcInsNoteMapReset,
  684. kcInsNoteMapTransposeSamples,
  685. kcInsNoteMapRemove,
  686. kcInsNoteMapTransposeUp,
  687. kcInsNoteMapTransposeDown,
  688. kcInsNoteMapTransposeOctUp,
  689. kcInsNoteMapTransposeOctDown,
  690. kcEndInstrumentCtrlMisc = kcInsNoteMapTransposeOctDown,
  691. kcStartSampleMisc,
  692. kcSampleLoad = kcStartSampleMisc,
  693. kcSampleLoadRaw,
  694. kcSampleSave,
  695. kcSampleNew,
  696. kcSampleDuplicate,
  697. kcSampleInitializeOPL,
  698. kcSampleTransposeUp,
  699. kcSampleTransposeDown,
  700. kcSampleTransposeOctUp,
  701. kcSampleTransposeOctDown,
  702. kcEndSampleMisc = kcSampleTransposeOctDown,
  703. kcStartSampleEditing,
  704. kcSampleTrim = kcStartSampleEditing,
  705. kcSampleTrimToLoopEnd,
  706. kcSampleSilence,
  707. kcSampleNormalize,
  708. kcSampleAmplify,
  709. kcSampleReverse,
  710. kcSampleDelete,
  711. kcSampleToggleDrawing,
  712. kcSampleResize,
  713. kcSampleGrid,
  714. kcSampleZoomUp,
  715. kcSampleZoomDown,
  716. kcSampleZoomSelection,
  717. kcSampleCenterSampleStart,
  718. kcSampleCenterSampleEnd,
  719. kcSampleCenterLoopStart,
  720. kcSampleCenterLoopEnd,
  721. kcSampleCenterSustainStart,
  722. kcSampleCenterSustainEnd,
  723. kcSampleConvertPingPongLoop,
  724. kcSampleConvertPingPongSustain,
  725. kcSample8Bit,
  726. kcSampleMonoMix,
  727. kcSampleMonoLeft,
  728. kcSampleMonoRight,
  729. kcSampleMonoSplit,
  730. kcSampleStereoSep,
  731. kcSampleUpsample,
  732. kcSampleDownsample,
  733. kcSampleResample,
  734. kcSampleInvert,
  735. kcSampleSignUnsign,
  736. kcSampleRemoveDCOffset,
  737. kcSampleQuickFade,
  738. kcSampleXFade,
  739. kcSampleAutotune,
  740. kcEndSampleEditing = kcSampleAutotune,
  741. kcStartSampleCues,
  742. kcEndSampleCues = kcStartSampleCues + 8,
  743. kcSampleSlice,
  744. kcEndSampleCueGroup = kcSampleSlice,
  745. kcSampStartNotes,
  746. kcSampEndNotes = kcSampStartNotes + kcCommandSetNumNotes,
  747. kcSampStartNoteStops,
  748. kcSampEndNoteStops = kcSampStartNoteStops + kcCommandSetNumNotes,
  749. kcInstrumentStartNotes,
  750. kcInstrumentEndNotes = kcInstrumentStartNotes + kcCommandSetNumNotes,
  751. kcInstrumentStartNoteStops,
  752. kcInstrumentEndNoteStops = kcInstrumentStartNoteStops + kcCommandSetNumNotes,
  753. kcTreeViewStartNotes,
  754. kcTreeViewEndNotes = kcTreeViewStartNotes + kcCommandSetNumNotes,
  755. kcTreeViewStartNoteStops,
  756. kcTreeViewEndNoteStops = kcTreeViewStartNoteStops + kcCommandSetNumNotes,
  757. kcInsNoteMapStartNotes,
  758. kcInsNoteMapEndNotes = kcInsNoteMapStartNotes + kcCommandSetNumNotes,
  759. kcInsNoteMapStartNoteStops,
  760. kcInsNoteMapEndNoteStops = kcInsNoteMapStartNoteStops + kcCommandSetNumNotes,
  761. kcVSTGUIStartNotes,
  762. kcVSTGUIEndNotes = kcVSTGUIStartNotes + kcCommandSetNumNotes,
  763. kcVSTGUIStartNoteStops,
  764. kcVSTGUIEndNoteStops = kcVSTGUIStartNoteStops + kcCommandSetNumNotes,
  765. kcCommentsStartNotes,
  766. kcCommentsEndNotes = kcCommentsStartNotes + kcCommandSetNumNotes,
  767. kcCommentsStartNoteStops,
  768. kcCommentsEndNoteStops = kcCommentsStartNoteStops + kcCommandSetNumNotes,
  769. kcTreeViewStopPreview,
  770. kcStartVSTGUICommands,
  771. kcVSTGUIPrevPreset = kcStartVSTGUICommands,
  772. kcVSTGUINextPreset,
  773. kcVSTGUIPrevPresetJump,
  774. kcVSTGUINextPresetJump,
  775. kcVSTGUIRandParams,
  776. kcVSTGUIToggleRecordParams,
  777. kcVSTGUIToggleRecordMIDIOut,
  778. kcVSTGUIToggleSendKeysToPlug,
  779. kcVSTGUIBypassPlug,
  780. kcEndVSTGUICommands = kcVSTGUIBypassPlug,
  781. kcStartOrderlistCommands,
  782. // Orderlist edit
  783. kcStartOrderlistEdit = kcStartOrderlistCommands,
  784. kcOrderlistEditDelete = kcStartOrderlistEdit,
  785. kcOrderlistEditInsert,
  786. kcOrderlistEditInsertSeparator,
  787. kcOrderlistEditCopyOrders,
  788. kcMergePatterns,
  789. kcOrderlistEditPattern,
  790. kcOrderlistSwitchToPatternView,
  791. kcEndOrderlistEdit = kcOrderlistSwitchToPatternView,
  792. // Orderlist navigation
  793. kcStartOrderlistNavigation,
  794. kcOrderlistNavigateLeft = kcStartOrderlistNavigation,
  795. kcOrderlistNavigateRight,
  796. kcOrderlistNavigateFirst,
  797. kcOrderlistNavigateLast,
  798. kcEndOrderlistNavigation = kcOrderlistNavigateLast,
  799. // with selection key(must match order above)
  800. kcStartOrderlistNavigationSelect,
  801. kcOrderlistNavigateLeftSelect = kcStartOrderlistNavigationSelect,
  802. kcOrderlistNavigateRightSelect,
  803. kcOrderlistNavigateFirstSelect,
  804. kcOrderlistNavigateLastSelect,
  805. kcEndOrderlistNavigationSelect = kcOrderlistNavigateLastSelect,
  806. // Orderlist pattern list edit
  807. kcStartOrderlistNum,
  808. kcOrderlistPat0 = kcStartOrderlistNum,
  809. kcOrderlistPat1,
  810. kcOrderlistPat2,
  811. kcOrderlistPat3,
  812. kcOrderlistPat4,
  813. kcOrderlistPat5,
  814. kcOrderlistPat6,
  815. kcOrderlistPat7,
  816. kcOrderlistPat8,
  817. kcOrderlistPat9,
  818. kcOrderlistPatPlus,
  819. kcOrderlistPatMinus,
  820. kcOrderlistPatIgnore,
  821. kcOrderlistPatInvalid,
  822. kcEndOrderlistNum = kcOrderlistPatInvalid,
  823. // Playback lock
  824. kcStartOrderlistLock,
  825. kcOrderlistLockPlayback = kcStartOrderlistLock,
  826. kcOrderlistUnlockPlayback,
  827. kcEndOrderlistLock = kcOrderlistUnlockPlayback,
  828. kcEndOrderlistCommands = kcEndOrderlistLock,
  829. kcStartChnSettingsCommands,
  830. kcChnSettingsPrev = kcStartChnSettingsCommands,
  831. kcChnSettingsNext,
  832. kcChnColorFromPrev,
  833. kcChnColorFromNext,
  834. kcChnSettingsClose,
  835. kcEndChnSettingsCommands = kcChnSettingsClose,
  836. kcStartCommentsCommands,
  837. kcToggleSmpInsList = kcStartCommentsCommands,
  838. kcExecuteSmpInsListItem,
  839. kcRenameSmpInsListItem,
  840. kcEndCommentsCommands = kcRenameSmpInsListItem,
  841. kcNumCommands,
  842. };
  843. enum Modifiers : uint8
  844. {
  845. ModNone = 0,
  846. ModShift = HOTKEYF_SHIFT,
  847. ModCtrl = HOTKEYF_CONTROL,
  848. ModAlt = HOTKEYF_ALT,
  849. ModWin = HOTKEYF_EXT,
  850. ModMidi = HOTKEYF_MIDI,
  851. ModRShift = HOTKEYF_RSHIFT,
  852. ModRCtrl = HOTKEYF_RCONTROL,
  853. ModRAlt = HOTKEYF_RALT,
  854. MaxMod = ModShift | ModCtrl | ModAlt | ModWin | ModMidi | ModRShift | ModRCtrl | ModRAlt,
  855. };
  856. DECLARE_FLAGSET(Modifiers)
  857. struct KeyCombination
  858. {
  859. protected:
  860. InputTargetContext ctx; // TODO: This should probably rather be a member of CommandStruct and not of the individual key combinations for consistency's sake.
  861. FlagSet<Modifiers> mod;
  862. uint8 code;
  863. FlagSet<KeyEventType> event;
  864. constexpr uint32 AsUint32() const
  865. {
  866. static_assert(sizeof(KeyCombination) == sizeof(uint32));
  867. return (static_cast<uint32>(ctx) << 0) |
  868. (static_cast<uint32>(mod.GetRaw()) << 8) |
  869. (static_cast<uint32>(code) << 16) |
  870. (static_cast<uint32>(event.GetRaw()) << 24);
  871. }
  872. public:
  873. KeyCombination(InputTargetContext context = kCtxAllContexts, FlagSet<Modifiers> modifier = ModNone, UINT key = 0, FlagSet<KeyEventType> type = kKeyEventNone)
  874. : ctx(context)
  875. , mod(modifier)
  876. , code(static_cast<uint8>(key))
  877. , event(type)
  878. {
  879. }
  880. constexpr bool operator==(const KeyCombination &other) const
  881. {
  882. return ctx == other.ctx && mod == other.mod && code == other.code && event == other.event;
  883. }
  884. constexpr bool operator<(const KeyCombination &kc) const
  885. {
  886. return AsUint32() < kc.AsUint32();
  887. }
  888. // Getters / Setters
  889. void Context(InputTargetContext context) { ctx = context; }
  890. constexpr InputTargetContext Context() const { return ctx; }
  891. void Modifier(FlagSet<Modifiers> modifier) { mod = modifier; }
  892. constexpr FlagSet<Modifiers> Modifier() const { return mod; }
  893. void Modifier(const KeyCombination &other) { mod = other.mod; }
  894. void AddModifier(FlagSet<Modifiers> modifier) { mod |= modifier; }
  895. void AddModifier(const KeyCombination &other) { mod |= other.mod; }
  896. void KeyCode(UINT key) { code = static_cast<uint8>(key); }
  897. constexpr UINT KeyCode() const { return code; }
  898. void EventType(FlagSet<KeyEventType> type) { event = type; }
  899. constexpr FlagSet<KeyEventType> EventType() const { return event; }
  900. static KeyCombination FromLPARAM(LPARAM lParam)
  901. {
  902. return KeyCombination(
  903. static_cast<InputTargetContext>((lParam >> 0) & 0xFF),
  904. static_cast<Modifiers>((lParam >> 8) & 0xFF),
  905. static_cast<UINT>((lParam >> 16) & 0xFF),
  906. static_cast<KeyEventType>((lParam >> 24) & 0xFF));
  907. }
  908. LPARAM AsLPARAM() const { return AsUint32(); }
  909. // Key combination to string
  910. static CString GetContextText(InputTargetContext ctx);
  911. CString GetContextText() const { return GetContextText(Context()); }
  912. static CString GetModifierText(FlagSet<Modifiers> mod);
  913. CString GetModifierText() const { return GetModifierText(Modifier()); }
  914. static CString GetKeyText(FlagSet<Modifiers> mod, UINT code);
  915. CString GetKeyText() const { return GetKeyText(Modifier(), KeyCode()); }
  916. static CString GetKeyEventText(FlagSet<KeyEventType> event);
  917. CString GetKeyEventText() const { return GetKeyEventText(EventType()); }
  918. static bool IsExtended(UINT code);
  919. };
  920. using KeyMap = std::multimap<KeyCombination, CommandID>;
  921. using KeyMapRange = std::pair<KeyMap::const_iterator, KeyMap::const_iterator>;
  922. //KeyMap
  923. struct KeyCommand
  924. {
  925. static constexpr uint32 Dummy = 1u << 31;
  926. static constexpr uint32 Hidden = 1u << 30;
  927. static constexpr uint32 UIDMask = Hidden - 1u;
  928. std::vector<KeyCombination> kcList;
  929. CString Message;
  930. protected:
  931. uint32 UID = 0;
  932. public:
  933. KeyCommand() = default;
  934. KeyCommand(uint32 uid, const TCHAR *message = _T(""), std::vector<KeyCombination> keys = {});
  935. // Unique ID for on-disk keymap format.
  936. // Note that hidden commands do not have a unique ID, because they are never written to keymap files.
  937. uint32 ID() const noexcept { return UID & UIDMask; }
  938. // e.g. Chord modifier is a dummy command, which serves only to automatically
  939. // generate a set of key combinations for chords
  940. bool IsDummy() const noexcept { return (UID & Dummy) != 0; }
  941. // Hidden commands are not configurable by the user (e.g. derived from dummy commands or note entry keys duplicated into other contexts)
  942. bool IsHidden() const noexcept { return (UID & Hidden) != 0; }
  943. };
  944. enum RuleID
  945. {
  946. krPreventDuplicate,
  947. krDeleteOldOnConflict,
  948. krAllowNavigationWithSelection,
  949. krAllowSelectionWithNavigation,
  950. krAutoSelectOff,
  951. krAllowSelectCopySelectCombos,
  952. krLockNotesToChords,
  953. krNoteOffOnKeyRelease,
  954. krPropagateNotes,
  955. krReassignDigitsToOctaves,
  956. krAutoSpacing,
  957. krCheckModifiers,
  958. krPropagateSampleManipulation,
  959. kNumRules
  960. };
  961. struct CModSpecifications;
  962. class CCommandSet
  963. {
  964. protected:
  965. //util
  966. void SetupCommands();
  967. void SetupContextHierarchy();
  968. CString EnforceAll(KeyCombination kc, CommandID cmd, bool adding);
  969. CommandID FindCmd(uint32 uid) const;
  970. bool KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool checkEventConflict = true) const;
  971. const CModSpecifications *m_oldSpecs = nullptr;
  972. KeyCommand m_commands[kcNumCommands];
  973. std::bitset<kCtxMaxInputContexts> m_isParentContext[kCtxMaxInputContexts];
  974. std::bitset<kNumRules> m_enforceRule;
  975. public:
  976. CCommandSet();
  977. // Population
  978. CString Add(KeyCombination kc, CommandID cmd, bool overwrite, int pos = -1, bool checkEventConflict = true);
  979. CString Remove(KeyCombination kc, CommandID cmd);
  980. CString Remove(int pos, CommandID cmd);
  981. std::pair<CommandID, KeyCombination> IsConflicting(KeyCombination kc, CommandID cmd, bool checkEventConflict = true) const;
  982. bool IsCrossContextConflict(KeyCombination kc1, KeyCombination kc2) const;
  983. // Tranformation
  984. bool QuickChange_SetEffects(const CModSpecifications &modSpecs);
  985. bool QuickChange_NotesRepeat(bool repeat);
  986. // Communication
  987. KeyCombination GetKey(CommandID cmd, UINT key) const { return m_commands[cmd].kcList[key]; }
  988. bool isHidden(UINT c) const { return m_commands[c].IsHidden(); }
  989. int GetKeyListSize(CommandID cmd) const { return (cmd != kcNull) ? static_cast<int>(m_commands[cmd].kcList.size()) : 0; }
  990. CString GetCommandText(CommandID cmd) const { return m_commands[cmd].Message; }
  991. CString GetKeyTextFromCommand(CommandID c, UINT key) const;
  992. // Pululation ;)
  993. void Copy(const CCommandSet *source); // Copy the contents of a commandset into this command set
  994. void GenKeyMap(KeyMap &km); // Generate a keymap from this command set
  995. bool SaveFile(const mpt::PathString &filename);
  996. bool LoadFile(const mpt::PathString &filename);
  997. bool LoadFile(std::istream &iStrm, const mpt::ustring &filenameDescription, const bool fillExistingSet = false);
  998. bool LoadDefaultKeymap();
  999. };
  1000. OPENMPT_NAMESPACE_END