Bugz Door Project
Macros | Functions | Variables
getkey.cpp File Reference

Key and door input routines. More...

#include <iostream>
#include <termios.h>
#include <unistd.h>
#include "door.h"
#include <signal.h>
#include <ctype.h>
Include dependency graph for getkey.cpp:

Macros

#define CRNL   "\r\n"
 used by output routines. More...
 

Functions

void raw (void)
 Enable terminal raw mode. More...
 
void reset (void)
 Reset the terminal termios to the original values.
 
signed int getch (void)
 low level getch key read More...
 
void unget (char c)
 ungets (pushes key back) More...
 
char get (void)
 get a key from the pushback buffer. More...
 
signed int getkey (void)
 high level getkey More...
 

Variables

struct termios tio_default
 Original terminal termios defaults.
 
char buffer [10]
 pushback buffer to store keys we're not ready for yet.
 
int bpos = 0
 pushback buffer position
 

Detailed Description

Key and door input routines.

Macro Definition Documentation

◆ CRNL

#define CRNL   "\r\n"

used by output routines.

Sending "\n" isn't enough.

Function Documentation

◆ get()

char get ( void  )

get a key from the pushback buffer.

Returns
char

◆ getch()

signed int getch ( void  )

low level getch key read

This reads a key with a defined timeout value. This is called by other routines to handle arrow keys, F-keys. returns -1 on timeout (no key), -2 on error (connection closed)

Returns
signed int

◆ getkey()

signed int getkey ( void  )

high level getkey

This returns function keys, arrow keys, see XKEY_* defines. returns -1 (no key avaiable) or -2 (hangup) or XKEY_UNKNOWN (don't know what it is)

Returns
signed int

◆ raw()

void raw ( void  )

Enable terminal raw mode.

This sets up the linux console so the door library will work correctly in local mode.

◆ unget()

void unget ( char  c)

ungets (pushes key back)

If we read ahead, and we can't use it, we push it back into the buffer for next time.

Parameters
c