Blender V2.61 - r43446

SCA_KeyboardSensor.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #ifndef __KX_KEYBOARDSENSOR
00034 #define __KX_KEYBOARDSENSOR
00035 
00036 #include "SCA_ISensor.h"
00037 #include "BoolValue.h"
00038 #include <list>
00039 
00045 class SCA_KeyboardSensor : public SCA_ISensor
00046 {
00047     Py_Header
00048 
00052     int                         m_hotkey;
00053     short int                   m_qual,m_qual2;
00054     short int                   m_val;
00059     bool                        m_bAllKeys;
00060 
00065     STR_String  m_targetprop;
00072     STR_String  m_toggleprop;
00073 
00077     void LogKeystrokes(void);
00078     
00082     void AddToTargetProp(int keyIndex);
00083 
00087     bool IsShifted(void);
00088     
00089 public:
00090     SCA_KeyboardSensor(class SCA_KeyboardManager* keybdmgr,
00091                        short int hotkey,
00092                        short int qual,
00093                        short int qual2,
00094                        bool bAllKeys,
00095                        const STR_String& targetProp,
00096                        const STR_String& toggleProp,
00097                        SCA_IObject* gameobj);
00098     virtual ~SCA_KeyboardSensor();
00099     virtual CValue* GetReplica();
00100     virtual void Init();
00101 
00102 
00103     short int GetHotkey();
00104     virtual bool Evaluate();
00105     virtual bool IsPositiveTrigger();
00106     bool    TriggerOnAllKeys();
00107 
00108 #ifdef WITH_PYTHON
00109     /* --------------------------------------------------------------------- */
00110     /* Python interface ---------------------------------------------------- */
00111     /* --------------------------------------------------------------------- */
00112 
00113     // KeyEvents: 
00114     KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList);
00115     // KeyStatus: 
00116     KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus);
00117     
00118     static PyObject*    pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
00119 #endif
00120 };
00121 
00122 
00126 char ToCharacter(int keyIndex, bool shifted);
00127 
00132 bool IsPrintable(int keyIndex);
00133 
00137 bool IsDelete(int keyIndex);
00138 
00139 
00140 #endif //__KX_KEYBOARDSENSOR
00141 
00142 
00143