Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Is there a way to flush input?

Author
Message
EdzUp
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 16th Oct 2021 19:31
As the subject says is there a way to flush the input of the pointer clicks etc, back in the BB days we had FlushMouse and FlushKeys this would clear the buffers between functions so that the new function could operate as if there were no clicks or inputs. These functions are good for mouse inputs between functions where the new screen is shown or when transitioning between mouse screens the new screen takes a click or clicks from the old screen.
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 16th Oct 2021 19:47 Edited at: 16th Oct 2021 19:57
This post has been marked by the post author as the answer.
GetCharBuffer() can help with the keyboard (as it does in this make-shift WaitKey() function) and perhaps the habit of using GetPointerReleased to trigger something vs GetPointerPressed() (and their Raw counterparts) can help.

and, i miss MouseMoveX/Y (i think it was, in DBPro) while we do have GetRawMouseWheelDelta() in AGK.

otherwise, since AppGameKit is meant for multi-platform development (and mobile targets), there isn't a lot of Windows (or PC)-specific functionality built in (i assume that's why).

finally, if you're deving for Win only, i'm sure a dll containing all related functionality can be put together (by someone with more skill than me ).

hope that helps.
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 16th Oct 2021 20:02
I think calling Sync() will do what you want. Input is read and stored during the Sync process.

This is for functions like get GetPointerPressed, GetRawMouseLeftPressed, etc which read the value since the last frame.
EdzUp
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 17th Oct 2021 04:29
I think Virtual Nomad's answer is a good one

I would have preferred a function to flush the inputs on all platforms, I will have to make a makeshift one for now. Calling sync isn't a good solution for inputs as it does a screen flip, I was aiming for just clearing the buffers no user interaction at all.
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Oct 2021 05:06 Edited at: 17th Oct 2021 05:18
Sync
Description
Updates the scene with the latest information, draws all sprites, updates global objects, and swaps the backbuffer into view.

i know we can manually Update, Render, Swap, et al, but "latest information" sounds like more of Sync() could/should be exposed like a ClearInputBuffer() command? that might make a popular Request on the Repo if you're up for it.

small tangent:

working with another user recently and i suggested that they only call GetPointerX/Y()/etc early and once per loop (where values can change throughout the loop), record the inputs and use the variables throughout the remainder of the loop; this goes back to advice posted when i was coding with DBPro.

when he did (in his rather large project), it (using the stored variable vs multiple direct calls) caused a sizable (& unexpected) performance hit
EdzUp
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 17th Oct 2021 22:02
What I did was simply have a repeat look with just a sync call, I did try the loop without the sync but it never updates.



Maybe a input update without the backbuffer flip would be a nice addition so we can refresh inputs without updating what the user sees.
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp

Login to post a reply

Server time is: 2024-04-26 04:13:53
Your offset time is: 2024-04-26 04:13:53