17cupsofcoffee / tetra

🎮 A simple 2D game framework written in Rust
MIT License
910 stars 63 forks source link

Added functions related to key repeat #220

Closed sumibi-yakitori closed 3 years ago

sumibi-yakitori commented 3 years ago

This is a feature that is not related to the game, but was still necessary for me to create the tool.

17cupsofcoffee commented 3 years ago

I'm open to adding this, will have a proper look at the code later today :+1:

Just out of curiousity, what issues were you having when key repeat was disabled? I've not really run into a situation where I've needed it so far, but I know your use case for Tetra is a bit different than mine :)

sumibi-yakitori commented 3 years ago

Happy New Year. I know UK is having a hard time with COVID, are you OK?

At the beginning of the year, I was working on an old-fashioned dual-pane file manager and particle creation tool, operated by a keyboard like vifm. With key repeat disabled, of course it's a pain to manipulate the file list with keystrokes. Since tetra::input::is_key_down and tetra::input::is_key_pressed can only be retrieved at timings related to the game loop In my use case, I needed to enable exact key repeat.

17cupsofcoffee commented 3 years ago

Happy New Year. I know UK is having a hard time with COVID, are you OK?

Thank you! Yes, I'm doing alright, I am lucky enough to have a job where I can work from home, so I've been able to stay safe. Hope you're doing okay too.

With key repeat disabled, of course it's a pain to manipulate the file list with keystrokes.

Ah, that makes sense! I usually use the polling functions (e.g. is_key_pressed) in my games, but I can see how they'd not be ideal for that style of app.

I've had a play around with the change locally and it seems good, I can see the extra events coming through in the events example when I enable key repeat. I might tweak the naming/docs of some things before I release, but happy to merge this as is for now :+1:

sumibi-yakitori commented 3 years ago

Thanks. I work from home too, so I'm good for now.