Exemplo n.º 1
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());
            }
        }
Exemplo n.º 2
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());
            }
        }
Exemplo n.º 3
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);
            }
        }