private void HandleJoyStickConnected(int joystickDeviceId, int joystickInstanceId) { if (SDL_IsGameController(joystickDeviceId) == SDL_bool.SDL_TRUE) { string id = GenerateGamepadId(joystickDeviceId); if (id == null) { return; } // Sometimes a JoyStick connected event fires after the app starts even though it was connected before // so it is rejected to avoid doubling the entries. if (_gamepadsIds.Contains(id)) { return; } if (_gamepadsInstanceIdsMapping.TryAdd(joystickInstanceId, id)) { _gamepadsIds.Add(id); OnGamepadConnected?.Invoke(id); } } }
public void OnGamepadConnectedHandler(GamepadEventDTO eventDTO) { var gamepad = _gamepads.Find(g => g.Index == eventDTO.gamepad.index); if (gamepad == null) { var ev = new GamepadEvent(eventDTO); _gamepads.Add(ev.Gamepad); OnGamepadConnected?.Invoke(ev); OnUpdate?.Invoke(); } }
private void HandleJoyStickConnected(int joystickDeviceId, int joystickInstanceId) { if (SDL_IsGameController(joystickDeviceId) == SDL_bool.SDL_TRUE) { string id = GenerateGamepadId(joystickDeviceId); if (id == null) { return; } if (_gamepadsInstanceIdsMapping.TryAdd(joystickInstanceId, id)) { _gamepadsIds.Add(id); OnGamepadConnected?.Invoke(id); } } }