private string[,] GetQwertyMappingStrings() { var data = new string[37, 4]; if (PlatformUtils.IsDesktop) { // Stop note. { var k0 = qwertyKeys[0, 0]; var k1 = qwertyKeys[0, 1]; data[0, 0] = "N/A"; data[0, 1] = "Stop Note"; data[0, 2] = k0 < 0 ? "" : PlatformUtils.KeyCodeToString(qwertyKeys[0, 0]); data[0, 3] = k1 < 0 ? "" : PlatformUtils.KeyCodeToString(qwertyKeys[0, 1]); } // Regular notes. for (int idx = 1; idx < data.GetLength(0); idx++) { var octave = (idx - 1) / 12; var note = (idx - 1) % 12; var k0 = qwertyKeys[idx, 0]; var k1 = qwertyKeys[idx, 1]; data[idx, 0] = octave.ToString(); data[idx, 1] = Note.NoteNames[note]; data[idx, 2] = k0 < 0 ? "" : PlatformUtils.KeyCodeToString(qwertyKeys[idx, 0]); data[idx, 3] = k1 < 0 ? "" : PlatformUtils.KeyCodeToString(qwertyKeys[idx, 1]); } } return(data); }
private void QwertyPage_PropertyClicked(PropertyPage props, ClickType click, int propIdx, int rowIdx, int colIdx) { if (propIdx == 1 && colIdx >= 2) { if (click == ClickType.Double) { var dlg = new PropertyDialog("", 300, false, true, dialog); dlg.Properties.AddLabel(null, "Press the new key or ESC to cancel."); dlg.Properties.Build(); // TODO : Make this cross-platform. #if FAMISTUDIO_WINDOWS dlg.KeyDown += (sender, e) => { if (PlatformUtils.KeyCodeToString((int)e.KeyCode) != null) { if (e.KeyCode != Keys.Escape) { AssignQwertyKey(rowIdx, colIdx - 2, (int)e.KeyCode); } dlg.Close(); } }; #elif FAMISTUDIO_LINUX || FAMISTUDIO_MACOS dlg.KeyPressEvent += (o, args) => { // These 2 keys are used by the QWERTY input. if (args.Event.Key != Gdk.Key.Tab && args.Event.Key != Gdk.Key.BackSpace && PlatformUtils.KeyCodeToString((int)args.Event.Key) != null) { if (args.Event.Key != Gdk.Key.Escape) { AssignQwertyKey(rowIdx, colIdx - 2, (int)args.Event.Key); } dlg.Accept(); } }; #endif dlg.ShowDialogAsync(null, (r) => { }); pages[(int)ConfigSection.QWERTY].UpdateMultiColumnList(1, GetQwertyMappingStrings()); } else if (click == ClickType.Right) { qwertyKeys[rowIdx, colIdx - 2] = -1; pages[(int)ConfigSection.QWERTY].UpdateMultiColumnList(1, GetQwertyMappingStrings()); } } else if (propIdx == 2 && click == ClickType.Button) { Array.Copy(Settings.DefaultQwertyKeys, qwertyKeys, Settings.DefaultQwertyKeys.Length); pages[(int)ConfigSection.QWERTY].UpdateMultiColumnList(1, GetQwertyMappingStrings()); } }
void QwertyListDoubleClicked(PropertyPage props, int propertyIndex, int itemIndex, int columnIndex) { if (columnIndex < 2) { return; } var dlg = new PropertyDialog(300, false, true, dialog); dlg.Properties.AddLabel(null, "Press the new key or ESC to cancel."); dlg.Properties.Build(); // TODO : Make this cross-platform. #if FAMISTUDIO_WINDOWS dlg.KeyDown += (sender, e) => { if (PlatformUtils.KeyCodeToString((int)e.KeyCode) != null) { if (e.KeyCode != Keys.Escape) { AssignQwertyKey(itemIndex, columnIndex - 2, (int)e.KeyCode); } dlg.Close(); } }; #else dlg.KeyPressEvent += (o, args) => { // These 2 keys are used by the QWERTY input. if (args.Event.Key != Gdk.Key.Tab && args.Event.Key != Gdk.Key.BackSpace && PlatformUtils.KeyCodeToString((int)args.Event.Key) != null) { if (args.Event.Key != Gdk.Key.Escape) { AssignQwertyKey(itemIndex, columnIndex - 2, (int)args.Event.Key); } dlg.Accept(); } }; #endif dlg.ShowDialog(null); pages[(int)ConfigSection.QWERTY].UpdateMultiColumnList(1, GetQwertyMappingStrings()); }