示例#1
0
        //		private CTimer timer;

        private void MidiInCallback(IntPtr hMidiIn, uint wMsg, IntPtr dwInstance, IntPtr dwParam1, IntPtr dwParam2)
        {
            int p = (int)dwParam1 & 0xF0;

            if (wMsg != CWin32.MIM_DATA || (p != 0x80 && p != 0x90 && p != 0xB0))
            {
                return;
            }

            long time = CSound管理.rc演奏用タイマ.nシステム時刻ms;              // lock前に取得。演奏用タイマと同じタイマを使うことで、BGMと譜面、入力ずれを防ぐ。

            lock (this.objMidiIn排他用)
            {
                if ((this.list入力デバイス != null) && (this.list入力デバイス.Count != 0))
                {
                    foreach (IInputDevice device in this.list入力デバイス)
                    {
                        CInputMIDI tmidi = device as CInputMIDI;
                        if ((tmidi != null) && (tmidi.hMidiIn == hMidiIn))
                        {
                            tmidi.tメッセージからMIDI信号のみ受信(wMsg, dwInstance, dwParam1, dwParam2, time);
                            break;
                        }
                    }
                }
            }
        }
示例#2
0
        public void Dispose(bool disposeManagedObjects)
        {
            if (!this.bDisposed済み)
            {
                if (disposeManagedObjects)
                {
                    foreach (IInputDevice device in this.list入力デバイス)
                    {
                        CInputMIDI tmidi = device as CInputMIDI;
                        if (tmidi != null)
                        {
                            CWin32.midiInStop(tmidi.hMidiIn);
                            CWin32.midiInReset(tmidi.hMidiIn);
                            CWin32.midiInClose(tmidi.hMidiIn);
                            Trace.TraceInformation("MIDI In: [{0}] を停止しました。", new object[] { tmidi.ID });
                        }
                    }
                    foreach (IInputDevice device2 in this.list入力デバイス)
                    {
                        device2.Dispose();
                    }
                    lock (this.objMidiIn排他用)
                    {
                        this.list入力デバイス.Clear();
                    }

                    //if( this.timer != null )
                    //{
                    //    this.timer.Dispose();
                    //    this.timer = null;
                    //}
                }
                this.bDisposed済み = true;
            }
        }
示例#3
0
        // コンストラクタ
        public CInputManager()
        {
            this.listInputDevices = 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.listInputDevices.Add(cinputkeyboard);
            }
            if (cinputmouse != null)
            {
                this.listInputDevices.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.listInputDevices.Add(new CInputJoystick(joynum));
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
            }
            #endregion

            try
            {
                var midiinlisttmp = MidiAccessManager.Default.Inputs.ToArray();

                for (int i = 0; i < midiinlisttmp.Length; i++)
                {
                    var midiintmp = MidiAccessManager.Default.OpenInputAsync(midiinlisttmp[i].Id).Result;
                    midiintmp.MessageReceived += onMessageRecevied;
                    this.midiInputs.Add(midiintmp);
                    CInputMIDI item = new CInputMIDI(uint.Parse(midiinlisttmp[i].Id));
                    this.listInputDevices.Add(item);
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(e.ToString());
            }
        }
示例#4
0
        // コンストラクタ
        public CInputManager(IntPtr hWnd)
        {
            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

            try
            {
                this.proc = new MIDIINPROC(this.MidiInCallback);
                for (int i = 0; i < BassMidi.BASS_MIDI_InGetDeviceInfos(); i++)
                {
                    BassMidi.BASS_MIDI_InInit(i, this.proc, IntPtr.Zero);
                    BassMidi.BASS_MIDI_InStart(i);
                    CInputMIDI item = new CInputMIDI((uint)i);
                    this.list入力デバイス.Add(item);
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(e.ToString());
            }
        }
示例#5
0
        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入力は使用しません。");
            }
        }
示例#6
0
        //		private CTimer timer;

        private void MidiInCallback(int dev, double intime, IntPtr buffer, int length, IntPtr user)
        {
            long time = CSound管理.rc演奏用タイマ.nシステム時刻ms;              // lock前に取得。演奏用タイマと同じタイマを使うことで、BGMと譜面、入力ずれを防ぐ。

            lock (this.objMidiIn排他用)
            {
                if ((this.list入力デバイス != null) && (this.list入力デバイス.Count != 0))
                {
                    foreach (IInputDevice device in this.list入力デバイス)
                    {
                        CInputMIDI tmidi = device as CInputMIDI;
                        if ((tmidi != null) && (tmidi.ID == dev))
                        {
                            tmidi.tメッセージからMIDI信号のみ受信(dev, time, buffer, length, user);
                            break;
                        }
                    }
                }
            }
        }
示例#7
0
        // コンストラクタ
        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);
            }
        }