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

Changing the polling rate of hardware inputs #26

Closed
dustyirwin opened this issue Oct 30, 2020 · 3 comments
Closed

Changing the polling rate of hardware inputs #26

dustyirwin opened this issue Oct 30, 2020 · 3 comments

Comments

@dustyirwin
Copy link
Contributor

Hi all, is there a way to change the polling rate of the mouse/keyboard inputs? I tried looking in event.jl, but I'm not too familiar with how events are scheduled...

@aviks
Copy link
Owner

aviks commented Oct 30, 2020

So the polling for events occurs inbetween frames (SDL2 queues them up). So if you find inputs are slow, it's likely only because your frame takes too long to render or update.

All the logic for the polling is in the mainloop function: https://github.com/aviks/GameZero.jl/blob/master/src/GameZero.jl#L79

@dustyirwin
Copy link
Contributor Author

dustyirwin commented Oct 31, 2020

Thanks for the info, my problem is that my keyboard/mouse events are executing too fast (a good problem to have!) and resolving several commands before the key is released--even on a very short tap.

Looking at the code, I could modify handleEvents! to perhaps accept and return the timer and check the elapsed duration before continuing the loop, but would that slow down the whole game?

@dustyirwin
Copy link
Contributor Author

dustyirwin commented Nov 20, 2020

After reviewing my code, I've decided that changing the polling rate isn't a good way to solve my problem. Instead, I've changed from executing functions directly via mouse/keyboard inputs to switching flags on/off and letting the game engine execute the functions based on those flags to control actor animation, destruction, etc.

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