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, ドラム入力種別>() {
133 // とりあえず、DTXMania からベタ移植。
134 { new IdKey( 0, 42 ), ドラム入力種別.HiHat_Close },
135 { new IdKey( 0, 93 ), ドラム入力種別.HiHat_Close },
136 { new IdKey( 0, 46 ), ドラム入力種別.HiHat_Open },
137 { new IdKey( 0, 92 ), ドラム入力種別.HiHat_Open },
138 { new IdKey( 0, 255 ), ドラム入力種別.HiHat_Control }, // FDK の MidiIn クラスは、FootControl を ノート 255 として扱う。
139 { new IdKey( 0, 25 ), ドラム入力種別.Snare },
140 { new IdKey( 0, 26 ), ドラム入力種別.Snare },
141 { new IdKey( 0, 27 ), ドラム入力種別.Snare },
142 { new IdKey( 0, 28 ), ドラム入力種別.Snare },
143 { new IdKey( 0, 29 ), ドラム入力種別.Snare },
144 { new IdKey( 0, 31 ), ドラム入力種別.Snare },
145 { new IdKey( 0, 32 ), ドラム入力種別.Snare },
146 { new IdKey( 0, 34 ), ドラム入力種別.Snare },
147 { new IdKey( 0, 37 ), ドラム入力種別.Snare },
148 { new IdKey( 0, 38 ), ドラム入力種別.Snare },
149 { new IdKey( 0, 40 ), ドラム入力種別.Snare },
150 { new IdKey( 0, 113 ), ドラム入力種別.Snare },
151 { new IdKey( 0, 33 ), ドラム入力種別.Bass },
152 { new IdKey( 0, 35 ), ドラム入力種別.Bass },
153 { new IdKey( 0, 36 ), ドラム入力種別.Bass },
154 { new IdKey( 0, 112 ), ドラム入力種別.Bass },
155 { new IdKey( 0, 48 ), ドラム入力種別.Tom1 },
156 { new IdKey( 0, 50 ), ドラム入力種別.Tom1 },
157 { new IdKey( 0, 47 ), ドラム入力種別.Tom2 },
158 { new IdKey( 0, 41 ), ドラム入力種別.Tom3 },
159 { new IdKey( 0, 43 ), ドラム入力種別.Tom3 },
160 { new IdKey( 0, 45 ), ドラム入力種別.Tom3 },
161 { new IdKey( 0, 49 ), ドラム入力種別.RightCrash },
162 { new IdKey( 0, 52 ), ドラム入力種別.RightCrash },
163 { new IdKey( 0, 55 ), ドラム入力種別.RightCrash },
164 { new IdKey( 0, 57 ), ドラム入力種別.RightCrash },
165 { new IdKey( 0, 91 ), ドラム入力種別.RightCrash },
166 { new IdKey( 0, 51 ), ドラム入力種別.Ride },
167 { new IdKey( 0, 53 ), ドラム入力種別.Ride },
168 { new IdKey( 0, 59 ), ドラム入力種別.Ride },
169 { new IdKey( 0, 89 ), ドラム入力種別.Ride },
175 #region " IExtensibleDataObject の実装 "
177 private ExtensionDataObject _ExData;
179 public virtual ExtensionDataObject ExtensionData
185 => this._ExData = value;