#include <ArKeyHandler.h>
Public Types | |
enum | KEY { UP = 256, DOWN, LEFT, RIGHT, ESCAPE, SPACE, TAB, ENTER, BACKSPACE, _StartFKeys, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, _EndFKeys, PAGEUP, PAGEDOWN, HOME, END, INSERT, DEL } |
These are enums for the non-ascii keys. More... | |
Public Member Functions | |
bool | addKeyHandler (int keyToHandle, ArFunctor *functor) |
This adds a keyhandler, when the keyToHandle is hit, functor will fire. | |
ArKeyHandler (bool blocking=false, bool addAriaExitCB=true) | |
void | checkKeys (void) |
intnernal, use addKeyHandler, Checks for keys and handles them | |
int | getKey (void) |
bool | remKeyHandler (ArFunctor *functor) |
This removes a key handler, by key. | |
bool | remKeyHandler (int keyToHandler) |
This removes a key handler, by key. | |
void | restore (void) |
void | takeKeys (bool blocking=false) |
~ArKeyHandler () | |
Protected Attributes | |
ArFunctorC< ArKeyHandler > | myAriaExitCB |
bool | myBlocking |
std::map< int, ArFunctor * > | myMap |
termios | myOriginalTermios |
bool | myRestored |
This class is for handling input from the keyboard, you just addKeyHandler the keys you want to deal with.
You should also register the keyhandler with Aria::setKeyHandler, and before you create a key handler you should see if one is already there with Aria::getKeyHandler.
You can attach a key handler to a robot with ArRobot::attachKeyHandler which will put a task into the robots list of tasks so that it'll get checked every cycle or you can just call checkKeys yourself (like in its own thread or in the main thread). You should only attach a key handler to one robot, even if you're using multiple robots.
Definition at line 58 of file ArKeyHandler.h.
|
These are enums for the non-ascii keys.
Definition at line 70 of file ArKeyHandler.h. |
|
This object will take over key capture when constructed, and release key capture when destroyed. Definition at line 47 of file ArKeyHandler.cpp. References Aria::addExitCallback(), ArFunctor::setName(), and takeKeys(). |
|
Destructor. Reseases control of the keyboard and restores state before this key handler was created. Definition at line 56 of file ArKeyHandler.cpp. References restore(). |
|
This adds a keyhandler, when the keyToHandle is hit, functor will fire.
Definition at line 103 of file ArKeyHandler.cpp. References ArLog::log(). Referenced by ArMode::ArMode(), ArSickLogger::ArSickLogger(), ArRatioInputKeydrive::takeKeys(), and ArActionKeydrive::takeKeys(). |
|
internal, use addKeyHandler instead... Gets a key from the stdin if ones available, -1 if there aren't any available Definition at line 194 of file ArKeyHandler.cpp. References BACKSPACE, DEL, DOWN, END, ENTER, ESCAPE, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, HOME, INSERT, LEFT, PAGEDOWN, PAGEUP, RIGHT, SPACE, TAB, and UP. Referenced by checkKeys(). |
|
This removes a key handler, by key.
Definition at line 145 of file ArKeyHandler.cpp. References ArLog::log(). |
|
This removes a key handler, by key.
Definition at line 125 of file ArKeyHandler.cpp. References ArLog::log(). Referenced by ArRatioInputKeydrive::giveUpKeys(), ArActionKeydrive::giveUpKeys(), and ArMode::~ArMode(). |
|
Sets stdin back to its original settings, if its been restored it won't read anymore. For internal or special use, since it's called in the destructor. Definition at line 83 of file ArKeyHandler.cpp. Referenced by ArRobot::stopRunning(), and ~ArKeyHandler(). |
|
Takes the key control over. For internal or special use, since it's called in the constructor. Definition at line 61 of file ArKeyHandler.cpp. Referenced by ArKeyHandler(). |