Can't get fresh readings.
Gavin-Williams opened this issue · comments
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?
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.
See #62 for more information.