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

tb_peek_event() buffers inputs with sleep_for() c++11 #133

Open
Mutaru16bit opened this issue Jun 17, 2020 · 1 comment
Open

tb_peek_event() buffers inputs with sleep_for() c++11 #133

Mutaru16bit opened this issue Jun 17, 2020 · 1 comment

Comments

@Mutaru16bit
Copy link

I'm not sure if this behavior of tb_peek_event() is intentional or not. I encountered it while attempting to make Tetris using termbox and trying to implement a time function and any inputs would stack rather than update on loop.

It can be replicated like this:

simply hold space and release when it shows 1.

#include <termbox.h>
#include <thread>
#include <chrono>
int main(void)
{
int i;
tb_init();
tb_cell c = {};
tb_event e = {};
while(i < 4)
{
tb_clear();
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
tb_peek_event(&e, 0);
if(e.key == TB_KEY_SPACE)
{
i++;
}
c.ch = 48 + i;
tb_put_cell(0,0,&c);
tb_present();
}
tb_shutdown();
return(0);
}

@mame98
Copy link

mame98 commented Oct 22, 2020

I would assume, that that behavior is intentional. Imagine a text-input. Here you would want to receive all missed input. However there should be a method to clear the input buffer?

Is this still relevant for you?

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