void InitWheel()
    {
        if (inited == null)
        {
            inited = this;
        }
        else
        {
            return;
        }

        if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows)
        {
            try
            {
                DirectInputWrapper.Init();
            }
            catch (DllNotFoundException)
            {
                // in case DirectInput wrapper dll file is not found
                Debug.Log("DirectInput wrapper dll file is not found");
                available = false;
                return;
            }

            for (int i = 0; i < DirectInputWrapper.DevicesCount(); i++)
            {
                if (!DirectInputWrapper.HasForceFeedback(i))
                {
                    continue;
                }
                wheelIndex = i;
                available  = true;
                break;
            }

            if (!available)
            {
                Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
                return;
            }
        }
        else
        {
            // WARNING: Input.GetJoystickNames or GetAxis/Buttons will crash if no valid Joystick is connected
            available = Environment.GetEnvironmentVariable("SDL_GAMECONTROLLERCONFIG") != null;
            // if (available)
            // {
            //     foreach (var joy in Input.GetJoystickNames())
            //     {
            //         Debug.Log($"Available joystick: {joy}, Preconfigured = {Input.IsJoystickPreconfigured(joy)}");
            //     }
            // }
        }
    }
    protected override void Start()
    {
        base.Start();

        debugStyle                  = new GUIStyle();
        debugStyle.fontSize         = 45;
        debugStyle.normal.textColor = Color.white;

        if (inited == null)
        {
            inited = this;
        }
        else
        {
            return;
        }

        DirectInputWrapper.Init();

        bool ff0 = DirectInputWrapper.HasForceFeedback(0);

        if (DirectInputWrapper.DevicesCount() > 1)
        {
            bool ff1 = DirectInputWrapper.HasForceFeedback(1);

            if (ff1 && !ff0)
            {
                wheelIndex = 1;
                pedalIndex = 0;
            }
            else if (ff0 && !ff1)
            {
                wheelIndex = 0;
                pedalIndex = 1;
            }
            else
            {
                //Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
                wheelIndex = 0;
                pedalIndex = 1;
            }
        }

        minBrake  = AppController.Instance.appSettings.minBrake;
        maxBrake  = AppController.Instance.appSettings.maxBrake;
        minGas    = AppController.Instance.appSettings.minGas;
        maxGas    = AppController.Instance.appSettings.maxGas;
        gasAxis   = AppController.Instance.appSettings.gasAxis;
        brakeAxis = AppController.Instance.appSettings.brakeAxis;
        FFBGain   = AppController.Instance.appSettings.FFBMultiplier;
    }
Exemplo n.º 3
0
    void Start()
    {
        Debug.Log("init: " + DirectInputWrapper.Init());
        Debug.Log("Count: " + DirectInputWrapper.DevicesCount());

        for (int i = 0; i < DirectInputWrapper.DevicesCount(); i++)
        {
            Debug.Log("Name: " + DirectInputWrapper.GetProductNameManaged(i));
            Debug.Log("FFB: " + DirectInputWrapper.HasForceFeedback(i));
            
            for(int j = 0; j < DirectInputWrapper.GetNumEffects(i); j++)
            {
                Debug.Log("EFFECT: " + DirectInputWrapper.GetEffectNameManaged(i, j));
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        DirectInputWrapper.Init();

        /*LogitechGSDK.LogiControllerPropertiesData properties = new LogitechGSDK.LogiControllerPropertiesData();
         * properties.wheelRange = 900;
         * properties.forceEnable = true;
         * properties.overallGain = 80;
         * properties.springGain = 80;
         * properties.damperGain = 80;
         * properties.allowGameSettings = true;
         * properties.combinePedals = true;
         * properties.defaultSpringEnabled = false;
         * properties.defaultSpringGain = 0;
         * LogitechGSDK.LogiSetPreferredControllerProperties(properties);
         */

        bool ff0 = DirectInputWrapper.HasForceFeedback(0);

        if (DirectInputWrapper.DevicesCount() > 1)
        {
            bool ff1 = DirectInputWrapper.HasForceFeedback(1);

            if (ff1 && !ff0)
            {
                wheelIndex = 1;
                pedalIndex = 0;
            }
            else if (ff0 && !ff1)
            {
                wheelIndex = 0;
                pedalIndex = 1;
            }
            else
            {
                Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
            }
        }
    }
    protected override void Start()
    {
        base.Start();

        debugStyle                  = new GUIStyle();
        debugStyle.fontSize         = 45;
        debugStyle.normal.textColor = Color.white;

        if (inited == null)
        {
            inited = this;
        }
        else
        {
            return;
        }

        DirectInputWrapper.Init();

        MasterSteeringWheel = false;
        masterIndex         = reportMasterWheel("FANATEC CSL Elite Wheel Base");
        if (masterIndex > -1)
        {
            MasterSteeringWheel = true;
        }


        bool ff0 = DirectInputWrapper.HasForceFeedback(0); /// Thios part mworks for now as the main inputs are always 0 or 1 we need code here though tat jumps over the master wheel shpould it be present

        if (DirectInputWrapper.DevicesCount() > 1)         // steering one and two should be padles and participant steering wheel
        {
            bool ff1 = DirectInputWrapper.HasForceFeedback(1);

            if (ff1 && !ff0)
            {
                wheelIndex = 1;
                pedalIndex = 0;
            }
            else if (ff0 && !ff1)
            {
                wheelIndex = 0;
                pedalIndex = 1;
            }
            else
            {
                Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
            }
        }


        if (MasterSteeringWheel)
        {
            minBrake = AppController.Instance.appSettings.minBrakeFanatec;
            maxBrake = AppController.Instance.appSettings.maxBrakeFanatec;
            minGas   = AppController.Instance.appSettings.minGasFanatec;
            maxGas   = AppController.Instance.appSettings.maxGasFanatec;
        }
        else
        {
            minBrake = AppController.Instance.appSettings.minBrake;
            maxBrake = AppController.Instance.appSettings.maxBrake;
            minGas   = AppController.Instance.appSettings.minGas;
            maxGas   = AppController.Instance.appSettings.maxGas;
        }

        gasAxis   = AppController.Instance.appSettings.gasAxis;
        brakeAxis = AppController.Instance.appSettings.brakeAxis;
        // FWheel = AppController.Instance.appSettings.FantacWheel;
        FFBGain = AppController.Instance.appSettings.FFBMultiplier;
    }