OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / FDK17プロジェクト / コード / 02.入力 / CInput管理.cs
index ad52dcd..fd2082f 100644 (file)
@@ -3,8 +3,7 @@ using System.Collections.Generic;
 using System.Text;\r
 using System.Diagnostics;\r
 using System.Runtime.InteropServices;\r
-using SlimDX;\r
-using SlimDX.DirectInput;\r
+using SharpDX.DirectInput;\r
 \r
 namespace FDK\r
 {\r
@@ -86,7 +85,7 @@ namespace FDK
                                cinputkeyboard = new CInputKeyboard( hWnd, directInput );\r
                                cinputmouse = new CInputMouse( hWnd, directInput );\r
                        }\r
-                       catch ( DirectInputException )\r
+                       catch\r
                        {\r
                        }\r
                        if (cinputkeyboard != null)\r
@@ -99,7 +98,7 @@ namespace FDK
                        }\r
                        #endregion\r
                        #region [ Enumerate joypad ]\r
-                       foreach ( DeviceInstance instance in this.directInput.GetDevices( DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly ) )\r
+                       foreach ( DeviceInstance instance in this.directInput.GetDevices( DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly ) )\r
                        {\r
                                this.list入力デバイス.Add( new CInputJoystick( hWnd, instance, directInput ) );\r
                        }\r
@@ -184,11 +183,19 @@ namespace FDK
                                        {\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 (SharpDX.SharpDXException 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
+                                               if( e.ResultCode == ResultCode.OtherApplicationHasPriority )\r
+                                               {\r
+                                                       // #xxxxx: 2017.5.9: from: このエラーの時は、何もしない。\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       // #xxxxx: 2017.5.9: from: その他のエラーの場合は、デバイスが外されたと想定してRemoveする。\r
+                                                       this.list入力デバイス.Remove( device );\r
+                                                       device.Dispose();\r
+                                                       Trace.TraceError( "tポーリング時に対象deviceが抜かれており例外発生。同deviceをポーリング対象からRemoveしました。" );\r
+                                               }\r
                                        }\r
                                }\r
                        }\r