GTAVMenuBase icon indicating copy to clipboard operation
GTAVMenuBase copied to clipboard

Keyboard handler

Open anzz1 opened this issue 2 years ago • 0 comments

According to the ScriptHookV doc you should use keyboardHandlerRegister instead of GetAsyncKeyState

You must use keyboard hook instead of GetKeyState/GetAsyncKeyState WIN API funcs, because it guarantees that all key presses will be handled correctly.

Due to the unfortunate situation Alexander Blade (scripthookv dev) cannot be asked directly why, but I suspect the the reason is this last part of sentence in the MSDN doc

Determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.

As when using your awesome GTAVAddonLoader mod, it seems that 50/50 of the time when pressing Escape to enter pause menu, it doesn't register on the first try and have to press it twice (just playing normally, addon spawner menu is not open, and it's the only addon besides ScriptHookV itself).

So if I had to guess, the reason Alexander instructs against using GetAsyncKeyState, is that maybe the GTA engine relies on this "previous call" part which breaks when adding another GetAsyncKeyState to the pipeline.

Then again, I'm less sure about that since that would be indeed very bad, outdated design as any other app running on the system could also taint the value by calling GetAsyncKeyState, and the MSDN doc states clearly that it's not to be relied on. Could the devs do such a mistake? Idk.

anzz1 avatar May 25 '22 23:05 anzz1