Advertisement
romanilyin

Gamepad Connected Disconnected

Apr 7th, 2022
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. private void UpdateLastActiveInputType (ControllerStatusChangedEventArgs args = null)
  2.     {
  3.         Controller activeController = _player.controllers.GetLastActiveController();
  4.         if ( activeController != null )
  5.         {
  6.             //Logger.Log(LogType.UI, "UpdateControlsNew(" + _player.controllers.GetLastActiveController().hardwareIdentifier + ")");
  7.             switch ( activeController.type )
  8.             {
  9.                 case ControllerType.Keyboard:
  10.                     JoystickMode = JoystickMode.KeyboardAndMouse;
  11.                     break;
  12.                 case ControllerType.Joystick:
  13.                     if ( activeController.hardwareIdentifier == "WindowsXInputGamepadGamepad" || activeController.hardwareIdentifier == "WindowsFallbackController(XEOXGamepad)" )
  14.                         JoystickMode = JoystickMode.XBox;
  15.                     else if ( activeController.hardwareIdentifier.Contains("Steam") ) // ?
  16.                         JoystickMode = JoystickMode.Steam;
  17.                     else
  18.                         JoystickMode = JoystickMode.PS;
  19.                     break;
  20.                 case ControllerType.Mouse:
  21.                     JoystickMode = JoystickMode.KeyboardAndMouse;
  22.                     break;
  23.                 case ControllerType.Custom:
  24.                     JoystickMode = JoystickMode.KeyboardAndMouse;
  25.                     break;
  26.             }
  27.         }
  28.         else
  29.         {
  30.             // если ничего не нажимали ещё то клавомышь выбираем
  31.             //Logger.Log(LogType.UI, "UpdateControlsNew(no active controller : set keyboard and mouse by default)");
  32.             JoystickMode = JoystickMode.KeyboardAndMouse;
  33.         }
  34.         UpdateJoystickHints();
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement