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

Can't get fresh readings. #64

Open
Gavin-Williams opened this issue Mar 7, 2024 · 2 comments
Open

Can't get fresh readings. #64

Gavin-Williams opened this issue Mar 7, 2024 · 2 comments

Comments

@Gavin-Williams
Copy link

Gavin-Williams commented Mar 7, 2024

Calling GetCurrentReading and checking the timestamp shows that it's the same reading over and over again. I can't get fresh readings.

    public static string GetReading()
    {
        IntPtr readingComPtr = InteropGameInput.GetCurrentReading(InputKind.Mouse, IntPtr.Zero);
        IGameInputReading reading = (IGameInputReading)Marshal.GetObjectForIUnknown(readingComPtr);

        ulong t = reading.GetTimestamp();
        string result = readingComPtr.ToString() + " | " + t.ToString();

        Marshal.FinalReleaseComObject(reading);
        return result;
    }
Input.Create | result = S_OK
Input.Time      readingCmpPtr | reading.Time
547322007323    2074475510032 | 547321957562
547322042057    2074475506032 | 547321957562
547322076200    2074475509392 | 547321957562
547322110489    2074475506752 | 547321957562
547322144683    2074475510112 | 547321957562
547322178827    2074475509232 | 547321957562

The ref count for reading is zero. How can I be getting the same reading repeatedly, if it's being destroyed every frame?

@bbowman
Copy link
Member

bbowman commented Apr 16, 2024

Hey @Gavin-Williams, sorry for the long delay on any response here. I am not a member of the GameInput team but I saw your issue and may be able to help at least a little.

Game Input's GetCurrentReading api will return the most recent reading from the device and if the mouse hasn't moved or a button hasn't been clicked, no new reading will be produced. In terms of the COM ref counting you mention, this does not cause a 'new' reading to come through the system. You may be releasing your view of the current reading and that will destroy the object but calling GetCurrentReading will just create a new COM object based off the same most reading from the device so its not really signaling anything to system to 'move on'.

If you are still experiencing issues here, and can help explain more about your situation (my guess that mouse isn't changing for instance could be way off base for what you are seeing locally), then I might be able to get you some more specific help.

@bbowman
Copy link
Member

bbowman commented May 5, 2024

See #62 for more information.

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

No branches or pull requests

2 participants