2 using System.Collections.Generic;
3 using System.Diagnostics;
6 using System.Runtime.Serialization;
7 using SharpDX.DirectInput;
12 [DataContract( Name = "KeyBindings", Namespace = "" )]
13 class キーバインディング : IExtensibleDataObject
16 /// 入力コードのマッピング用 Dictionary のキーとなる型。
19 /// 入力は、デバイスID(入力デバイスの内部識別用ID; FDKのIInputEvent.DeviceIDと同じ)と、
20 /// キー(キーコード、ノート番号などデバイスから得られる入力値)の組で定義される。
22 [DataContract( Name = "IDとキー", Namespace = "" )]
31 public IdKey( int deviceId, int key )
33 this.deviceId = deviceId;
36 public IdKey( FDK.入力.InputEvent ie )
38 this.deviceId = ie.DeviceID;
45 /// MIDI番号(0~7)とMIDIデバイス名のマッピング用 Dictionary。
48 public Dictionary<int, string> MIDIデバイス番号toデバイス名 { get; protected set; }
51 /// キーボードの入力(DirectInputのKey値)からドラム入力へのマッピング用 Dictionary 。
54 public Dictionary<IdKey, ドラム入力種別> キーボードtoドラム { get; protected set; }
57 /// MIDI入力の入力(MIDIノート番号)からドラム入力へのマッピング用 Dictionary 。
60 public Dictionary<IdKey, ドラム入力種別> MIDItoドラム { get; protected set; }
68 using( Log.Block( FDKUtilities.現在のメソッド名 ) )
70 this._既定値で初期化する( new StreamingContext() );
79 using( Log.Block( FDKUtilities.現在のメソッド名 ) )
81 var path = SST.IO.Folder.絶対パスに含まれるフォルダ変数を展開して返す( _KeyBindingsファイルパス );
82 FDKUtilities.保存する( this, path, false ); // キーが struct なので、SimplayDictionary を使うとおかしくなる。
89 public static キーバインディング 復元する()
91 using( Log.Block( FDKUtilities.現在のメソッド名 ) )
93 var path = SST.IO.Folder.絶対パスに含まれるフォルダ変数を展開して返す( _KeyBindingsファイルパス );
94 return FDKUtilities.復元または新規作成する<キーバインディング>( path, false ); // キーが struct なので、SimplayDictionary を使うとおかしくなる。
99 /// キーバインディングを保存するファイルのパス。
101 private static readonly string _KeyBindingsファイルパス = @"$(AppData)\KeyBindings.json";
104 /// コンストラクタ時または逆シリアル化時のメンバの既定値を設定する。
106 /// <param name="sc">未使用。</param>
108 /// .NET 既定の初期値だと支障のある(逆シリアル化対象の)メンバがあれば、ここで初期化しておくこと。
111 private void _既定値で初期化する( StreamingContext context )
113 using( Log.Block( FDKUtilities.現在のメソッド名 ) )
115 this.MIDIデバイス番号toデバイス名 = new Dictionary<int, string>();
117 this.キーボードtoドラム = new Dictionary<IdKey, ドラム入力種別>() {
118 { new IdKey( 0, (int) Key.Q ), ドラム入力種別.LeftCrash },
119 { new IdKey( 0, (int) Key.Return ), ドラム入力種別.LeftCrash },
120 { new IdKey( 0, (int) Key.A ), ドラム入力種別.HiHat_Open },
121 { new IdKey( 0, (int) Key.Z ), ドラム入力種別.HiHat_Close },
122 { new IdKey( 0, (int) Key.X ), ドラム入力種別.Snare },
123 { new IdKey( 0, (int) Key.C ), ドラム入力種別.Bass },
124 { new IdKey( 0, (int) Key.Space ), ドラム入力種別.Bass },
125 { new IdKey( 0, (int) Key.V ), ドラム入力種別.Tom1 },
126 { new IdKey( 0, (int) Key.B ), ドラム入力種別.Tom2 },
127 { new IdKey( 0, (int) Key.N ), ドラム入力種別.Tom3 },
128 { new IdKey( 0, (int) Key.M ), ドラム入力種別.RightCrash },
129 { new IdKey( 0, (int) Key.K ), ドラム入力種別.Ride },
132 this.MIDItoドラム = new Dictionary<IdKey, ドラム入力種別>() {
134 { new IdKey( 1, 36 ), ドラム入力種別.Bass },
135 { new IdKey( 1, 30 ), ドラム入力種別.RightCrash },
136 { new IdKey( 1, 29 ), ドラム入力種別.RightCrash },
137 { new IdKey( 0, 51 ), ドラム入力種別.RightCrash },
138 { new IdKey( 0, 52 ), ドラム入力種別.RightCrash },
139 { new IdKey( 0, 57 ), ドラム入力種別.RightCrash },
140 { new IdKey( 1, 52 ), ドラム入力種別.RightCrash },
141 { new IdKey( 1, 43 ), ドラム入力種別.Tom3 },
142 { new IdKey( 1, 58 ), ドラム入力種別.Tom3 },
143 { new IdKey( 1, 42 ), ドラム入力種別.HiHat_Close },
144 { new IdKey( 1, 22 ), ドラム入力種別.HiHat_Close },
145 { new IdKey( 1, 26 ), ドラム入力種別.HiHat_Open },
146 { new IdKey( 1, 46 ), ドラム入力種別.HiHat_Open },
147 { new IdKey( 1, 255 ), ドラム入力種別.HiHat_Control }, // FDK の MidiIn クラスは、FootControl を ノート 255 として扱う。
148 { new IdKey( 1, 48 ), ドラム入力種別.Tom3 },
149 { new IdKey( 1, 50 ), ドラム入力種別.Tom3 },
150 { new IdKey( 1, 49 ), ドラム入力種別.LeftCrash },
151 { new IdKey( 1, 55 ), ドラム入力種別.LeftCrash },
152 { new IdKey( 0, 48 ), ドラム入力種別.LeftCrash },
153 { new IdKey( 0, 49 ), ドラム入力種別.LeftCrash },
154 { new IdKey( 0, 59 ), ドラム入力種別.LeftCrash },
155 { new IdKey( 1, 45 ), ドラム入力種別.Tom2 },
156 { new IdKey( 1, 47 ), ドラム入力種別.Tom2 },
157 { new IdKey( 1, 51 ), ドラム入力種別.Ride },
158 { new IdKey( 1, 59 ), ドラム入力種別.Ride },
159 { new IdKey( 1, 38 ), ドラム入力種別.Snare },
160 { new IdKey( 1, 40 ), ドラム入力種別.Snare },
161 { new IdKey( 1, 37 ), ドラム入力種別.Snare },
163 // とりあえず、DTXMania からベタ移植。
164 //{ new IdKey( 0, 42 ), ドラム入力種別.HiHat_Close },
165 //{ new IdKey( 0, 93 ), ドラム入力種別.HiHat_Close },
166 //{ new IdKey( 0, 46 ), ドラム入力種別.HiHat_Open },
167 //{ new IdKey( 0, 92 ), ドラム入力種別.HiHat_Open },
168 //{ new IdKey( 0, 255 ), ドラム入力種別.HiHat_Control }, // FDK の MidiIn クラスは、FootControl を ノート 255 として扱う。
169 //{ new IdKey( 0, 25 ), ドラム入力種別.Snare },
170 //{ new IdKey( 0, 26 ), ドラム入力種別.Snare },
171 //{ new IdKey( 0, 27 ), ドラム入力種別.Snare },
172 //{ new IdKey( 0, 28 ), ドラム入力種別.Snare },
173 //{ new IdKey( 0, 29 ), ドラム入力種別.Snare },
174 //{ new IdKey( 0, 31 ), ドラム入力種別.Snare },
175 //{ new IdKey( 0, 32 ), ドラム入力種別.Snare },
176 //{ new IdKey( 0, 34 ), ドラム入力種別.Snare },
177 //{ new IdKey( 0, 37 ), ドラム入力種別.Snare },
178 //{ new IdKey( 0, 38 ), ドラム入力種別.Snare },
179 //{ new IdKey( 0, 40 ), ドラム入力種別.Snare },
180 //{ new IdKey( 0, 113 ), ドラム入力種別.Snare },
181 //{ new IdKey( 0, 33 ), ドラム入力種別.Bass },
182 //{ new IdKey( 0, 35 ), ドラム入力種別.Bass },
183 //{ new IdKey( 0, 36 ), ドラム入力種別.Bass },
184 //{ new IdKey( 0, 112 ), ドラム入力種別.Bass },
185 //{ new IdKey( 0, 48 ), ドラム入力種別.Tom1 },
186 //{ new IdKey( 0, 50 ), ドラム入力種別.Tom1 },
187 //{ new IdKey( 0, 47 ), ドラム入力種別.Tom2 },
188 //{ new IdKey( 0, 41 ), ドラム入力種別.Tom3 },
189 //{ new IdKey( 0, 43 ), ドラム入力種別.Tom3 },
190 //{ new IdKey( 0, 45 ), ドラム入力種別.Tom3 },
191 //{ new IdKey( 0, 49 ), ドラム入力種別.RightCrash },
192 //{ new IdKey( 0, 52 ), ドラム入力種別.RightCrash },
193 //{ new IdKey( 0, 55 ), ドラム入力種別.RightCrash },
194 //{ new IdKey( 0, 57 ), ドラム入力種別.RightCrash },
195 //{ new IdKey( 0, 91 ), ドラム入力種別.RightCrash },
196 //{ new IdKey( 0, 51 ), ドラム入力種別.Ride },
197 //{ new IdKey( 0, 53 ), ドラム入力種別.Ride },
198 //{ new IdKey( 0, 59 ), ドラム入力種別.Ride },
199 //{ new IdKey( 0, 89 ), ドラム入力種別.Ride },
205 #region " IExtensibleDataObject の実装 "
207 private ExtensionDataObject _ExData;
209 public virtual ExtensionDataObject ExtensionData
215 => this._ExData = value;