コード例 #1
0
        public void SetVibration(uint playerIndex, float leftMotor, float rightMotor)
        {
            if (!DllAvailable)
            {
                return;
            }

            try
            {
                XInputGamePadSetState(playerIndex, leftMotor, rightMotor);
            }
            catch (DllNotFoundException)
            {
                if (XInputGamePadSetState != NativeMethods.XInputGamePadSetState)    // if _x86 or _x64 dll not exists
                {
                    XInputGamePadSetState = NativeMethods.XInputGamePadSetState;
                    SetVibration(playerIndex, leftMotor, rightMotor);
                }
                else    // no dll at all
                {
                    DllAvailable = false;
                    return;
                }
            }
            catch (BadImageFormatException) // use _x86 dll on x64 system, or _x64 dll on x86 system
            {
                DllAvailable = false;
                return;
            }
            catch (Exception)
            {
                DllAvailable = false;
                return;
            }
        }
コード例 #2
0
 private void Initialize()
 {
     if (Util.IsWin32())
     {
         XInputGamePadGetState = NativeMethods.XInputGamePadGetState_x86;
         XInputGamePadSetState = NativeMethods.XInputGamePadSetState_x86;
     }
     else if (Util.IsWin64())
     {
         XInputGamePadGetState = NativeMethods.XInputGamePadGetState_x64;
         XInputGamePadSetState = NativeMethods.XInputGamePadSetState_x64;
     }
     else
     {
         XInputGamePadGetState = NativeMethods.XInputGamePadGetState;
         XInputGamePadSetState = NativeMethods.XInputGamePadSetState;
     }
 }