Blender V2.61 - r43446

SCA_KeyboardSensor.cpp

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  * Sensor for keyboard input
00027  */
00028 
00034 #include <stddef.h>
00035 
00036 #include "SCA_KeyboardSensor.h"
00037 #include "SCA_KeyboardManager.h"
00038 #include "SCA_LogicManager.h"
00039 #include "StringValue.h"
00040 #include "SCA_IInputDevice.h"
00041 
00042 /* ------------------------------------------------------------------------- */
00043 /* Native functions                                                          */
00044 /* ------------------------------------------------------------------------- */
00045 
00046 SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr,
00047                                        short int hotkey,
00048                                        short int qual,
00049                                        short int qual2,
00050                                        bool bAllKeys,
00051                                        const STR_String& targetProp,
00052                                        const STR_String& toggleProp,
00053                                        SCA_IObject* gameobj)
00054     :SCA_ISensor(gameobj,keybdmgr),
00055      m_hotkey(hotkey),
00056      m_qual(qual),
00057      m_qual2(qual2),
00058      m_bAllKeys(bAllKeys),
00059      m_targetprop(targetProp),
00060      m_toggleprop(toggleProp)
00061 {
00062     if (hotkey == SCA_IInputDevice::KX_ESCKEY)
00063         keybdmgr->GetInputDevice()->HookEscape();
00064 //  SetDrawColor(0xff0000ff);
00065     Init();
00066 }
00067 
00068 
00069 
00070 SCA_KeyboardSensor::~SCA_KeyboardSensor()
00071 {
00072 }
00073 
00074 void SCA_KeyboardSensor::Init()
00075 {
00076     // this function is used when the sensor is disconnected from all controllers
00077     // by the state engine. It reinitializes the sensor as if it was just created.
00078     // However, if the target key is pressed when the sensor is reactivated, it
00079     // will not generated an event (see remark in Evaluate()).
00080     m_val = (m_invert)?1:0;
00081     m_reset = true;
00082 }
00083 
00084 CValue* SCA_KeyboardSensor::GetReplica()
00085 {
00086     SCA_KeyboardSensor* replica = new SCA_KeyboardSensor(*this);
00087     // this will copy properties and so on...
00088     replica->ProcessReplica();
00089     replica->Init();
00090     return replica;
00091 }
00092 
00093 
00094 
00095 short int SCA_KeyboardSensor::GetHotkey()
00096 {
00097     return m_hotkey;
00098 }
00099 
00100 
00101 
00102 bool SCA_KeyboardSensor::IsPositiveTrigger()
00103 { 
00104     bool result = (m_val != 0);
00105 
00106     if (m_invert)
00107         result = !result;
00108         
00109     return result;
00110 }
00111 
00112 
00113 
00114 bool SCA_KeyboardSensor::TriggerOnAllKeys()
00115 { 
00116     return m_bAllKeys;
00117 }
00118 
00119 
00120 
00121 bool SCA_KeyboardSensor::Evaluate()
00122 {
00123     bool result    = false;
00124     bool reset     = m_reset && m_level;
00125     bool qual      = true;
00126     bool qual_change = false;
00127     short int m_val_orig = m_val;
00128     
00129     SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
00130     //      cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n";
00131 
00132     /* See if we need to do logging: togPropState exists and is
00133      * different from 0 */
00134     CValue* myparent = GetParent();
00135     CValue* togPropState = myparent->GetProperty(m_toggleprop);
00136     if (togPropState &&
00137         (((int)togPropState->GetNumber()) != 0) )
00138     {
00139         LogKeystrokes();
00140     }
00141 
00142     m_reset = false;
00143 
00144     /* Now see whether events must be bounced. */
00145     if (m_bAllKeys)
00146     {
00147         bool justactivated = false;
00148         bool justreleased = false;
00149         bool active = false;
00150 
00151         for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++)
00152         {
00153             const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
00154             switch (inevent.m_status) 
00155             { 
00156             case SCA_InputEvent::KX_JUSTACTIVATED:
00157                 justactivated = true;
00158                 break;
00159             case SCA_InputEvent::KX_JUSTRELEASED:
00160                 justreleased = true;
00161                 break;
00162             case SCA_InputEvent::KX_ACTIVE:
00163                 active = true;
00164                 break;
00165             case SCA_InputEvent::KX_NO_INPUTSTATUS:
00166                 /* do nothing */
00167                 break;
00168             }
00169         }
00170 
00171         if (justactivated)
00172         {
00173             m_val=1;
00174             result = true;
00175         } else
00176         {
00177             if (justreleased)
00178             {
00179                 m_val=(active)?1:0;
00180                 result = true;
00181             } else
00182             {
00183                 if (active)
00184                 {
00185                     if (m_val == 0)
00186                     {
00187                         m_val = 1;
00188                         if (m_level) {
00189                             result = true;
00190                         }
00191                     }
00192                 } else
00193                 {
00194                     if (m_val == 1)
00195                     {
00196                         m_val = 0;
00197                         result = true;
00198                     }
00199                 }
00200             }
00201             if (m_tap)
00202                 // special case for tap mode: only generate event for new activation
00203                 result = false;
00204         }
00205 
00206 
00207     } else
00208     {
00209 
00210     //      cerr << "======= SCA_KeyboardSensor::Evaluate:: peeking at key status" << endl;
00211         const SCA_InputEvent & inevent = inputdev->GetEventValue(
00212             (SCA_IInputDevice::KX_EnumInputs) m_hotkey);
00213     
00214     //      cerr << "======= SCA_KeyboardSensor::Evaluate:: status: " << inevent.m_status << endl;
00215         
00216         
00217         /* Check qualifier keys
00218          * - see if the qualifiers we request are pressed - 'qual' true/false
00219          * - see if the qualifiers we request changed their state - 'qual_change' true/false
00220          */
00221         if (m_qual > 0) {
00222             const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual);
00223             switch(qualevent.m_status) {
00224             case SCA_InputEvent::KX_NO_INPUTSTATUS:
00225                 qual = false;
00226                 break;
00227             case SCA_InputEvent::KX_JUSTRELEASED:
00228                 qual_change = true;
00229                 qual = false;
00230                 break;
00231             case SCA_InputEvent::KX_JUSTACTIVATED:
00232                 qual_change = true;
00233             case SCA_InputEvent::KX_ACTIVE:
00234                 /* do nothing */
00235                 break;
00236             }
00237         }
00238         if (m_qual2 > 0 && qual==true) {
00239             const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual2);
00240             /* copy of above */
00241             switch(qualevent.m_status) {
00242             case SCA_InputEvent::KX_NO_INPUTSTATUS:
00243                 qual = false;
00244                 break;
00245             case SCA_InputEvent::KX_JUSTRELEASED:
00246                 qual_change = true;
00247                 qual = false;
00248                 break;
00249             case SCA_InputEvent::KX_JUSTACTIVATED:
00250                 qual_change = true;
00251             case SCA_InputEvent::KX_ACTIVE:
00252                 /* do nothing */
00253                 break;
00254             }
00255         }
00256         /* done reading qualifiers */
00257         
00258         if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS)
00259         {
00260             if (m_val == 1)
00261             {
00262                 // this situation may occur after a scene suspend: the keyboard release 
00263                 // event was not captured, produce now the event off
00264                 m_val = 0;
00265                 result = true;
00266             }
00267         } else
00268         {
00269             if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
00270             {
00271                 m_val=1;
00272                 result = true;
00273             } else
00274             {
00275                 if (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)
00276                 {
00277                     m_val = 0;
00278                     result = true;
00279                 } else 
00280                 {
00281                     if (inevent.m_status == SCA_InputEvent::KX_ACTIVE)
00282                     {
00283                         if (m_val == 0)
00284                         {
00285                             m_val = 1;
00286                             if (m_level) 
00287                             {
00288                                 result = true;
00289                             }
00290                         }
00291                     }
00292                 }
00293             }
00294         }
00295         
00296         /* Modify the key state based on qual(s)
00297          * Tested carefuly. dont touch unless your really sure.
00298          * note, this will only change the results if key modifiers are set.
00299          *
00300          * When all modifiers and keys are positive
00301          *  - pulse true
00302          * 
00303          * When ANY of the modifiers or main key become inactive,
00304          *  - pulse false
00305          */
00306         if (qual==false) { /* one of the qualifiers are not pressed */
00307             if (m_val_orig && qual_change) { /* we were originally enabled, but a qualifier changed */
00308                 result = true;
00309             } else {
00310                 result = false;
00311             }
00312             m_val = 0; /* since one of the qualifiers is not on, set the state to false */
00313         } else {                        /* we done have any qualifiers or they are all pressed */
00314             if (m_val && qual_change) { /* the main key state is true and our qualifier just changed */
00315                 result = true;
00316             }
00317         }
00318         /* done with key quals */
00319         
00320     }
00321     
00322     if (reset)
00323         // force an event
00324         result = true;
00325     return result;
00326 
00327 }
00328 
00329 void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
00330 {
00331     if (IsPrintable(keyIndex)) {
00332         CValue* tprop = GetParent()->GetProperty(m_targetprop);
00333         
00334         if (tprop) {
00335             /* overwrite the old property */
00336             if (IsDelete(keyIndex)) {
00337                 /* strip one char, if possible */
00338                 STR_String newprop = tprop->GetText();
00339                 int oldlength = newprop.Length();
00340                 if (oldlength >= 1 ) {
00341                     newprop.SetLength(oldlength - 1);
00342                     CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
00343                     GetParent()->SetProperty(m_targetprop, newstringprop);
00344                     newstringprop->Release();
00345                 }               
00346             } else {
00347                 /* append */
00348                 char pchar = ToCharacter(keyIndex, IsShifted());
00349                 STR_String newprop = tprop->GetText() + pchar;
00350                 CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);         
00351                 GetParent()->SetProperty(m_targetprop, newstringprop);
00352                 newstringprop->Release();
00353             }
00354         } else {
00355             if (!IsDelete(keyIndex)) {
00356                 /* Make a new property. Deletes can be ignored. */
00357                 char pchar = ToCharacter(keyIndex, IsShifted());
00358                 STR_String newprop = pchar;
00359                 CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);         
00360                 GetParent()->SetProperty(m_targetprop, newstringprop);
00361                 newstringprop->Release();
00362             }
00363         }
00364     }
00365     
00366 }
00367     
00371 bool SCA_KeyboardSensor::IsShifted(void)
00372 {
00373     SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
00374     
00375     if ( (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status 
00376           == SCA_InputEvent::KX_ACTIVE)
00377          || (inputdev->GetEventValue(SCA_IInputDevice::KX_RIGHTSHIFTKEY).m_status 
00378              == SCA_InputEvent::KX_JUSTACTIVATED)
00379          || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status 
00380              == SCA_InputEvent::KX_ACTIVE)
00381          || (inputdev->GetEventValue(SCA_IInputDevice::KX_LEFTSHIFTKEY).m_status 
00382              == SCA_InputEvent::KX_JUSTACTIVATED)
00383         ) {
00384         return true;
00385     } else {
00386         return false;
00387     }   
00388 }
00389 
00390 void SCA_KeyboardSensor::LogKeystrokes(void) 
00391 {
00392     SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
00393     int num = inputdev->GetNumActiveEvents();
00394 
00395     /* weird loop, this one... */
00396     if (num > 0)
00397     {
00398         
00399         int index = 0;
00400         /* Check on all keys whether they were pushed. This does not
00401          * untangle the ordering, so don't type too fast :) */
00402         for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++)
00403         {
00404             const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
00405             if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) //NO_INPUTSTATUS)
00406             {
00407                 if (index < num)
00408                 {
00409                     AddToTargetProp(i);
00410                     index++;
00411                 }
00412             }
00413         }
00414     }
00415 }
00416 
00417 #ifdef WITH_PYTHON
00418 
00419 /* ------------------------------------------------------------------------- */
00420 /* Python Functions                            */
00421 /* ------------------------------------------------------------------------- */
00422 
00423 KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
00424 "getKeyStatus(keycode)\n"
00425 "\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
00426 {
00427     if (!PyLong_Check(value)) {
00428         PyErr_SetString(PyExc_ValueError, "sensor.getKeyStatus(int): Keyboard Sensor, expected an int");
00429         return NULL;
00430     }
00431     
00432     int keycode = PyLong_AsSsize_t(value);
00433     
00434     if ((keycode < SCA_IInputDevice::KX_BEGINKEY)
00435         || (keycode > SCA_IInputDevice::KX_ENDKEY)){
00436         PyErr_SetString(PyExc_AttributeError, "sensor.getKeyStatus(int): Keyboard Sensor, invalid keycode specified!");
00437         return NULL;
00438     }
00439     
00440     SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)m_eventmgr)->GetInputDevice();
00441     const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode);
00442     return PyLong_FromSsize_t(inevent.m_status);
00443 }
00444 
00445 /* ------------------------------------------------------------------------- */
00446 /* Python Integration Hooks                        */
00447 /* ------------------------------------------------------------------------- */
00448 
00449 PyTypeObject SCA_KeyboardSensor::Type = {
00450     PyVarObject_HEAD_INIT(NULL, 0)
00451     "SCA_KeyboardSensor",
00452     sizeof(PyObjectPlus_Proxy),
00453     0,
00454     py_base_dealloc,
00455     0,
00456     0,
00457     0,
00458     0,
00459     py_base_repr,
00460     0,0,0,0,0,0,0,0,0,
00461     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
00462     0,0,0,0,0,0,0,
00463     Methods,
00464     0,
00465     0,
00466     &SCA_ISensor::Type,
00467     0,0,0,0,0,0,
00468     py_base_new
00469 };
00470 
00471 PyMethodDef SCA_KeyboardSensor::Methods[] = {
00472     KX_PYMETHODTABLE_O(SCA_KeyboardSensor, getKeyStatus),
00473     {NULL,NULL} //Sentinel
00474 };
00475 
00476 PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
00477     KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_KeyboardSensor, pyattr_get_events),
00478     KX_PYATTRIBUTE_BOOL_RW("useAllKeys",SCA_KeyboardSensor,m_bAllKeys),
00479     KX_PYATTRIBUTE_INT_RW("key",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_hotkey),
00480     KX_PYATTRIBUTE_SHORT_RW("hold1",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_qual),
00481     KX_PYATTRIBUTE_SHORT_RW("hold2",0,SCA_IInputDevice::KX_ENDKEY,true,SCA_KeyboardSensor,m_qual2),
00482     KX_PYATTRIBUTE_STRING_RW("toggleProperty",0,MAX_PROP_NAME,false,SCA_KeyboardSensor,m_toggleprop),
00483     KX_PYATTRIBUTE_STRING_RW("targetProperty",0,MAX_PROP_NAME,false,SCA_KeyboardSensor,m_targetprop),
00484     { NULL }    //Sentinel
00485 };
00486 
00487 
00488 PyObject* SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
00489 {
00490     SCA_KeyboardSensor* self= static_cast<SCA_KeyboardSensor*>(self_v);
00491     
00492     SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)self->m_eventmgr)->GetInputDevice();
00493 
00494     PyObject* resultlist = PyList_New(0);
00495     
00496     for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++)
00497     {
00498         const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
00499         if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
00500         {
00501             PyObject* keypair = PyList_New(2);
00502             PyList_SET_ITEM(keypair,0,PyLong_FromSsize_t(i));
00503             PyList_SET_ITEM(keypair,1,PyLong_FromSsize_t(inevent.m_status));
00504             PyList_Append(resultlist,keypair);
00505         }
00506     }   
00507     return resultlist;
00508 }
00509 
00510 #endif // WITH_PYTHON
00511 
00512 /* Accessed from python */
00513 
00514 // this code looks ugly, please use an ordinary hashtable
00515 
00516 char ToCharacter(int keyIndex, bool shifted)
00517 {
00518     /* numerals */
00519     if ( (keyIndex >= SCA_IInputDevice::KX_ZEROKEY) 
00520          && (keyIndex <= SCA_IInputDevice::KX_NINEKEY) ) {
00521         if (shifted) {
00522             char numshift[] = ")!@#$%^&*(";
00523             return numshift[keyIndex - '0']; 
00524         } else {
00525             return keyIndex - SCA_IInputDevice::KX_ZEROKEY + '0'; 
00526         }
00527     }
00528     
00529     /* letters... always lowercase... is that desirable? */
00530     if ( (keyIndex >= SCA_IInputDevice::KX_AKEY) 
00531          && (keyIndex <= SCA_IInputDevice::KX_ZKEY) ) {
00532         if (shifted) {
00533             return keyIndex - SCA_IInputDevice::KX_AKEY + 'A'; 
00534         } else {
00535             return keyIndex - SCA_IInputDevice::KX_AKEY + 'a'; 
00536         }
00537     }
00538     
00539     if (keyIndex == SCA_IInputDevice::KX_SPACEKEY) {
00540         return ' ';
00541     }
00542     if (keyIndex == SCA_IInputDevice::KX_RETKEY || keyIndex == SCA_IInputDevice::KX_PADENTER) {
00543         return '\n';
00544     }
00545     
00546     
00547     if (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) {
00548         return '*';
00549     }
00550     
00551     if (keyIndex == SCA_IInputDevice::KX_TABKEY) {
00552         return '\t';
00553     }
00554     
00555     /* comma to period */
00556     char commatoperiod[] = ",-.";
00557     char commatoperiodshifted[] = "<_>";
00558     if (keyIndex == SCA_IInputDevice::KX_COMMAKEY) {
00559         if (shifted) {
00560             return commatoperiodshifted[0];
00561         } else {
00562             return commatoperiod[0];
00563         }
00564     }
00565     if (keyIndex == SCA_IInputDevice::KX_MINUSKEY) {
00566         if (shifted) {
00567             return commatoperiodshifted[1];
00568         } else {
00569             return commatoperiod[1];
00570         }
00571     }
00572     if (keyIndex == SCA_IInputDevice::KX_PERIODKEY) {
00573         if (shifted) {
00574             return commatoperiodshifted[2];
00575         } else {
00576             return commatoperiod[2];
00577         }
00578     }
00579     
00580     /* semicolon to rightbracket */
00581     char semicolontorightbracket[] = ";\'`/\\=[]";
00582     char semicolontorightbracketshifted[] = ":\"~\?|+{}";
00583     if ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY) 
00584         && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY)) {
00585         if (shifted) {
00586             return semicolontorightbracketshifted[keyIndex - SCA_IInputDevice::KX_SEMICOLONKEY];
00587         } else {
00588             return semicolontorightbracket[keyIndex - SCA_IInputDevice::KX_SEMICOLONKEY];
00589         }
00590     }
00591     
00592     /* keypad2 to padplus */
00593     char pad2topadplus[] = "246813579. 0- +";
00594     if ((keyIndex >= SCA_IInputDevice::KX_PAD2) 
00595         && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) { 
00596         return pad2topadplus[keyIndex - SCA_IInputDevice::KX_PAD2];
00597     }
00598 
00599     return '!';
00600 }
00601 
00602 
00603 
00608 bool IsPrintable(int keyIndex)
00609 {
00610     /* only print 
00611      * - numerals: KX_ZEROKEY to KX_NINEKEY
00612      * - alphas:   KX_AKEY to KX_ZKEY. 
00613      * - specials: KX_RETKEY, KX_PADASTERKEY, KX_PADCOMMAKEY to KX_PERIODKEY,
00614      *             KX_TABKEY , KX_SEMICOLONKEY to KX_RIGHTBRACKETKEY, 
00615      *             KX_PAD2 to KX_PADPLUSKEY
00616      * - delete and backspace: also printable in the sense that they modify 
00617      *                         the string
00618      * - retkey: should this be printable?
00619      * - virgule: prints a space... don't know which key that's supposed
00620      *   to be...
00621      */
00622     if ( ((keyIndex >= SCA_IInputDevice::KX_ZEROKEY) 
00623           && (keyIndex <= SCA_IInputDevice::KX_NINEKEY))
00624          || ((keyIndex >= SCA_IInputDevice::KX_AKEY) 
00625              && (keyIndex <= SCA_IInputDevice::KX_ZKEY)) 
00626          || (keyIndex == SCA_IInputDevice::KX_SPACEKEY) 
00627          || (keyIndex == SCA_IInputDevice::KX_RETKEY)
00628          || (keyIndex == SCA_IInputDevice::KX_PADENTER)
00629          || (keyIndex == SCA_IInputDevice::KX_PADASTERKEY) 
00630          || (keyIndex == SCA_IInputDevice::KX_TABKEY) 
00631          || ((keyIndex >= SCA_IInputDevice::KX_COMMAKEY) 
00632              && (keyIndex <= SCA_IInputDevice::KX_PERIODKEY)) 
00633          || ((keyIndex >= SCA_IInputDevice::KX_SEMICOLONKEY) 
00634              && (keyIndex <= SCA_IInputDevice::KX_RIGHTBRACKETKEY)) 
00635          || ((keyIndex >= SCA_IInputDevice::KX_PAD2) 
00636              && (keyIndex <= SCA_IInputDevice::KX_PADPLUSKEY)) 
00637          || (keyIndex == SCA_IInputDevice::KX_DELKEY)
00638          || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY)
00639         )
00640     {
00641         return true;
00642     } else {
00643         return false;
00644     }
00645 }
00646 
00650 bool IsDelete(int keyIndex)
00651 {
00652     if ( (keyIndex == SCA_IInputDevice::KX_DELKEY)
00653          || (keyIndex == SCA_IInputDevice::KX_BACKSPACEKEY) ) {
00654         return true;
00655     } else {
00656         return false;
00657     }
00658 }