2 using System.Collections.Generic;
3 using System.Diagnostics;
6 using System.Runtime.Serialization;
8 using SharpDX.DirectInput;
13 [DataContract( Name = "KeyBindings", Namespace = "" )]
14 class キーバインディング : IExtensibleDataObject
17 /// 入力コードのマッピング用 Dictionary のキーとなる型。
20 /// 入力は、デバイスID(入力デバイスの内部識別用ID; FDKのIInputEvent.DeviceIDと同じ)と、
21 /// キー(キーコード、ノート番号などデバイスから得られる入力値)の組で定義される。
23 [DataContract( Name = "IDとキー", Namespace = "" )]
32 public IdKey( int deviceId, int key )
34 this.deviceId = deviceId;
37 public IdKey( FDK.入力.InputEvent ie )
39 this.deviceId = ie.DeviceID;
46 /// キーボードの入力(DirectInputのKey値)からドラム入力へのマッピング用 Dictionary 。
49 public Dictionary<IdKey, ドラム入力種別> キーボードtoドラム { get; protected set; }
52 /// MIDI入力の入力(MIDIノート番号)からドラム入力へのマッピング用 Dictionary 。
55 public Dictionary<IdKey, ドラム入力種別> MIDItoドラム { get; protected set; }
63 this._既定値で初期化する( new StreamingContext() );
69 public static void 保存する( キーバインディング keyBindings )
71 var xmlPath = SST.IO.Folder.絶対パスに含まれるフォルダ変数を展開して返す( _KeyBindingsXmlファイルパス );
72 Utilities.保存する( keyBindings, xmlPath );
78 public static キーバインディング 復元する()
80 var xmlPath = SST.IO.Folder.絶対パスに含まれるフォルダ変数を展開して返す( _KeyBindingsXmlファイルパス );
81 return Utilities.復元または新規作成する<キーバインディング>( xmlPath );
85 /// キーバインディングを保存する XML ファイルのパス。
87 private static readonly string _KeyBindingsXmlファイルパス = @"$(AppData)\KeyBindings.xml";
90 /// コンストラクタ時または逆シリアル化時のメンバの既定値を設定する。
92 /// <param name="sc">未使用。</param>
94 /// .NET 既定の初期値だと支障のある(逆シリアル化対象の)メンバがあれば、ここで初期化しておくこと。
97 private void _既定値で初期化する( StreamingContext context )
99 this.キーボードtoドラム = new Dictionary<IdKey, ドラム入力種別>() {
100 { new IdKey( 0, (int) Key.Q ), ドラム入力種別.LeftCrash },
101 { new IdKey( 0, (int) Key.Return ), ドラム入力種別.LeftCrash },
102 { new IdKey( 0, (int) Key.A ), ドラム入力種別.HiHat_Open },
103 { new IdKey( 0, (int) Key.Z ), ドラム入力種別.HiHat_Close },
104 { new IdKey( 0, (int) Key.X ), ドラム入力種別.Snare },
105 { new IdKey( 0, (int) Key.C ), ドラム入力種別.Bass },
106 { new IdKey( 0, (int) Key.Space ), ドラム入力種別.Bass },
107 { new IdKey( 0, (int) Key.V ), ドラム入力種別.Tom1 },
108 { new IdKey( 0, (int) Key.B ), ドラム入力種別.Tom2 },
109 { new IdKey( 0, (int) Key.N ), ドラム入力種別.Tom3 },
110 { new IdKey( 0, (int) Key.M ), ドラム入力種別.RightCrash },
111 { new IdKey( 0, (int) Key.K ), ドラム入力種別.Ride },
114 this.MIDItoドラム = new Dictionary<IdKey, ドラム入力種別>() {
115 // とりあえず、DTXMania からベタ移植。
116 { new IdKey( 0, 42 ), ドラム入力種別.HiHat_Close },
117 { new IdKey( 0, 93 ), ドラム入力種別.HiHat_Close },
118 { new IdKey( 0, 46 ), ドラム入力種別.HiHat_Open },
119 { new IdKey( 0, 92 ), ドラム入力種別.HiHat_Open },
120 { new IdKey( 0, 255 ), ドラム入力種別.HiHat_Control }, // FDK の MidiIn クラスは、FootControl を ノート 255 として扱う。
121 { new IdKey( 0, 25 ), ドラム入力種別.Snare },
122 { new IdKey( 0, 26 ), ドラム入力種別.Snare },
123 { new IdKey( 0, 27 ), ドラム入力種別.Snare },
124 { new IdKey( 0, 28 ), ドラム入力種別.Snare },
125 { new IdKey( 0, 29 ), ドラム入力種別.Snare },
126 { new IdKey( 0, 31 ), ドラム入力種別.Snare },
127 { new IdKey( 0, 32 ), ドラム入力種別.Snare },
128 { new IdKey( 0, 34 ), ドラム入力種別.Snare },
129 { new IdKey( 0, 37 ), ドラム入力種別.Snare },
130 { new IdKey( 0, 38 ), ドラム入力種別.Snare },
131 { new IdKey( 0, 40 ), ドラム入力種別.Snare },
132 { new IdKey( 0, 113 ), ドラム入力種別.Snare },
133 { new IdKey( 0, 33 ), ドラム入力種別.Bass },
134 { new IdKey( 0, 35 ), ドラム入力種別.Bass },
135 { new IdKey( 0, 36 ), ドラム入力種別.Bass },
136 { new IdKey( 0, 112 ), ドラム入力種別.Bass },
137 { new IdKey( 0, 48 ), ドラム入力種別.Tom1 },
138 { new IdKey( 0, 50 ), ドラム入力種別.Tom1 },
139 { new IdKey( 0, 47 ), ドラム入力種別.Tom2 },
140 { new IdKey( 0, 41 ), ドラム入力種別.Tom3 },
141 { new IdKey( 0, 43 ), ドラム入力種別.Tom3 },
142 { new IdKey( 0, 45 ), ドラム入力種別.Tom3 },
143 { new IdKey( 0, 49 ), ドラム入力種別.RightCrash },
144 { new IdKey( 0, 52 ), ドラム入力種別.RightCrash },
145 { new IdKey( 0, 55 ), ドラム入力種別.RightCrash },
146 { new IdKey( 0, 57 ), ドラム入力種別.RightCrash },
147 { new IdKey( 0, 91 ), ドラム入力種別.RightCrash },
148 { new IdKey( 0, 51 ), ドラム入力種別.Ride },
149 { new IdKey( 0, 53 ), ドラム入力種別.Ride },
150 { new IdKey( 0, 59 ), ドラム入力種別.Ride },
151 { new IdKey( 0, 89 ), ドラム入力種別.Ride },
156 #region " IExtensibleDataObject の実装 "
158 private ExtensionDataObject _ExData;
160 public virtual ExtensionDataObject ExtensionData
166 => this._ExData = value;