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

ArKeyHandler.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
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 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARKEYHANDLER_H
00027 #define ARKEYHANDLER_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ArFunctor.h"
00031 #include <map>
00032 
00033 #ifndef WIN32
00034 #include <termios.h>
00035 #include <unistd.h>
00036 #endif
00037 
00038 
00040 
00056 class ArKeyHandler
00057 {
00058 public:
00061   AREXPORT ArKeyHandler(bool blocking = false, bool addAriaExitCB = true);
00062 
00065   AREXPORT ~ArKeyHandler();
00066 
00068   enum KEY {
00069     UP = 256, 
00070     DOWN, 
00071     LEFT, 
00072     RIGHT, 
00073     ESCAPE, 
00074     SPACE, 
00075     TAB, 
00076     ENTER, 
00077     BACKSPACE, 
00078     _StartFKeys,  
00079     F1, 
00080     F2, 
00081     F3, 
00082     F4, 
00083     F5, 
00084     F6, 
00085     F7, 
00086     F8, 
00087     F9, 
00088     F10, 
00089     F11, 
00090     F12, 
00091     _EndFKeys, 
00092     PAGEUP, 
00093     PAGEDOWN, 
00094     HOME,   
00095     END,    
00096     INSERT, 
00097     DEL  
00098   };
00099 
00101   AREXPORT bool addKeyHandler(int keyToHandle, ArFunctor *functor);
00102 
00104   AREXPORT bool remKeyHandler(int keyToHandler);
00106   AREXPORT bool remKeyHandler(ArFunctor *functor);
00107 
00110   AREXPORT void takeKeys(bool blocking = false);
00111 
00115   AREXPORT void restore(void);
00116 
00118   AREXPORT void checkKeys(void);
00119   
00122   AREXPORT int getKey(void);
00123 
00124 protected:
00125   std::map<int, ArFunctor *> myMap;
00126   bool myBlocking;
00127   
00128   bool myRestored;
00129   ArFunctorC<ArKeyHandler> myAriaExitCB;
00130 #ifndef WIN32
00131   struct termios myOriginalTermios;
00132 #endif
00133 };
00134 
00135 
00136 #endif // ARKEYHANDLER_H

Generated on Tue Feb 20 10:51:40 2007 for Aria by  doxygen 1.4.0