#include <ArKeyHandler.h>
This class is used for handling input from the keyboard. Use addKeyHandler() to associate a functor with a keyboard key. ArKeyHandler will call that functor when the key is pressed.
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(). Only one key handler can be created in a program, and this lets independent parts of a program use the same key handler.
You can attach a key handler to a robot with ArRobot::attachKeyHandler() which will put a task into the robots list of tasks to check for new keyboard input in each cycle, and which will also add a handler to end the robot's task cycle when Escape is pressed (you can override this by replacing it with your own handler). If you have mulitple ArRobot objects, only create one key handler and attach it to one robot.
Alternatively, you can call checkKeys() periodically to check for new key input.
actionGroupExample.cpp, actsColorFollowingExample.cpp, demo.cpp, dpptuExample.cpp, gotoActionExample.cpp, gripperExample.cpp, gyroExample.cpp, lineFinderExample.cpp, sonyPTZDemo.cpp, triangleDriveToActionExample.cpp, vcc4CameraExample.cpp, and wander.cpp.
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 symbols 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, FILE *stream=NULL, bool takeKeysInConstructor=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 Member Functions | |
int | getChar (void) |
Protected Attributes | |
ArFunctorC< ArKeyHandler > | myAriaExitCB |
bool | myBlocking |
std::map< int, ArFunctor * > | myMap |
termios | myOriginalTermios |
bool | myRestored |
FILE * | myStream |
bool | myTookKeys |
|
|
This object will take over key capture when constructed, and release key capture when destroyed. |
|
Destructor. Reseases control of the keyboard and restores state before this key handler was created. |
|
This adds a keyhandler, when the keyToHandle is hit, functor will fire.
|
|
internal, use addKeyHandler instead... Gets a key from the stdin if ones available, -1 if there aren't any available |
|
This removes a key handler, by key.
|
|
This removes a key handler, by key.
|
|
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.
|
|
Takes the key control over. For internal or special use, since it's called in the constructor. |