Main Page   Class Hierarchy   Compound List   Compound Members  

ArKeyHandler Class Reference

This class will read input from the keyboard. More...

#include <ArKeyHandler.h>

List of all members.

Public Types

enum  KEY {
  UP = 256, DOWN, LEFT, RIGHT,
  ESCAPE, SPACE, TAB, ENTER,
  BACKSPACE, F1, F2, F3,
  F4
}
 These are enums for the non-ascii keys. More...


Public Methods

 ArKeyHandler (bool blocking=false)
 Constructor. More...

 ~ArKeyHandler (void)
 Destructor.

bool addKeyHandler (int keyToHandle, ArFunctor *functor)
 This adds a keyhandler, when the keyToHandle is hit, functor will fire. More...

bool remKeyHandler (int keyToHandler)
 This removes a key handler, by key. More...

bool remKeyHandler (ArFunctor *functor)
 This removes a key handler, by key. More...

void restore (void)
 Sets stdin back to its original settings, if its been restored it won't read anymore.

void checkKeys (void)
 intnernal, use addKeyHandler, Checks for keys and handles them.

int getKey (void)
 internal, use addKeyHandler instead... Gets a key from the stdin if ones available, -1 if there aren't any available.


Detailed Description

This class will read input from the keyboard.

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.


Member Enumeration Documentation

enum ArKeyHandler::KEY
 

These are enums for the non-ascii keys.

Enumeration values:
UP  Up arrow (keypad or 4 key dirs).
DOWN  Down arrow (keypad or 4 key dirs).
LEFT  Left arrow (keypad or 4 key dirs).
RIGHT  Right arrow (keypad or 4 key dirs).
ESCAPE  Escape key.
SPACE  Space key.
TAB  Tab key.
ENTER  Enter key.
BACKSPACE  Backspace key.
F1  F1.
F2  F2.
F3  F3.
F4  F4.


Constructor & Destructor Documentation

ArKeyHandler::ArKeyHandler bool    blocking = false
 

Constructor.

Parameters:
blocking  whether or not to block waiting on keys, default is false, ie not to wait... you probably only want to block if you are using checkKeys yourself like after you start a robot run or in its own thread or something along those lines


Member Function Documentation

bool ArKeyHandler::addKeyHandler int    keyToHandle,
ArFunctor   functor
 

This adds a keyhandler, when the keyToHandle is hit, functor will fire.

Parameters:
keyToHandle  this is an ascii character, such as 'a' or '1' or '[', or a member of the KEY enum.
functor  a functor to call when the given key is pressed
Returns:
true if the addKeyHandler succeeded, which means that the key added was unique and it will be handled... false means that the add failed, because there was already a keyHandler in place for that key

bool ArKeyHandler::remKeyHandler ArFunctor   functor
 

This removes a key handler, by key.

Parameters:
keyToHandle  the functor to remove
Returns:
true if the remKeyHandler succeeded, which means that the key wad found and rmeoved... false means that the remove failed because there was no key for that

bool ArKeyHandler::remKeyHandler int    keyToHandle
 

This removes a key handler, by key.

Parameters:
keyToHandle  this is an ascii character, such as 'a' or '1' or '[', or a member of the KEY enum.
Returns:
true if the remKeyHandler succeeded, which means that the key wad found and rmeoved... false means that the remove failed because there was no key for that


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:43:57 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001