def get_controller(controller_name, pygame_control):
    """Get the controller object.

    Args:
        controller_name: The controller name.
        pygame_control: Whether to use Pygame as the interface to receive keyboard signal if using keyboard.

    Returns:
        The instance of controller or None if error.
    """
    controller_name = str(controller_name).lower()
    if controller_name == "keyboard":
        return KeyboardController(pygame_control=pygame_control)
    elif controller_name in ["xboxController", "xboxcontroller", "xbox", "gamepad", "joystick", "steering_wheel",
                             "wheel"]:
        try:
            if controller_name in ["steering_wheel", "wheel"]:
                return SteeringWheelController()
            else:
                return XboxController()
        except Exception:
            return None
    else:
        raise ValueError("No such a controller type: {}".format(controller_name))
Get the controller object.

    Args:
        controller_name: The controller name.
        pygame_control: Whether to use Pygame as the interface to receive keyboard signal if using keyboard.

    Returns:
        The instance of controller or None if error.
    
metadrive/policy/manual_control_policy.py