none
[UWP]RacingWheel.WheelMotor makes my application hang RRS feed

  • Question

  • First, sorry about the links but it seems like my account is not verified, so I can't post any link or image. Please just add "https://" before any link I give. Sorry about that.

    I'm trying to interface my racing wheel with C# UWP, I want to get the input values but also to control the force feedback.

    I followed this really great documentation : docs.microsoft.com/fr-fr/windows/uwp/gaming/racing-wheel-and-force-feedback

    I easily managed to get the values from my wheel, like steering angle, throttle, brake, etc. no problem.

    But as soon as I try to do anything related to force feedback using the "WheelMotor" property of my RacingWheel object, my program hangs. It does not crash, I don't get any error or message, it just doesn't respond to anything anymore.

    My test program is really simple : I have a timer calling a function every 50ms, this function reads the input values and display them in a TextBlock.

    I also have a button tied to a function that just check if the property is null. I'm not even trying to do anything, just checking whether or not it's null.

    bool isNull = wheel.WheelMotor is null;

    Nothing more.

    When I run the program, the input are displayed and refreshed as expected, but as soon as I click the button, everything stops responding. I can't even move the window anymore

    The racing wheel I'm using is a Thrustmaster T300RS, and it is in the list of wheels with force feedback supported by the class I'm using : docs.microsoft.com/en-us/uwp/api/windows.gaming.input.racingwheel

    I have no idea about how to debug this, as I said, no error, can't check if it's null, and when I try to use a breakpoint to see what's inside, it doesn't work either.

    Do you have any idea about how I could get more information about what's happening ?


    Friday, September 13, 2019 11:46 AM

Answers

  • Hi Roy,

    I'm using Windows 10 1903.

    But today I've found the cause of the problem : The wheel was connected using a USB hub, and when I tried with it plugged directly on my computer, everything was back to normal.

    Which is odd, since I was able to communicate with the wheel to get the different axis values with absolutely no problem.

    I guess the program was waiting for a response from the wheel forever. Maybe it would be useful to set a timeout to throw an exception if it's taking too long.

    Anyway, Thank you very much for your help, I hope I hope I did not bother you as the problem was on my side.

    Have a nice day,

    Matthieu

    Tuesday, September 17, 2019 5:08 PM

All replies

  • Hi,

    I have some questions here. I haven't found which device you are testing on using racing wheel. Are you testing the racing wheel in Xbox one or Xbox 360? Another thing I need to confirm is that according to the document: RacingWheel Class, you need to add the humaninterfacedevice capability for your racing wheel if it supports force feedback. Is that done in your app?  Also could you please share the code snippet that you used to test?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 16, 2019 1:43 AM
    Moderator
  • Hi,

    Thank you for your reply.

    I'm trying to run the program on Windows, and I added the humaninterfacedevice capability in the manifest.

    Here is the code :

    public sealed partial class MainPage : Page
        {
            DispatcherTimer timer = new DispatcherTimer();
            RacingWheel wheel;
    
            bool running = false;
    
            public MainPage()
            {
                this.InitializeComponent();
    
                timer.Interval = new TimeSpan(0, 0, 0, 0, 50);
                timer.Tick += dispatcherTimer_Tick;
                timer.Start();
            }
    
            void dispatcherTimer_Tick(object sender, object e)
            {
                if(running)
                {
                    return;
                }
    
                running = true;
    
                maintTextBlock.Text = "Nombre de volants détéctés : " + RacingWheel.RacingWheels.Count.ToString() + "\n\n";
    
                if (RacingWheel.RacingWheels.Count > 0)
                {
                    wheel = RacingWheel.RacingWheels[0];
    
                    maintTextBlock.Text += "Direction\t: " + wheel.GetCurrentReading().Wheel.ToString() + "\n";
                    maintTextBlock.Text += "Accélérateur\t: " + wheel.GetCurrentReading().Throttle.ToString() + "\n";
                    maintTextBlock.Text += "Frein\t: " + wheel.GetCurrentReading().Brake.ToString() + "\n";
                }
    
                running = false;
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                if(wheel != null)
                {
                    bool isNull = wheel.WheelMotor is null;
                }
            }
        }

    Really simple, just trying to test the differents features.

    Thank you,

    Matthieu


    • Edited by Fardenco Monday, September 16, 2019 4:21 PM
    Monday, September 16, 2019 4:20 PM
  • Hi,

    Thanks for the code. But I still have a question. What's the OS version of the device that you used to test? Currently I don't have such a racing wheel device here to test. I'll ask the team to about this. There might be some time delay.

    Thank you for your patience.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, September 17, 2019 1:19 AM
    Moderator
  • Hi Roy,

    I'm using Windows 10 1903.

    But today I've found the cause of the problem : The wheel was connected using a USB hub, and when I tried with it plugged directly on my computer, everything was back to normal.

    Which is odd, since I was able to communicate with the wheel to get the different axis values with absolutely no problem.

    I guess the program was waiting for a response from the wheel forever. Maybe it would be useful to set a timeout to throw an exception if it's taking too long.

    Anyway, Thank you very much for your help, I hope I hope I did not bother you as the problem was on my side.

    Have a nice day,

    Matthieu

    Tuesday, September 17, 2019 5:08 PM
  • Hi,

    It's a good news to hear that you have solved the problem and share the answer here.

    Having a nice day!

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 18, 2019 12:55 AM
    Moderator