Curses keyboard input without pause [Archive] - C Board

PDA

View Full Version : Curses keyboard input without pause


guesst
04-10-2008, 08:31 PM
Actually, I'm programming in windows, but since Curses is a linux thing I figure i'd have more luck here. Of courses, if I'm wrong, moderators, feel free to move this message.

Okay, I've made this tetris (http://cboard.cprogramming.com/showthread.php?p=739915) program and I'm trying to click with as few and as simple libraries as I can, so I don't want to load any others, and I'm tired of the TAP-TAP-TAPping to get the pieces into place. I'd prefer if when I depressed the key the left-right moved and when you released it stopped, with some reasonable delay so as to avoid on too-fast computers that far left and far right become the only options.

I've been over the documenataion and I'm not sure it can be done. Am I wrong?

brewbuck
04-10-2008, 09:47 PM
I've been over the documenataion and I'm not sure it can be done. Am I wrong?

I'm not sure why it's not already working. Do you have keyboard autorepeat disabled? In standard curses there is no way to get the key up/down state -- you get characters, not key motions. You will have to rely on the terminal (Windows command shell in this case?) to auto-repeat the keys for you. The problem would be the same on UNIX as well, if auto-repeat is off.

The answer might be in your particular curses version for Windows. It might be turning off the auto-repeat for some reason. It might have some (nonstandard) function to turn it back on again.

guesst
04-12-2008, 09:07 AM
Maybe. What happens is you depress the key and after a brief pause it starts repeating. Maybe that is a windows thing.

Is there no such thing as interrupts?

brewbuck
04-14-2008, 10:22 AM
Maybe. What happens is you depress the key and after a brief pause it starts repeating. Maybe that is a windows thing.

Is there no such thing as interrupts?

No. Curses is fundamentally a terminal-based system. As such it has no way of representing such concepts as a "key press." All it knows is that it can read from the terminal, and write to it. Everything else is up to the terminal.