Thread: Curses keyboard input without pause

  1. #1
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179

    Curses keyboard input without pause

    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 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?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by guesst View Post
    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.

  3. #3
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    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?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by guesst View Post
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with keyboard input
    By fighter92 in forum Game Programming
    Replies: 6
    Last Post: 03-20-2009, 09:41 AM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  3. Using low-level keyboard for input
    By hdragon in forum C++ Programming
    Replies: 25
    Last Post: 12-24-2007, 02:13 PM
  4. Intercepting keyboard input
    By EvBladeRunnervE in forum Windows Programming
    Replies: 3
    Last Post: 01-08-2004, 09:03 AM
  5. Keyboard input without waiting (Borland C++)
    By adamdalziel in forum Game Programming
    Replies: 6
    Last Post: 09-24-2001, 04:20 PM