Blender  V2.59
SCA_KeyboardSensor.h
Go to the documentation of this file.
00001 /*
00002  * $Id: SCA_KeyboardSensor.h 35063 2011-02-22 10:33:14Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (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 Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00035 #ifndef __KX_KEYBOARDSENSOR
00036 #define __KX_KEYBOARDSENSOR
00037 
00038 #include "SCA_ISensor.h"
00039 #include "BoolValue.h"
00040 #include <list>
00041 
00047 class SCA_KeyboardSensor : public SCA_ISensor
00048 {
00049         Py_Header;
00050 
00054         int                                                     m_hotkey;
00055         short int                                       m_qual,m_qual2;
00056         short int                                       m_val;
00061         bool                                            m_bAllKeys;
00062 
00067         STR_String      m_targetprop;
00074         STR_String      m_toggleprop;
00075 
00079         void LogKeystrokes(void);
00080         
00084         void AddToTargetProp(int keyIndex);
00085 
00089         bool IsShifted(void);
00090         
00091 public:
00092         SCA_KeyboardSensor(class SCA_KeyboardManager* keybdmgr,
00093                                            short int hotkey,
00094                                            short int qual,
00095                                            short int qual2,
00096                                            bool bAllKeys,
00097                                            const STR_String& targetProp,
00098                                            const STR_String& toggleProp,
00099                                            SCA_IObject* gameobj);
00100         virtual ~SCA_KeyboardSensor();
00101         virtual CValue* GetReplica();
00102         virtual void Init();
00103 
00104 
00105         short int GetHotkey();
00106         virtual bool Evaluate();
00107         virtual bool IsPositiveTrigger();
00108         bool    TriggerOnAllKeys();
00109 
00110 #ifdef WITH_PYTHON
00111         /* --------------------------------------------------------------------- */
00112         /* Python interface ---------------------------------------------------- */
00113         /* --------------------------------------------------------------------- */
00114 
00115         // KeyEvents: 
00116         KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList); 
00117         // KeyStatus: 
00118         KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus);
00119         
00120         static PyObject*        pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00121 #endif
00122 };
00123 
00124 
00128 char ToCharacter(int keyIndex, bool shifted);
00129 
00134 bool IsPrintable(int keyIndex);
00135 
00139 bool IsDelete(int keyIndex);
00140 
00141 
00142 #endif //__KX_KEYBOARDSENSOR
00143 
00144 
00145