Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArKeyHandler.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARKEYHANDLER_H
00028 #define ARKEYHANDLER_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArFunctor.h"
00032 #include <map>
00033 
00034 #ifndef WIN32
00035 #include <termios.h>
00036 #include <unistd.h>
00037 #endif
00038 
00039 class ArRobot;
00040 
00042 
00058 class ArKeyHandler
00059 {
00060 public:
00063   ArKeyHandler(bool blocking = false, bool addAriaExitCB = true);
00064 
00067   ~ArKeyHandler();
00068 
00070   enum KEY {
00071     UP = 256, 
00072     DOWN, 
00073     LEFT, 
00074     RIGHT, 
00075     ESCAPE, 
00076     SPACE, 
00077     TAB, 
00078     ENTER, 
00079     BACKSPACE, 
00080     _StartFKeys,  
00081     F1, 
00082     F2, 
00083     F3, 
00084     F4, 
00085     F5, 
00086     F6, 
00087     F7, 
00088     F8, 
00089     F9, 
00090     F10, 
00091     F11, 
00092     F12, 
00093     _EndFKeys, 
00094     PAGEUP, 
00095     PAGEDOWN, 
00096     HOME,   
00097     END,    
00098     INSERT, 
00099     DEL  
00100   };
00101 
00103   bool addKeyHandler(int keyToHandle, ArFunctor *functor);
00104 
00106   bool remKeyHandler(int keyToHandler);
00108   bool remKeyHandler(ArFunctor *functor);
00109 
00112   void takeKeys(bool blocking = false);
00113 
00117   void restore(void);
00118 
00120   void checkKeys(void);
00121   
00124   int getKey(void);
00125 
00126 protected:
00127   std::map<int, ArFunctor *> myMap;
00128   bool myBlocking;
00129   
00130   bool myRestored;
00131   ArFunctorC<ArKeyHandler> myAriaExitCB;
00132 #ifndef WIN32
00133   struct termios myOriginalTermios;
00134 #endif
00135 };
00136 
00137 
00138 #endif // ARKEYHANDLER_H

Generated on Wed Oct 19 12:56:36 2005 for Aria by  doxygen 1.4.0