public void CInput管理初期化(IntPtr hWnd, bool bUseMidiIn) { this.directInput = new DirectInput(); // this.timer = new CTimer( CTimer.E種別.MultiMedia ); this.list入力デバイス = new List <IInputDevice>(10); this.list入力デバイス.Add(new CInputKeyboard(hWnd, directInput)); this.list入力デバイス.Add(new CInputMouse(hWnd, directInput)); foreach (DeviceInstance instance in this.directInput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly)) { this.list入力デバイス.Add(new CInputJoystick(hWnd, instance, directInput)); } if (bUseMidiIn) { this.proc = new CWin32.MidiInProc(this.MidiInCallback); uint nMidiDevices = CWin32.midiInGetNumDevs(); Trace.TraceInformation("MIDI入力デバイス数: {0}", nMidiDevices); for (uint i = 0; i < nMidiDevices; i++) { CInputMIDI item = new CInputMIDI(i); this.list入力デバイス.Add(item); CWin32.MIDIINCAPS lpMidiInCaps = new CWin32.MIDIINCAPS(); uint num3 = CWin32.midiInGetDevCaps(i, ref lpMidiInCaps, (uint)Marshal.SizeOf(lpMidiInCaps)); if (num3 != 0) { Trace.TraceError("MIDI In: Device{0}: midiInDevCaps(): {1:X2}: ", i, num3); } else if ((CWin32.midiInOpen(ref item.hMidiIn, i, this.proc, 0, 0x30000) == 0) && (item.hMidiIn != 0)) { CWin32.midiInStart(item.hMidiIn); Trace.TraceInformation("MIDI In: [{0}] \"{1}\" の入力受付を開始しました。", i, lpMidiInCaps.szPname); } else { Trace.TraceError("MIDI In: [{0}] \"{1}\" の入力受付の開始に失敗しました。", i, lpMidiInCaps.szPname); } } } else { Trace.TraceInformation("DTXVモードのため、MIDI入力は使用しません。"); } }
// コンストラクタ public CInput管理() { // this.timer = new CTimer( CTimer.E種別.MultiMedia ); this.list入力デバイス = new List <IInputDevice>(10); #region [ Enumerate keyboard/mouse: exception is masked if keyboard/mouse is not connected ] CInputKeyboard cinputkeyboard = null; CInputMouse cinputmouse = null; try { cinputkeyboard = new CInputKeyboard(); cinputmouse = new CInputMouse(); } catch { } if (cinputkeyboard != null) { this.list入力デバイス.Add(cinputkeyboard); } if (cinputmouse != null) { this.list入力デバイス.Add(cinputmouse); } #endregion #region [ Enumerate joypad ] try { for (int joynum = 0; joynum < 8; joynum++) //2020.06.28 Mr-Ojii joystickの検出数を返す関数が見つからないので適当に8個で { if (OpenTK.Input.Joystick.GetState(joynum).IsConnected) { this.list入力デバイス.Add(new CInputJoystick(joynum)); } } } catch (Exception e) { Trace.WriteLine(e.ToString()); } #endregion this.proc = new CWin32.MidiInProc(this.MidiInCallback); uint nMidiDevices = CWin32.midiInGetNumDevs(); Trace.TraceInformation("MIDI入力デバイス数: {0}", nMidiDevices); for (uint i = 0; i < nMidiDevices; i++) { CInputMIDI item = new CInputMIDI(i); CWin32.MIDIINCAPS lpMidiInCaps = new CWin32.MIDIINCAPS(); uint num3 = CWin32.midiInGetDevCaps(i, ref lpMidiInCaps, (uint)Marshal.SizeOf(lpMidiInCaps)); if (num3 != 0) { Trace.TraceError("MIDI In: Device{0}: midiInDevCaps(): {1:X2}: ", i, num3); } else { uint ret = CWin32.midiInOpen(ref item.hMidiIn, i, this.proc, IntPtr.Zero, 0x30000); Trace.TraceInformation("midiInOpen()==" + ret); Trace.TraceInformation("item.hMidiIn==" + item.hMidiIn.ToString()); if ((ret == 0) && (item.hMidiIn != IntPtr.Zero)) { CWin32.midiInStart(item.hMidiIn); Trace.TraceInformation("MIDI In: [{0}] \"{1}\" の入力受付を開始しました。", i, lpMidiInCaps.szPname); item.strDeviceName = lpMidiInCaps.szPname; this.list入力デバイス.Add(item); continue; } } Trace.TraceError("MIDI In: [{0}] \"{1}\" の入力受付の開始に失敗しました。", i, lpMidiInCaps.szPname); } }
// コンストラクタ public CInput管理(IntPtr hWnd) { this.directInput = new DirectInput(); // this.timer = new CTimer( CTimer.E種別.MultiMedia ); this.list入力デバイス = new List <IInputDevice>(10); #region [ Enumerate keyboard/mouse: exception is masked if keyboard/mouse is not connected ] CInputKeyboard cinputkeyboard = null; CInputMouse cinputmouse = null; try { cinputkeyboard = new CInputKeyboard(hWnd, directInput); cinputmouse = new CInputMouse(hWnd, directInput); } catch { } if (cinputkeyboard != null) { this.list入力デバイス.Add(cinputkeyboard); } if (cinputmouse != null) { this.list入力デバイス.Add(cinputmouse); } #endregion #region [ Enumerate joypad ] foreach (DeviceInstance instance in this.directInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly)) { this.list入力デバイス.Add(new CInputJoystick(hWnd, instance, directInput)); } #endregion this.proc = new CWin32.MidiInProc(this.MidiInCallback); uint nMidiDevices = CWin32.midiInGetNumDevs(); Trace.TraceInformation("MIDI入力デバイス数: {0}", nMidiDevices); for (uint i = 0; i < nMidiDevices; i++) { CInputMIDI item = new CInputMIDI(i); CWin32.MIDIINCAPS lpMidiInCaps = new CWin32.MIDIINCAPS(); uint num3 = CWin32.midiInGetDevCaps(i, ref lpMidiInCaps, (uint)Marshal.SizeOf(lpMidiInCaps)); if (num3 != 0) { Trace.TraceError("MIDI In: Device{0}: midiInDevCaps(): {1:X2}: ", i, num3); } else { uint ret = CWin32.midiInOpen(ref item.hMidiIn, i, this.proc, IntPtr.Zero, 0x30000); Trace.TraceInformation("midiInOpen()==" + ret); Trace.TraceInformation("item.hMidiIn==" + item.hMidiIn.ToString()); if ((ret == 0) && (item.hMidiIn != IntPtr.Zero)) { CWin32.midiInStart(item.hMidiIn); Trace.TraceInformation("MIDI In: [{0}] \"{1}\" の入力受付を開始しました。", i, lpMidiInCaps.szPname); item.strDeviceName = lpMidiInCaps.szPname; this.list入力デバイス.Add(item); continue; } } Trace.TraceError("MIDI In: [{0}] \"{1}\" の入力受付の開始に失敗しました。", i, lpMidiInCaps.szPname); } }