--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 10.00\r
+# Visual Studio 2008\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MidiInChecker2", "MidiInChecker2_Project\MidiInChecker2.csproj", "{46AC7786-9431-4C49-B18E-9B6A839B6E5A}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Release|Any CPU = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {46AC7786-9431-4C49-B18E-9B6A839B6E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {46AC7786-9431-4C49-B18E-9B6A839B6E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {46AC7786-9431-4C49-B18E-9B6A839B6E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {46AC7786-9431-4C49-B18E-9B6A839B6E5A}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+namespace MidiInChecker2\r
+{\r
+ partial class Form_Main\r
+ {\r
+ /// <summary>\r
+ /// 必要なデザイナ変数です。\r
+ /// </summary>\r
+ private System.ComponentModel.IContainer components = null;\r
+\r
+ /// <summary>\r
+ /// 使用中のリソースをすべてクリーンアップします。\r
+ /// </summary>\r
+ /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>\r
+ protected override void Dispose( bool disposing )\r
+ {\r
+ if ( disposing && ( components != null ) )\r
+ {\r
+ components.Dispose();\r
+ }\r
+ base.Dispose( disposing );\r
+ }\r
+\r
+ #region Windows フォーム デザイナで生成されたコード\r
+\r
+ /// <summary>\r
+ /// デザイナ サポートに必要なメソッドです。このメソッドの内容を\r
+ /// コード エディタで変更しないでください。\r
+ /// </summary>\r
+ private void InitializeComponent()\r
+ {\r
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager( typeof( Form_Main ) );\r
+ this.LogTextBox = new System.Windows.Forms.TextBox();\r
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();\r
+ this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
+ this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();\r
+ this.buttonOK = new System.Windows.Forms.Button();\r
+ this.menuStrip1.SuspendLayout();\r
+ this.SuspendLayout();\r
+ // \r
+ // LogTextBox\r
+ // \r
+ resources.ApplyResources( this.LogTextBox, "LogTextBox" );\r
+ this.LogTextBox.Name = "LogTextBox";\r
+ this.LogTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler( this.LogTextBox_KeyDown );\r
+ // \r
+ // menuStrip1\r
+ // \r
+ this.menuStrip1.Items.AddRange( new System.Windows.Forms.ToolStripItem[] {\r
+ this.exitToolStripMenuItem} );\r
+ resources.ApplyResources( this.menuStrip1, "menuStrip1" );\r
+ this.menuStrip1.Name = "menuStrip1";\r
+ // \r
+ // exitToolStripMenuItem\r
+ // \r
+ this.exitToolStripMenuItem.DropDownItems.AddRange( new System.Windows.Forms.ToolStripItem[] {\r
+ this.exitToolStripMenuItem1} );\r
+ this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";\r
+ resources.ApplyResources( this.exitToolStripMenuItem, "exitToolStripMenuItem" );\r
+ // \r
+ // exitToolStripMenuItem1\r
+ // \r
+ this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1";\r
+ resources.ApplyResources( this.exitToolStripMenuItem1, "exitToolStripMenuItem1" );\r
+ this.exitToolStripMenuItem1.Click += new System.EventHandler( this.exitToolStripMenuItem1_Click );\r
+ // \r
+ // buttonOK\r
+ // \r
+ resources.ApplyResources( this.buttonOK, "buttonOK" );\r
+ this.buttonOK.Name = "buttonOK";\r
+ this.buttonOK.UseVisualStyleBackColor = true;\r
+ this.buttonOK.Click += new System.EventHandler( this.button1_Click );\r
+ // \r
+ // Form_Main\r
+ // \r
+ resources.ApplyResources( this, "$this" );\r
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
+ this.Controls.Add( this.buttonOK );\r
+ this.Controls.Add( this.menuStrip1 );\r
+ this.Controls.Add( this.LogTextBox );\r
+ this.MainMenuStrip = this.menuStrip1;\r
+ this.Name = "Form_Main";\r
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler( this.Form_Main_FormClosing );\r
+ this.menuStrip1.ResumeLayout( false );\r
+ this.menuStrip1.PerformLayout();\r
+ this.ResumeLayout( false );\r
+ this.PerformLayout();\r
+\r
+ }\r
+\r
+ #endregion\r
+\r
+ private System.Windows.Forms.TextBox LogTextBox;\r
+ private System.Windows.Forms.MenuStrip menuStrip1;\r
+ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;\r
+ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1;\r
+ private System.Windows.Forms.Button buttonOK;\r
+ }\r
+}\r
+\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.ComponentModel;\r
+using System.Data;\r
+using System.Drawing;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Windows.Forms;\r
+using System.Diagnostics;\r
+using System.Threading;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ public partial class Form_Main : Form\r
+ {\r
+ CInputManager InputManager;\r
+ System.Threading.Timer timer;\r
+ object lockobj = new object();\r
+\r
+ public Form_Main()\r
+ {\r
+ InitializeComponent();\r
+ InputManager = new CInputManager();\r
+\r
+ LogTextBox.AppendText( "Number of MIDI devices: " + InputManager.nInputMidiDevices + "\r\n" );\r
+ foreach ( string s in InputManager.listStrMidiDevices )\r
+ {\r
+ LogTextBox.AppendText( s + "\r\n" );\r
+ }\r
+ LogTextBox.AppendText( "\r\nHit any MIDI Pad to show the signal info.\r\n\r\n\n" );\r
+\r
+ #region [タイマーで0.1秒ごとにログ画面を更新するように初期化する]\r
+ TimerCallback timerDelegate = new TimerCallback(mainloop);\r
+ timer = new System.Threading.Timer(timerDelegate, null , 0, 100);\r
+ #endregion\r
+ }\r
+\r
+\r
+ private void mainloop( object o )\r
+ {\r
+ lock ( lockobj )\r
+ {\r
+ InputManager.tポーリング( true, true );\r
+ List<STInputEvent> list = new List<STInputEvent>();\r
+\r
+ // すべての入力デバイスについて…\r
+ foreach ( IInputDevice device in InputManager.list入力デバイス )\r
+ {\r
+ if ( ( device.list入力イベント != null ) && ( device.list入力イベント.Count != 0 ) && ( device.e入力デバイス種別 == E入力デバイス種別.MidiIn ) )\r
+ {\r
+ foreach ( STInputEvent ev in device.list入力イベント )\r
+ {\r
+ int nMIDIevent = ev.nKey & 0xF0;\r
+ int nNote = ( ev.nKey >> 8 ) & 0xFF; // note#\r
+ // int nVelo = ( ev.nKey >> 16 ) & 0xFF; // velocity\r
+\r
+ string s = DateTime.Now.ToString( "hh:mm:ss.fff" ) +\r
+ ": Device=" + device.ID +\r
+ ", MIDIevent=0x" + nMIDIevent.ToString( "X2" ) +\r
+ ", Note#=0x" + nNote.ToString( "X2" ) +\r
+ ", Velocity=" + ev.nVelocity.ToString( "D3" ) +\r
+\r
+ "\r\n";\r
+ Invoke( new AppendTextDelegate( appendLogText ), s );\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ delegate void AppendTextDelegate( string text );\r
+ private void appendLogText( string text )\r
+ {\r
+ LogTextBox.AppendText( text );\r
+ }\r
+\r
+ // ダサい。後日改善予定。\r
+ private void Form_Main_FormClosing( object sender, FormClosingEventArgs e )\r
+ {\r
+ // mainloop処理中なら、待つ\r
+ lock ( lockobj )\r
+ { };\r
+\r
+ // mainloop処理中でないことを確認して、(mainloopを呼び出している)timerを止める\r
+ timer.Dispose();\r
+\r
+ // timerを止めてmainloop処理が発生しないことを担保してから、InputMangerを開放する\r
+ InputManager.Dispose();\r
+ InputManager = null;\r
+ }\r
+\r
+ private void button1_Click( object sender, EventArgs e )\r
+ {\r
+ Application.Exit();\r
+ }\r
+\r
+ private void exitToolStripMenuItem1_Click( object sender, EventArgs e )\r
+ {\r
+ Application.Exit();\r
+ }\r
+\r
+ /// <summary>\r
+ /// textboxで、Ctrl-Aでの全選択ができるようにする\r
+ /// </summary>\r
+ /// <param name="sender"></param>\r
+ /// <param name="e"></param>\r
+ private void LogTextBox_KeyDown( object sender, KeyEventArgs e )\r
+ {\r
+ if ( e.KeyCode == System.Windows.Forms.Keys.A & e.Control == true )\r
+ {\r
+ LogTextBox.SelectAll();\r
+ } \r
+ }\r
+ }\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+ <!-- \r
+ Microsoft ResX Schema \r
+ \r
+ Version 2.0\r
+ \r
+ The primary goals of this format is to allow a simple XML format \r
+ that is mostly human readable. The generation and parsing of the \r
+ various data types are done through the TypeConverter classes \r
+ associated with the data types.\r
+ \r
+ Example:\r
+ \r
+ ... ado.net/XML headers & schema ...\r
+ <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+ <resheader name="version">2.0</resheader>\r
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+ <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+ </data>\r
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+ <comment>This is a comment</comment>\r
+ </data>\r
+ \r
+ There are any number of "resheader" rows that contain simple \r
+ name/value pairs.\r
+ \r
+ Each data row contains a name, and value. The row also contains a \r
+ type or mimetype. Type corresponds to a .NET class that support \r
+ text/value conversion through the TypeConverter architecture. \r
+ Classes that don't support this are serialized and stored with the \r
+ mimetype set.\r
+ \r
+ The mimetype is used for serialized objects, and tells the \r
+ ResXResourceReader how to depersist the object. This is currently not \r
+ extensible. For a given mimetype the value must be set accordingly:\r
+ \r
+ Note - application/x-microsoft.net.object.binary.base64 is the format \r
+ that the ResXResourceWriter will generate, however the reader can \r
+ read any of the formats listed below.\r
+ \r
+ mimetype: application/x-microsoft.net.object.binary.base64\r
+ value : The object must be serialized with \r
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+ : and then encoded with base64 encoding.\r
+ \r
+ mimetype: application/x-microsoft.net.object.soap.base64\r
+ value : The object must be serialized with \r
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+ : and then encoded with base64 encoding.\r
+\r
+ mimetype: application/x-microsoft.net.object.bytearray.base64\r
+ value : The object must be serialized into a byte array \r
+ : using a System.ComponentModel.TypeConverter\r
+ : and then encoded with base64 encoding.\r
+ -->\r
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+ <xsd:element name="root" msdata:IsDataSet="true">\r
+ <xsd:complexType>\r
+ <xsd:choice maxOccurs="unbounded">\r
+ <xsd:element name="metadata">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+ </xsd:sequence>\r
+ <xsd:attribute name="name" use="required" type="xsd:string" />\r
+ <xsd:attribute name="type" type="xsd:string" />\r
+ <xsd:attribute name="mimetype" type="xsd:string" />\r
+ <xsd:attribute ref="xml:space" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ <xsd:element name="assembly">\r
+ <xsd:complexType>\r
+ <xsd:attribute name="alias" type="xsd:string" />\r
+ <xsd:attribute name="name" type="xsd:string" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ <xsd:element name="data">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+ </xsd:sequence>\r
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+ <xsd:attribute ref="xml:space" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ <xsd:element name="resheader">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+ </xsd:sequence>\r
+ <xsd:attribute name="name" type="xsd:string" use="required" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ </xsd:choice>\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ </xsd:schema>\r
+ <resheader name="resmimetype">\r
+ <value>text/microsoft-resx</value>\r
+ </resheader>\r
+ <resheader name="version">\r
+ <value>2.0</value>\r
+ </resheader>\r
+ <resheader name="reader">\r
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </resheader>\r
+ <resheader name="writer">\r
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </resheader>\r
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />\r
+ <data name="LogTextBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">\r
+ <value>Top, Bottom, Left, Right</value>\r
+ </data>\r
+ <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />\r
+ <data name="LogTextBox.Location" type="System.Drawing.Point, System.Drawing">\r
+ <value>13, 29</value>\r
+ </data>\r
+ <assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />\r
+ <data name="LogTextBox.Multiline" type="System.Boolean, mscorlib">\r
+ <value>True</value>\r
+ </data>\r
+ <data name="LogTextBox.ScrollBars" type="System.Windows.Forms.ScrollBars, System.Windows.Forms">\r
+ <value>Both</value>\r
+ </data>\r
+ <data name="LogTextBox.Size" type="System.Drawing.Size, System.Drawing">\r
+ <value>473, 335</value>\r
+ </data>\r
+ <data name="LogTextBox.TabIndex" type="System.Int32, mscorlib">\r
+ <value>0</value>\r
+ </data>\r
+ <data name=">>LogTextBox.Name" xml:space="preserve">\r
+ <value>LogTextBox</value>\r
+ </data>\r
+ <data name=">>LogTextBox.Type" xml:space="preserve">\r
+ <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </data>\r
+ <data name=">>LogTextBox.Parent" xml:space="preserve">\r
+ <value>$this</value>\r
+ </data>\r
+ <data name=">>LogTextBox.ZOrder" xml:space="preserve">\r
+ <value>2</value>\r
+ </data>\r
+ <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+ <value>0, 0</value>\r
+ </metadata>\r
+ <data name="exitToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">\r
+ <value>152, 22</value>\r
+ </data>\r
+ <data name="exitToolStripMenuItem1.Text" xml:space="preserve">\r
+ <value>E&xit</value>\r
+ </data>\r
+ <data name="exitToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">\r
+ <value>40, 22</value>\r
+ </data>\r
+ <data name="exitToolStripMenuItem.Text" xml:space="preserve">\r
+ <value>&File</value>\r
+ </data>\r
+ <data name="menuStrip1.Location" type="System.Drawing.Point, System.Drawing">\r
+ <value>0, 0</value>\r
+ </data>\r
+ <data name="menuStrip1.Size" type="System.Drawing.Size, System.Drawing">\r
+ <value>486, 26</value>\r
+ </data>\r
+ <data name="menuStrip1.TabIndex" type="System.Int32, mscorlib">\r
+ <value>2</value>\r
+ </data>\r
+ <data name="menuStrip1.Text" xml:space="preserve">\r
+ <value>menuStrip1</value>\r
+ </data>\r
+ <data name=">>menuStrip1.Name" xml:space="preserve">\r
+ <value>menuStrip1</value>\r
+ </data>\r
+ <data name=">>menuStrip1.Type" xml:space="preserve">\r
+ <value>System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </data>\r
+ <data name=">>menuStrip1.Parent" xml:space="preserve">\r
+ <value>$this</value>\r
+ </data>\r
+ <data name=">>menuStrip1.ZOrder" xml:space="preserve">\r
+ <value>1</value>\r
+ </data>\r
+ <data name="buttonOK.Location" type="System.Drawing.Point, System.Drawing">\r
+ <value>399, 370</value>\r
+ </data>\r
+ <data name="buttonOK.Size" type="System.Drawing.Size, System.Drawing">\r
+ <value>75, 23</value>\r
+ </data>\r
+ <data name="buttonOK.TabIndex" type="System.Int32, mscorlib">\r
+ <value>3</value>\r
+ </data>\r
+ <data name="buttonOK.Text" xml:space="preserve">\r
+ <value>OK</value>\r
+ </data>\r
+ <data name=">>buttonOK.Name" xml:space="preserve">\r
+ <value>buttonOK</value>\r
+ </data>\r
+ <data name=">>buttonOK.Type" xml:space="preserve">\r
+ <value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </data>\r
+ <data name=">>buttonOK.Parent" xml:space="preserve">\r
+ <value>$this</value>\r
+ </data>\r
+ <data name=">>buttonOK.ZOrder" xml:space="preserve">\r
+ <value>0</value>\r
+ </data>\r
+ <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+ <value>True</value>\r
+ </metadata>\r
+ <data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">\r
+ <value>6, 12</value>\r
+ </data>\r
+ <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">\r
+ <value>486, 405</value>\r
+ </data>\r
+ <data name="$this.Text" xml:space="preserve">\r
+ <value>MidiInChecker2</value>\r
+ </data>\r
+ <data name=">>exitToolStripMenuItem.Name" xml:space="preserve">\r
+ <value>exitToolStripMenuItem</value>\r
+ </data>\r
+ <data name=">>exitToolStripMenuItem.Type" xml:space="preserve">\r
+ <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </data>\r
+ <data name=">>exitToolStripMenuItem1.Name" xml:space="preserve">\r
+ <value>exitToolStripMenuItem1</value>\r
+ </data>\r
+ <data name=">>exitToolStripMenuItem1.Type" xml:space="preserve">\r
+ <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </data>\r
+ <data name=">>$this.Name" xml:space="preserve">\r
+ <value>Form_Main</value>\r
+ </data>\r
+ <data name=">>$this.Type" xml:space="preserve">\r
+ <value>System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </data>\r
+</root>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProductVersion>9.0.30729</ProductVersion>\r
+ <SchemaVersion>2.0</SchemaVersion>\r
+ <ProjectGuid>{46AC7786-9431-4C49-B18E-9B6A839B6E5A}</ProjectGuid>\r
+ <OutputType>WinExe</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>MidiInChecker2</RootNamespace>\r
+ <AssemblyName>MidiInChecker2_Project</AssemblyName>\r
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
+ <FileAlignment>512</FileAlignment>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release\</OutputPath>\r
+ <DefineConstants>TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Reference Include="System" />\r
+ <Reference Include="System.Core">\r
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+ </Reference>\r
+ <Reference Include="System.Xml.Linq">\r
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+ </Reference>\r
+ <Reference Include="System.Data.DataSetExtensions">\r
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+ </Reference>\r
+ <Reference Include="System.Data" />\r
+ <Reference Include="System.Deployment" />\r
+ <Reference Include="System.Drawing" />\r
+ <Reference Include="System.Windows.Forms" />\r
+ <Reference Include="System.Xml" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="PsuedoFDK\CInputManager.cs" />\r
+ <Compile Include="PsuedoFDK\CInputMidi.cs" />\r
+ <Compile Include="PsuedoFDK\CWin32.cs" />\r
+ <Compile Include="Form_Main.cs">\r
+ <SubType>Form</SubType>\r
+ </Compile>\r
+ <Compile Include="Form_Main.Designer.cs">\r
+ <DependentUpon>Form_Main.cs</DependentUpon>\r
+ </Compile>\r
+ <Compile Include="Program.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <EmbeddedResource Include="Form_Main.resx">\r
+ <DependentUpon>Form_Main.cs</DependentUpon>\r
+ </EmbeddedResource>\r
+ <EmbeddedResource Include="Properties\Resources.resx">\r
+ <Generator>ResXFileCodeGenerator</Generator>\r
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r
+ <SubType>Designer</SubType>\r
+ </EmbeddedResource>\r
+ <Compile Include="Properties\Resources.Designer.cs">\r
+ <AutoGen>True</AutoGen>\r
+ <DependentUpon>Resources.resx</DependentUpon>\r
+ <DesignTime>True</DesignTime>\r
+ </Compile>\r
+ <None Include="Properties\Settings.settings">\r
+ <Generator>SettingsSingleFileGenerator</Generator>\r
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>\r
+ </None>\r
+ <Compile Include="Properties\Settings.Designer.cs">\r
+ <AutoGen>True</AutoGen>\r
+ <DependentUpon>Settings.settings</DependentUpon>\r
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>\r
+ </Compile>\r
+ <Compile Include="PsuedoFDK\EInputDeviceType.cs" />\r
+ <Compile Include="PsuedoFDK\IInputDevice.cs" />\r
+ <Compile Include="PsuedoFDK\STInputEvent.cs" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+ Other similar extension points exist, see Microsoft.Common.targets.\r
+ <Target Name="BeforeBuild">\r
+ </Target>\r
+ <Target Name="AfterBuild">\r
+ </Target>\r
+ -->\r
+</Project>
\ No newline at end of file
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Windows.Forms;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ static class Program\r
+ {\r
+ /// <summary>\r
+ /// アプリケーションのメイン エントリ ポイントです。\r
+ /// </summary>\r
+ [STAThread]\r
+ static void Main()\r
+ {\r
+ Application.EnableVisualStyles();\r
+ Application.SetCompatibleTextRenderingDefault( false );\r
+ Application.Run( new Form_Main() );\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。\r
+// アセンブリに関連付けられている情報を変更するには、\r
+// これらの属性値を変更してください。\r
+[assembly: AssemblyTitle( "MidiInChecker2_Project" )]\r
+[assembly: AssemblyDescription( "" )]\r
+[assembly: AssemblyConfiguration( "" )]\r
+[assembly: AssemblyCompany( "" )]\r
+[assembly: AssemblyProduct( "MidiInChecker2_Project" )]\r
+[assembly: AssemblyCopyright( "Copyright © 2012" )]\r
+[assembly: AssemblyTrademark( "" )]\r
+[assembly: AssemblyCulture( "" )]\r
+\r
+// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから \r
+// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、\r
+// その型の ComVisible 属性を true に設定してください。\r
+[assembly: ComVisible( false )]\r
+\r
+// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です\r
+[assembly: Guid( "2cc8f17a-e5e3-41ee-b138-0284782415c3" )]\r
+\r
+// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:\r
+//\r
+// Major Version\r
+// Minor Version \r
+// Build Number\r
+// Revision\r
+//\r
+// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を \r
+// 既定値にすることができます:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion( "1.0.0.0" )]\r
+[assembly: AssemblyFileVersion( "1.0.0.0" )]\r
--- /dev/null
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+// このコードはツールによって生成されました。\r
+// ランタイム バージョン:2.0.50727.5466\r
+//\r
+// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、\r
+// コードが再生成されるときに損失したりします。\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace MidiInChecker2.Properties {\r
+ using System;\r
+ \r
+ \r
+ /// <summary>\r
+ /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。\r
+ /// </summary>\r
+ // このクラスは StronglyTypedResourceBuilder クラスが ResGen\r
+ // または Visual Studio のようなツールを使用して自動生成されました。\r
+ // メンバを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に\r
+ // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。\r
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]\r
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r
+ internal class Resources {\r
+ \r
+ private static global::System.Resources.ResourceManager resourceMan;\r
+ \r
+ private static global::System.Globalization.CultureInfo resourceCulture;\r
+ \r
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]\r
+ internal Resources() {\r
+ }\r
+ \r
+ /// <summary>\r
+ /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。\r
+ /// </summary>\r
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r
+ internal static global::System.Resources.ResourceManager ResourceManager {\r
+ get {\r
+ if (object.ReferenceEquals(resourceMan, null)) {\r
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MidiInChecker2.Properties.Resources", typeof(Resources).Assembly);\r
+ resourceMan = temp;\r
+ }\r
+ return resourceMan;\r
+ }\r
+ }\r
+ \r
+ /// <summary>\r
+ /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、\r
+ /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。\r
+ /// </summary>\r
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r
+ internal static global::System.Globalization.CultureInfo Culture {\r
+ get {\r
+ return resourceCulture;\r
+ }\r
+ set {\r
+ resourceCulture = value;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+ <!-- \r
+ Microsoft ResX Schema \r
+ \r
+ Version 2.0\r
+ \r
+ The primary goals of this format is to allow a simple XML format \r
+ that is mostly human readable. The generation and parsing of the \r
+ various data types are done through the TypeConverter classes \r
+ associated with the data types.\r
+ \r
+ Example:\r
+ \r
+ ... ado.net/XML headers & schema ...\r
+ <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+ <resheader name="version">2.0</resheader>\r
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+ <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+ </data>\r
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+ <comment>This is a comment</comment>\r
+ </data>\r
+ \r
+ There are any number of "resheader" rows that contain simple \r
+ name/value pairs.\r
+ \r
+ Each data row contains a name, and value. The row also contains a \r
+ type or mimetype. Type corresponds to a .NET class that support \r
+ text/value conversion through the TypeConverter architecture. \r
+ Classes that don't support this are serialized and stored with the \r
+ mimetype set.\r
+ \r
+ The mimetype is used for serialized objects, and tells the \r
+ ResXResourceReader how to depersist the object. This is currently not \r
+ extensible. For a given mimetype the value must be set accordingly:\r
+ \r
+ Note - application/x-microsoft.net.object.binary.base64 is the format \r
+ that the ResXResourceWriter will generate, however the reader can \r
+ read any of the formats listed below.\r
+ \r
+ mimetype: application/x-microsoft.net.object.binary.base64\r
+ value : The object must be serialized with \r
+ : System.Serialization.Formatters.Binary.BinaryFormatter\r
+ : and then encoded with base64 encoding.\r
+ \r
+ mimetype: application/x-microsoft.net.object.soap.base64\r
+ value : The object must be serialized with \r
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+ : and then encoded with base64 encoding.\r
+\r
+ mimetype: application/x-microsoft.net.object.bytearray.base64\r
+ value : The object must be serialized into a byte array \r
+ : using a System.ComponentModel.TypeConverter\r
+ : and then encoded with base64 encoding.\r
+ -->\r
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+ <xsd:element name="root" msdata:IsDataSet="true">\r
+ <xsd:complexType>\r
+ <xsd:choice maxOccurs="unbounded">\r
+ <xsd:element name="metadata">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+ </xsd:sequence>\r
+ <xsd:attribute name="name" type="xsd:string" />\r
+ <xsd:attribute name="type" type="xsd:string" />\r
+ <xsd:attribute name="mimetype" type="xsd:string" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ <xsd:element name="assembly">\r
+ <xsd:complexType>\r
+ <xsd:attribute name="alias" type="xsd:string" />\r
+ <xsd:attribute name="name" type="xsd:string" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ <xsd:element name="data">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+ </xsd:sequence>\r
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />\r
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ <xsd:element name="resheader">\r
+ <xsd:complexType>\r
+ <xsd:sequence>\r
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+ </xsd:sequence>\r
+ <xsd:attribute name="name" type="xsd:string" use="required" />\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ </xsd:choice>\r
+ </xsd:complexType>\r
+ </xsd:element>\r
+ </xsd:schema>\r
+ <resheader name="resmimetype">\r
+ <value>text/microsoft-resx</value>\r
+ </resheader>\r
+ <resheader name="version">\r
+ <value>2.0</value>\r
+ </resheader>\r
+ <resheader name="reader">\r
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </resheader>\r
+ <resheader name="writer">\r
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+ </resheader>\r
+</root>
\ No newline at end of file
--- /dev/null
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+// このコードはツールによって生成されました。\r
+// ランタイム バージョン:2.0.50727.5466\r
+//\r
+// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、\r
+// コードが再生成されるときに損失したりします。\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace MidiInChecker2.Properties {\r
+ \r
+ \r
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]\r
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {\r
+ \r
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));\r
+ \r
+ public static Settings Default {\r
+ get {\r
+ return defaultInstance;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>\r
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">\r
+ <Profiles>\r
+ <Profile Name="(Default)" />\r
+ </Profiles>\r
+ <Settings />\r
+</SettingsFile>\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Diagnostics;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ public class CInputManager : IDisposable\r
+ {\r
+ // 定数\r
+\r
+ public static int n通常音量 = 110;\r
+\r
+\r
+ // プロパティ\r
+\r
+ public List<IInputDevice> list入力デバイス\r
+ {\r
+ get;\r
+ private set;\r
+ }\r
+\r
+ public uint nInputMidiDevices;\r
+ public List<string> listStrMidiDevices;\r
+\r
+ // コンストラクタ\r
+\r
+ //public CInputManager( IntPtr hWnd )\r
+ public CInputManager()\r
+ {\r
+ //this.directInput = new DirectInput();\r
+ //this.timer = new CTimer( CTimer.E種別.MultiMedia );\r
+\r
+ this.list入力デバイス = new List<IInputDevice>( 10 );\r
+ this.listStrMidiDevices = new List<string>();\r
+\r
+ //this.list入力デバイス.Add( new CInputKeyboard( hWnd, directInput ) );\r
+ //this.list入力デバイス.Add( new CInputMouse( hWnd, directInput ) );\r
+ //foreach ( DeviceInstance instance in this.directInput.GetDevices( DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly ) )\r
+ //{\r
+ // this.list入力デバイス.Add( new CInputJoystick( hWnd, instance, directInput ) );\r
+ //}\r
+ this.proc = new CWin32.MidiInProc( this.MidiInCallback );\r
+ nInputMidiDevices = CWin32.midiInGetNumDevs();\r
+ Trace.TraceInformation( "MIDI入力デバイス数: {0}", nInputMidiDevices );\r
+ for ( uint i = 0; i < nInputMidiDevices; i++ )\r
+ {\r
+ CInputMIDI item = new CInputMIDI( i );\r
+ this.list入力デバイス.Add( item );\r
+ CWin32.MIDIINCAPS lpMidiInCaps = new CWin32.MIDIINCAPS();\r
+ uint retcode = CWin32.midiInGetDevCaps( i, ref lpMidiInCaps, (uint) Marshal.SizeOf( lpMidiInCaps ) );\r
+ if ( retcode != 0 )\r
+ {\r
+ Trace.TraceError( "MIDI In: Device{0}: midiInDevCaps(): {1:X2}: ", i, retcode );\r
+ }\r
+ else if ( ( CWin32.midiInOpen( ref item.hMidiIn, i, this.proc, 0, 0x30000 ) == 0 ) && ( item.hMidiIn != 0 ) )\r
+ {\r
+ CWin32.midiInStart( item.hMidiIn );\r
+ Trace.TraceInformation( "MIDI In: [{0}] \"{1}\" の入力受付を開始しました。", i, lpMidiInCaps.szPname );\r
+ this.listStrMidiDevices.Add( "MIDI In [" + i + "] = " + lpMidiInCaps.szPname );\r
+ }\r
+ else\r
+ {\r
+ Trace.TraceError( "MIDI In: [{0}] \"{1}\" の入力受付の開始に失敗しました。", i, lpMidiInCaps.szPname );\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ // メソッド\r
+\r
+ //public IInputDevice Joystick( int ID )\r
+ //{\r
+ // foreach ( IInputDevice device in this.list入力デバイス )\r
+ // {\r
+ // if ( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && ( device.ID == ID ) )\r
+ // {\r
+ // return device;\r
+ // }\r
+ // }\r
+ // return null;\r
+ //}\r
+ //public IInputDevice Joystick( string GUID )\r
+ //{\r
+ // foreach ( IInputDevice device in this.list入力デバイス )\r
+ // {\r
+ // if ( ( device.e入力デバイス種別 == E入力デバイス種別.Joystick ) && device.GUID.Equals( GUID ) )\r
+ // {\r
+ // return device;\r
+ // }\r
+ // }\r
+ // return null;\r
+ //}\r
+ public IInputDevice MidiIn( int ID )\r
+ {\r
+ foreach ( IInputDevice device in this.list入力デバイス )\r
+ {\r
+ if ( ( device.e入力デバイス種別 == E入力デバイス種別.MidiIn ) && ( device.ID == ID ) )\r
+ {\r
+ return device;\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ public void tポーリング( bool bWindowがアクティブ中, bool bバッファ入力を使用する )\r
+ {\r
+ lock ( this.objMidiIn排他用 )\r
+ {\r
+ // foreach( IInputDevice device in this.list入力デバイス )\r
+ for ( int i = this.list入力デバイス.Count - 1; i >= 0; i-- ) // #24016 2011.1.6 yyagi: change not to use "foreach" to avoid InvalidOperation exception by Remove().\r
+ {\r
+ IInputDevice device = this.list入力デバイス[ i ];\r
+ try\r
+ {\r
+ device.tポーリング( bWindowがアクティブ中, bバッファ入力を使用する );\r
+ }\r
+ // catch ( DirectInputException ) // #24016 2011.1.6 yyagi: catch exception for unplugging USB joystick, and remove the device object from the polling items.\r
+ catch ( Exception e ) // #24016 2011.1.6 yyagi: catch exception for unplugging USB joystick, and remove the device object from the polling items.\r
+ {\r
+ this.list入力デバイス.Remove( device );\r
+ device.Dispose();\r
+ Trace.TraceError( "tポーリング時に対象deviceが抜かれており例外発生。同deviceをポーリング対象からRemoveしました。" );\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ #region [ IDisposable+α ]\r
+ //-----------------\r
+ public void Dispose()\r
+ {\r
+ this.Dispose( true );\r
+ }\r
+ public void Dispose( bool disposeManagedObjects )\r
+ {\r
+ if ( !this.bDisposed済み )\r
+ {\r
+ if ( disposeManagedObjects )\r
+ {\r
+ foreach ( IInputDevice device in this.list入力デバイス )\r
+ {\r
+ CInputMIDI tmidi = device as CInputMIDI;\r
+ if ( tmidi != null )\r
+ {\r
+ CWin32.midiInStop( tmidi.hMidiIn );\r
+ CWin32.midiInReset( tmidi.hMidiIn );\r
+ CWin32.midiInClose( tmidi.hMidiIn );\r
+ Trace.TraceInformation( "MIDI In: [{0}] を停止しました。", tmidi.ID );\r
+ }\r
+ }\r
+ foreach ( IInputDevice device2 in this.list入力デバイス )\r
+ {\r
+ device2.Dispose();\r
+ }\r
+ lock ( this.objMidiIn排他用 )\r
+ {\r
+ this.list入力デバイス.Clear();\r
+ }\r
+\r
+ //this.directInput.Dispose();\r
+\r
+ //if ( this.timer != null )\r
+ //{\r
+ // this.timer.Dispose();\r
+ // this.timer = null;\r
+ //}\r
+ }\r
+ this.bDisposed済み = true;\r
+ }\r
+ }\r
+ ~CInputManager()\r
+ {\r
+ this.Dispose( false );\r
+ GC.KeepAlive( this );\r
+ }\r
+ //-----------------\r
+ #endregion\r
+\r
+\r
+ // その他\r
+\r
+ #region [ private ]\r
+ //-----------------\r
+ //private DirectInput directInput;\r
+ //private IInputDevice _Keyboard;\r
+ //private IInputDevice _Mouse;\r
+ private bool bDisposed済み;\r
+ private List<uint> listHMIDIIN = new List<uint>( 8 );\r
+ private object objMidiIn排他用 = new object();\r
+ private CWin32.MidiInProc proc;\r
+ //private CTimer timer;\r
+\r
+ private void MidiInCallback( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 )\r
+ {\r
+ int p = dwParam1 & 0xF0;\r
+ if ( wMsg != CWin32.MIM_DATA || ( p != 0x80 && p != 0x90 ) )\r
+ return;\r
+\r
+ //long time = this.timer.nシステム時刻; // lock前に取得\r
+ long time = System.DateTime.Now.Ticks; // lock前に取得\r
+\r
+ lock ( this.objMidiIn排他用 )\r
+ {\r
+ if ( ( this.list入力デバイス != null ) && ( this.list入力デバイス.Count != 0 ) )\r
+ {\r
+ foreach ( IInputDevice device in this.list入力デバイス )\r
+ {\r
+ CInputMIDI tmidi = device as CInputMIDI;\r
+ if ( ( tmidi != null ) && ( tmidi.hMidiIn == hMidiIn ) )\r
+ {\r
+ tmidi.tメッセージからMIDI信号のみ受信( wMsg, dwInstance, dwParam1, dwParam2, time );\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ //-----------------\r
+ #endregion\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Diagnostics;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ public class CInputMIDI : IInputDevice, IDisposable\r
+ {\r
+ // プロパティ\r
+\r
+ public uint hMidiIn;\r
+ public List<STInputEvent> listEventBuffer;\r
+\r
+\r
+ // コンストラクタ\r
+\r
+ public CInputMIDI( uint nID )\r
+ {\r
+ this.hMidiIn = 0;\r
+ this.listEventBuffer = new List<STInputEvent>( 32 );\r
+ this.list入力イベント = new List<STInputEvent>( 32 );\r
+ this.e入力デバイス種別 = E入力デバイス種別.MidiIn;\r
+ this.GUID = "";\r
+ this.ID = (int) nID;\r
+ }\r
+\r
+\r
+ // メソッド\r
+\r
+ public void tメッセージからMIDI信号のみ受信( uint wMsg, int dwInstance, int dwParam1, int dwParam2, long n受信システム時刻 )\r
+ {\r
+ if ( wMsg == CWin32.MIM_DATA )\r
+ {\r
+ int nMIDIevent = dwParam1 & 0xF0;\r
+ int nPara1 = ( dwParam1 >> 8 ) & 0xFF;\r
+ int nPara2 = ( dwParam1 >> 16 ) & 0xFF;\r
+\r
+ // Trace.TraceInformation( "MIDIevent={0:X2} para1={1:X2} para2={2:X2}", nMIDIevent, nPara1, nPara2 );\r
+\r
+// if ( ( nMIDIevent == 0x90 ) && ( nPara2 != 0 ) )\r
+ {\r
+ STInputEvent item = new STInputEvent();\r
+ // item.nKey = nPara1;\r
+ item.nKey = dwParam1;\r
+ item.b押された = true;\r
+ item.nTimeStamp = n受信システム時刻;\r
+ item.nVelocity = nPara2;\r
+ this.listEventBuffer.Add( item );\r
+ }\r
+ }\r
+ }\r
+\r
+ #region [ IInputDevice 実装 ]\r
+ //-----------------\r
+ public E入力デバイス種別 e入力デバイス種別 { get; private set; }\r
+ public string GUID { get; private set; }\r
+ public int ID { get; private set; }\r
+ public List<STInputEvent> list入力イベント { get; private set; }\r
+\r
+ public void tポーリング( bool bWindowがアクティブ中, bool bバッファ入力を使用する )\r
+ {\r
+ // this.list入力イベント = new List<STInputEvent>( 32 );\r
+ this.list入力イベント.Clear(); // #xxxxx 2012.6.11 yyagi; To optimize, I removed new();\r
+\r
+ for ( int i = 0; i < this.listEventBuffer.Count; i++ )\r
+ this.list入力イベント.Add( this.listEventBuffer[ i ] );\r
+\r
+ this.listEventBuffer.Clear();\r
+ }\r
+ public bool bキーが押された( int nKey )\r
+ {\r
+ foreach ( STInputEvent event2 in this.list入力イベント )\r
+ {\r
+ if ( ( event2.nKey == nKey ) && event2.b押された )\r
+ {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ public bool bキーが押されている( int nKey )\r
+ {\r
+ return false;\r
+ }\r
+ public bool bキーが離された( int nKey )\r
+ {\r
+ return false;\r
+ }\r
+ public bool bキーが離されている( int nKey )\r
+ {\r
+ return false;\r
+ }\r
+ //-----------------\r
+ #endregion\r
+\r
+ #region [ IDisposable 実装 ]\r
+ //-----------------\r
+ public void Dispose()\r
+ {\r
+ if ( this.listEventBuffer != null )\r
+ {\r
+ this.listEventBuffer = null;\r
+ }\r
+ if ( this.list入力イベント != null )\r
+ {\r
+ this.list入力イベント = null;\r
+ }\r
+ }\r
+ //-----------------\r
+ #endregion\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Runtime.InteropServices;\r
+using System.Drawing;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ public class CWin32\r
+ {\r
+ #region [ Win32 定数 ]\r
+ //-----------------\r
+ public const int BROADCAST_QUERY_DENY = 0x424d5144;\r
+ public const uint CALLBACK_FUNCTION = 0x30000;\r
+ public const uint ES_CONTINUOUS = 0x80000000;\r
+ public const uint ES_DISPLAY_REQUIRED = 2;\r
+ public const uint ES_SYSTEM_REQUIRED = 1;\r
+ public const uint ES_USER_PRESENT = 4;\r
+ public const int GWL_EXSTYLE = -20;\r
+ public const int GWL_HINSTANCE = -6;\r
+ public const int GWL_HWNDPARENT = -8;\r
+ public const int GWL_ID = -12;\r
+ public const int GWL_STYLE = -16;\r
+ public const int GWL_USERDATA = -21;\r
+ public const int GWL_WNDPROC = -4;\r
+ public static readonly IntPtr HWND_NOTOPMOST = new IntPtr( -2 );\r
+ public static readonly IntPtr HWND_TOPMOST = new IntPtr( -1 );\r
+ public const uint MAXPNAMELEN = 0x20;\r
+ public const uint MIM_CLOSE = 0x3c2;\r
+ public const uint MIM_DATA = 0x3c3;\r
+ public const uint MIM_ERROR = 0x3c5;\r
+ public const uint MIM_LONGDATA = 0x3c4;\r
+ public const uint MIM_LONGERROR = 0x3c6;\r
+ public const uint MIM_OPEN = 0x3c1;\r
+ public const int MONITOR_DEFAULTTOPRIMARY = 1;\r
+ public const int PBT_APMQUERYSTANDBY = 1;\r
+ public const int PBT_APMQUERYSUSPEND = 0;\r
+ public const int SC_MONITORPOWER = 0xf170;\r
+ public const int SC_SCREENSAVE = 0xf140;\r
+ public const int SIZE_MAXIMIZED = 2;\r
+ public const int SIZE_MINIMIZED = 1;\r
+ public const int SIZE_RESTORED = 0;\r
+ public const uint SWP_FRAMECHANGED = 0x20;\r
+ public const uint SWP_HIDEWINDOW = 0x80;\r
+ public const uint SWP_NOACTIVATE = 0x10;\r
+ public const uint SWP_NOCOPYBITS = 0x100;\r
+ public const uint SWP_NOMOVE = 2;\r
+ public const uint SWP_NOOWNERZORDER = 0x200;\r
+ public const uint SWP_NOREDRAW = 8;\r
+ public const uint SWP_NOSENDCHANGING = 0x400;\r
+ public const uint SWP_NOSIZE = 1;\r
+ public const uint SWP_NOZORDER = 4;\r
+ public const uint SWP_SHOWWINDOW = 0x40;\r
+ public const int WM_ACTIVATEAPP = 0x1c;\r
+ public const int WM_POWERBROADCAST = 0x218;\r
+ public const int WM_SIZE = 5;\r
+ public const int WM_SYSCOMMAND = 0x112;\r
+ public const int WM_SYSKEYDOWN = 260;\r
+ public const int WPF_RESTORETOMAXIMIZED = 2;\r
+ public const long WS_BORDER = 0x800000L;\r
+ public const long WS_CAPTION = 0xc00000L;\r
+ public const long WS_CHILD = 0x40000000L;\r
+ public const long WS_CHILDWINDOW = 0x40000000L;\r
+ public const long WS_CLIPCHILDREN = 0x2000000L;\r
+ public const long WS_CLIPSIBLINGS = 0x4000000L;\r
+ public const long WS_DISABLED = 0x8000000L;\r
+ public const long WS_DLGFRAME = 0x400000L;\r
+ public const long WS_EX_ACCEPTFILES = 0x10L;\r
+ public const long WS_EX_APPWINDOW = 0x40000L;\r
+ public const long WS_EX_CLIENTEDGE = 0x200L;\r
+ public const long WS_EX_COMPOSITED = 0x2000000L;\r
+ public const long WS_EX_CONTEXTHELP = 0x400L;\r
+ public const long WS_EX_CONTROLPARENT = 0x10000L;\r
+ public const long WS_EX_DLGMODALFRAME = 1L;\r
+ public const long WS_EX_LAYERED = 0x80000L;\r
+ public const long WS_EX_LAYOUTRTL = 0x400000L;\r
+ public const long WS_EX_LEFT = 0L;\r
+ public const long WS_EX_LEFTSCROLLBAR = 0x4000L;\r
+ public const long WS_EX_LTRREADING = 0L;\r
+ public const long WS_EX_MDICHILD = 0x40L;\r
+ public const long WS_EX_NOACTIVATE = 0x8000000L;\r
+ public const long WS_EX_NOINHERITLAYOUT = 0x100000L;\r
+ public const long WS_EX_NOPARENTNOTIFY = 4L;\r
+ public const long WS_EX_OVERLAPPEDWINDOW = 0x300L;\r
+ public const long WS_EX_PALETTEWINDOW = 0x188L;\r
+ public const long WS_EX_RIGHT = 0x1000L;\r
+ public const long WS_EX_RIGHTSCROLLBAR = 0L;\r
+ public const long WS_EX_RTLREADING = 0x2000L;\r
+ public const long WS_EX_STATICEDGE = 0x20000L;\r
+ public const long WS_EX_TOOLWINDOW = 0x80L;\r
+ public const long WS_EX_TOPMOST = 8L;\r
+ public const long WS_EX_TRANSPARENT = 0x20L;\r
+ public const long WS_EX_WINDOWEDGE = 0x100L;\r
+ public const long WS_GROUP = 0x20000L;\r
+ public const long WS_HSCROLL = 0x100000L;\r
+ public const long WS_ICONIC = 0x20000000L;\r
+ public const long WS_MAXIMIZE = 0x1000000L;\r
+ public const long WS_MAXIMIZEBOX = 0x10000L;\r
+ public const long WS_MINIMIZE = 0x20000000L;\r
+ public const long WS_MINIMIZEBOX = 0x20000L;\r
+ public const long WS_OVERLAPPED = 0L;\r
+ public const long WS_OVERLAPPEDWINDOW = 0xcf0000L;\r
+ public const long WS_POPUP = 0x80000000L;\r
+ public const long WS_POPUPWINDOW = 0x80880000L;\r
+ public const long WS_SIZEBOX = 0x40000L;\r
+ public const long WS_SYSMENU = 0x80000L;\r
+ public const long WS_TABSTOP = 0x10000L;\r
+ public const long WS_THICKFRAME = 0x40000L;\r
+ public const long WS_TILED = 0L;\r
+ public const long WS_TILEDWINDOW = 0xcf0000L;\r
+ public const long WS_VISIBLE = 0x10000000L;\r
+ public const long WS_VSCROLL = 0x200000L;\r
+\r
+ public enum EShowWindow\r
+ {\r
+ ForceMinimize = 11,\r
+ Hide = 0,\r
+ Maximize = 3,\r
+ Minimize = 6,\r
+ Normal = 1,\r
+ Restore = 9,\r
+ Show = 5,\r
+ ShowDefault = 10,\r
+ ShowMaximized = 3,\r
+ ShowMinimized = 2,\r
+ ShowMinNoActive = 7,\r
+ ShowNA = 8,\r
+ ShowNoActivate = 4\r
+ }\r
+ public enum MMSYSERR\r
+ {\r
+ NOERROR,\r
+ ERROR,\r
+ BADDEVICEID,\r
+ NOTENABLED,\r
+ ALLOCATED,\r
+ INVALHANDLE,\r
+ NODRIVER,\r
+ NOMEM,\r
+ NOTSUPPORTED,\r
+ BADERRNUM,\r
+ INVALFLAG,\r
+ INVALPARAM,\r
+ HANDLEBUSY,\r
+ INVALIDALIAS,\r
+ BADDB,\r
+ KEYNOTFOUND,\r
+ READERROR,\r
+ WRITEERROR,\r
+ DELETEERROR,\r
+ VALNOTFOUND,\r
+ NODRIVERCB,\r
+ MOREDATA\r
+ }\r
+ [FlagsAttribute]\r
+ internal enum ExecutionState : uint\r
+ {\r
+ Null = 0, // 関数が失敗した時の戻り値\r
+ SystemRequired = 1, // スタンバイを抑止\r
+ DisplayRequired = 2, // 画面OFFを抑止\r
+ Continuous = 0x80000000, // 効果を永続させる。ほかオプションと併用する。\r
+ }\r
+ //-----------------\r
+ #endregion\r
+\r
+ #region [ Win32 関数 ]\r
+ //-----------------\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern bool AdjustWindowRect( ref RECT lpRect, uint dwStyle, [MarshalAs( UnmanagedType.Bool )] bool bMenu );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern bool GetClientRect( IntPtr hWnd, out RECT lpRect );\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern uint GetWindowLong( IntPtr hWnd, int nIndex );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern bool GetWindowPlacement( IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
+ public static extern bool IsIconic( IntPtr hWnd );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
+ public static extern bool IsWindowVisible( IntPtr hWnd );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
+ public static extern bool IsZoomed( IntPtr hWnd );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInClose( uint hMidiIn );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInGetDevCaps( uint uDeviceID, ref MIDIINCAPS lpMidiInCaps, uint cbMidiInCaps );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInGetID( uint hMidiIn, ref uint puDeviceID );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInGetNumDevs();\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInOpen( ref uint phMidiIn, uint uDeviceID, MidiInProc dwCallback, int dwInstance, int fdwOpen );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInReset( uint hMidiIn );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInStart( uint hMidiIn );\r
+ [DllImport( "winmm.dll" )]\r
+ public static extern uint midiInStop( uint hMidiIn );\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
+ public static extern IntPtr MonitorFromWindow( IntPtr hwnd, uint dwFlags );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
+ public static extern bool PeekMessage( out WindowMessage message, IntPtr hwnd, uint messageFilterMin, uint messageFilterMax, uint flags );\r
+ [DllImport( "kernel32.dll", CharSet = CharSet.Auto )]\r
+ public static extern uint SetThreadExecutionState( uint esFlags );\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern uint SetWindowLong( IntPtr hWnd, int nIndex, uint dwNewLong );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern bool SetWindowPlacement( IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
+ public static extern bool ShowWindow( IntPtr hWnd, EShowWindow nCmdShow );\r
+ [return: MarshalAs( UnmanagedType.Bool )]\r
+ [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
+ public static extern bool SystemParametersInfo( uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni );\r
+ [DllImport( "kernel32.dll" )]\r
+ public static extern void GetSystemInfo( ref SYSTEM_INFO ptmpsi );\r
+ [DllImport( "kernel32.dll" )]\r
+ internal static extern ExecutionState SetThreadExecutionState( ExecutionState esFlags );\r
+ //-----------------\r
+ #endregion\r
+\r
+ #region [ Win32 構造体 ]\r
+ //-----------------\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ private struct FILTERKEYS\r
+ {\r
+ public int cbSize;\r
+ public int dwFlags;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct MIDIINCAPS\r
+ {\r
+ public ushort wMid;\r
+ public ushort wPid;\r
+ public uint vDriverVersion;\r
+ [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 0x20 )]\r
+ public string szPname;\r
+ public uint dwSupport;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct RECT\r
+ {\r
+ public int left;\r
+ public int top;\r
+ public int right;\r
+ public int bottom;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ private struct STICKYKEYS\r
+ {\r
+ public int cbSize;\r
+ public int dwFlags;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ private struct TOGGLEKEYS\r
+ {\r
+ public int cbSize;\r
+ public int dwFlags;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct WAVEFORMATEX\r
+ {\r
+ public ushort wFormatTag;\r
+ public ushort nChannels;\r
+ public uint nSamplesPerSec;\r
+ public uint nAvgBytesPerSec;\r
+ public ushort nBlockAlign;\r
+ public ushort wBitsPerSample;\r
+ public ushort cbSize;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct WindowMessage\r
+ {\r
+ public IntPtr hWnd;\r
+ public uint msg;\r
+ public IntPtr wParam;\r
+ public IntPtr lParam;\r
+ public uint time;\r
+ public Point p;\r
+ }\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct WINDOWPLACEMENT\r
+ {\r
+ public int length;\r
+ public int flags;\r
+ public CWin32.EShowWindow showCmd;\r
+ public Point ptMinPosition;\r
+ public Point ptMaxPosition;\r
+ public CWin32.RECT rcNormalPosition;\r
+ public static int Length\r
+ {\r
+ get\r
+ {\r
+ return Marshal.SizeOf( typeof( CWin32.WINDOWPLACEMENT ) );\r
+ }\r
+ }\r
+ }\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct SYSTEM_INFO\r
+ {\r
+ public uint dwOemId;\r
+ public uint dwPageSize;\r
+ public uint lpMinimumApplicationAddress;\r
+ public uint lpMaximumApplicationAddress;\r
+ public uint dwActiveProcessorMask;\r
+ public uint dwNumberOfProcessors;\r
+ public uint dwProcessorType;\r
+ public uint dwAllocationGranularity;\r
+ public uint dwProcessorLevel;\r
+ public uint dwProcessorRevision;\r
+ }\r
+ //-----------------\r
+ #endregion\r
+\r
+\r
+ // プロパティ\r
+\r
+ public static bool bアプリがIdle状態である\r
+ {\r
+ get\r
+ {\r
+ WindowMessage message;\r
+ return !PeekMessage( out message, IntPtr.Zero, 0, 0, 0 );\r
+ }\r
+ }\r
+\r
+\r
+ // キーボードの特殊機能の制御\r
+\r
+ public static class Cトグルキー機能\r
+ {\r
+ public static void t無効化する()\r
+ {\r
+ if ( ( stored.dwFlags & 1L ) == 0L )\r
+ {\r
+ CWin32.TOGGLEKEYS structure = new CWin32.TOGGLEKEYS();\r
+ structure.dwFlags = stored.dwFlags;\r
+ structure.cbSize = stored.cbSize;\r
+ structure.dwFlags &= -5;\r
+ structure.dwFlags &= -9;\r
+ int cb = Marshal.SizeOf( structure );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( structure, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x35, (uint) cb, ptr, 0 );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+ }\r
+ public static void t復元する()\r
+ {\r
+ int cb = Marshal.SizeOf( stored );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( stored, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x35, (uint) cb, ptr, 0 );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+\r
+ #region [ private ]\r
+ //-----------------\r
+ static Cトグルキー機能()\r
+ {\r
+ int cb = Marshal.SizeOf( stored );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( stored, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x34, (uint) cb, ptr, 0 );\r
+ stored = (CWin32.TOGGLEKEYS) Marshal.PtrToStructure( ptr, typeof( CWin32.TOGGLEKEYS ) );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+\r
+ private const uint SPI_GETTOGGLEKEYS = 0x34;\r
+ private const uint SPI_SETTOGGLEKEYS = 0x35;\r
+ private static CWin32.TOGGLEKEYS stored = new CWin32.TOGGLEKEYS();\r
+ private const uint TKF_CONFIRMHOTKEY = 8;\r
+ private const uint TKF_HOTKEYACTIVE = 4;\r
+ private const uint TKF_TOGGLEKEYSON = 1;\r
+ //-----------------\r
+ #endregion\r
+ }\r
+ public static class Cフィルタキー機能\r
+ {\r
+ public static void t無効化する()\r
+ {\r
+ if ( ( stored.dwFlags & 1L ) == 0L )\r
+ {\r
+ CWin32.FILTERKEYS structure = new CWin32.FILTERKEYS();\r
+ structure.dwFlags = stored.dwFlags;\r
+ structure.cbSize = stored.cbSize;\r
+ structure.dwFlags &= -5;\r
+ structure.dwFlags &= -9;\r
+ int cb = Marshal.SizeOf( structure );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( structure, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+ }\r
+ public static void t復元する()\r
+ {\r
+ int cb = Marshal.SizeOf( stored );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( stored, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+\r
+ #region [ private ]\r
+ //-----------------\r
+ static Cフィルタキー機能()\r
+ {\r
+ stored.cbSize = 0;\r
+ stored.dwFlags = 0;\r
+ int cb = Marshal.SizeOf( stored );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( stored, ptr, false );\r
+ CWin32.SystemParametersInfo( 50, (uint) cb, ptr, 0 );\r
+ stored = (CWin32.FILTERKEYS) Marshal.PtrToStructure( ptr, typeof( CWin32.FILTERKEYS ) );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+\r
+ private const uint FKF_CONFIRMHOTKEY = 8;\r
+ private const uint FKF_FILTERKEYSON = 1;\r
+ private const uint FKF_HOTKEYACTIVE = 4;\r
+ private const uint SPI_GETFILTERKEYS = 50;\r
+ private const uint SPI_SETFILTERKEYS = 0x3b;\r
+ private static CWin32.FILTERKEYS stored = new CWin32.FILTERKEYS();\r
+ //-----------------\r
+ #endregion\r
+ }\r
+ public static class C固定キー機能\r
+ {\r
+ public static void t無効化する()\r
+ {\r
+ if ( ( stored.dwFlags & 1L ) == 0L )\r
+ {\r
+ CWin32.STICKYKEYS structure = new CWin32.STICKYKEYS();\r
+ structure.dwFlags = stored.dwFlags;\r
+ structure.cbSize = stored.cbSize;\r
+ structure.dwFlags &= -5;\r
+ structure.dwFlags &= -9;\r
+ int cb = Marshal.SizeOf( structure );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( structure, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+ }\r
+ public static void t復元する()\r
+ {\r
+ int cb = Marshal.SizeOf( stored );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( stored, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+\r
+ #region [ private ]\r
+ //-----------------\r
+ static C固定キー機能()\r
+ {\r
+ stored.cbSize = 0;\r
+ stored.dwFlags = 0;\r
+ int cb = Marshal.SizeOf( stored );\r
+ IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
+ Marshal.StructureToPtr( stored, ptr, false );\r
+ CWin32.SystemParametersInfo( 0x3a, (uint) cb, ptr, 0 );\r
+ stored = (CWin32.STICKYKEYS) Marshal.PtrToStructure( ptr, typeof( CWin32.STICKYKEYS ) );\r
+ Marshal.FreeCoTaskMem( ptr );\r
+ }\r
+\r
+ private const uint SKF_CONFIRMHOTKEY = 8;\r
+ private const uint SKF_HOTKEYACTIVE = 4;\r
+ private const uint SKF_STICKYKEYSON = 1;\r
+ private const uint SPI_GETSTICKYKEYS = 0x3a;\r
+ private const uint SPI_SETSTICKYKEYS = 0x3b;\r
+ private static CWin32.STICKYKEYS stored = new CWin32.STICKYKEYS();\r
+ //-----------------\r
+ #endregion\r
+ }\r
+\r
+\r
+ // Win32 メッセージ処理デリゲート\r
+\r
+ public delegate void MidiInProc( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 );\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ // 定数\r
+\r
+ public enum E入力デバイス種別\r
+ {\r
+ Keyboard,\r
+ Mouse,\r
+ Joystick,\r
+ MidiIn,\r
+ Unknown\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ public interface IInputDevice : IDisposable\r
+ {\r
+ // プロパティ\r
+\r
+ E入力デバイス種別 e入力デバイス種別\r
+ {\r
+ get;\r
+ }\r
+ string GUID\r
+ {\r
+ get;\r
+ }\r
+ int ID\r
+ {\r
+ get;\r
+ }\r
+ List<STInputEvent> list入力イベント\r
+ {\r
+ get;\r
+ }\r
+\r
+\r
+ // メソッドインターフェース\r
+\r
+ void tポーリング( bool bWindowがアクティブ中, bool bバッファ入力を使用する );\r
+ bool bキーが押された( int nKey );\r
+ bool bキーが押されている( int nKey );\r
+ bool bキーが離された( int nKey );\r
+ bool bキーが離されている( int nKey );\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace MidiInChecker2\r
+{\r
+ // 構造体\r
+\r
+ [StructLayout( LayoutKind.Sequential )]\r
+ public struct STInputEvent\r
+ {\r
+ public int nKey { get; set; }\r
+ public bool b押された { get; set; }\r
+ public bool b離された { get; set; }\r
+ public long nTimeStamp { get; set; }\r
+ public int nVelocity { get; set; }\r
+ }\r
+}\r