summaryrefslogtreecommitdiff
path: root/VRCSDK3Worlds/Assets/VRCSDK/SDK3/Runtime/Midi/PortMidi/MidiDeviceInfo.cs
blob: 001816fe3b7bfc1d158b4bc20ed1325dcf926285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Runtime.InteropServices;

namespace PortMidi
{
    public struct MidiDeviceInfo
    {
        PmDeviceInfo info;

        internal MidiDeviceInfo(int id, IntPtr ptr)
        {
            ID = id;
            this.info = (PmDeviceInfo) Marshal.PtrToStructure(ptr, typeof(PmDeviceInfo));
        }

        public int ID { get; set; }

        public string Interface => Marshal.PtrToStringAnsi(info.Interface);

        public string Name => Marshal.PtrToStringAnsi(info.Name);

        public bool IsInput => info.Input != 0;

        public bool IsOutput => info.Output != 0;

        public bool IsOpened => info.Opened != 0;

        public override string ToString()
        {
            return
                $"{Interface} - {Name} ({(IsInput ? (IsOutput ? "I/O" : "Input") : (IsOutput ? "Output" : "N/A"))} {(IsOpened ? "open" : String.Empty)})";
        }
    }
}