Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialising introduces mouse stutter #40

Closed
Kolichikov opened this issue Jul 5, 2022 · 2 comments · Fixed by #74
Closed

Initialising introduces mouse stutter #40

Kolichikov opened this issue Jul 5, 2022 · 2 comments · Fixed by #74

Comments

@Kolichikov
Copy link

I was trying to get the analog sdk used in our Unity game, but I ran into a problem that also seems to happen in regular Visual Studio projects.

Whenever I run var (noDevices, error) = WootingAnalogSDK.Initialise(); I get constant, noticeable mouse stutter. It feels like the mouse just stops registering inputs briefly. Seems to not depend on actually listening for device input.

This behaviour stops in Visual Studio when I stop debugging, and in Unity if I call WootingAnalogSDK.UnInitialise();.

Full code:

using System;
using WootingAnalogSDKNET;

namespace WootingAnalogTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var (noDevices, error) = WootingAnalogSDK.Initialise();
            Console.ReadLine();
        }
    }
}

Versions of things:
VS 2019 16.11.2
Console Project, .NET 5.0
WootingAnalogSDKNET 0.5.0
The Wootility is version: 3.6.16
Latest wooting-analog-sdk installed (whatever Wootility thinks is latest)

@simon-wh
Copy link
Member

simon-wh commented Jul 6, 2022

Hmmmm, the first thing that came to mind is that it could be triggered by the wooting-analog-plugin in the SDK searching for devices periodically. The code I'm referencing is here. The hidapi refresh_devices can be a fairly heavy operation and it could be that it blocks some USB communication while it's searching, hence the mouse stutter you're noticing.

A couple of methods that could be used to verify that this is the cause:

  1. Remove the wooting-analog-plugin.dll from Program Files/WootingAnalogPlugins, then when you initialise it wouldn't occur anymore (although you also wouldn't get inputs from your keyboard)
  2. See if the stutter lines up with the 500ms interval that the refresh_devices will be called on.
  3. Re-compile the SDK with the refreshing disabled / less often

I'm fairly certain that that would be the cause, although I'm unsure of what the best way to fix it would be while still preserving the detection of devices that have been connected after init

@Sainan
Copy link
Contributor

Sainan commented Oct 16, 2023

We've narrowed down on the Discord that this problem occurs due to hidapi calling HidD_GetProductString and HidD_GetSerialNumberString for each HID device. I think this could be avoided if hid_enumerate was called with specifically the Wooting VIDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants