Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

KX_BlenderKeyboardDevice.cpp

Go to the documentation of this file.
00001 
00002 #ifdef WIN32
00003 // annoying warnings about truncated STL debug info
00004 #pragma warning (disable :4786)
00005 #endif 
00006 
00007 #include "KX_BlenderKeyboardDevice.h"
00008 
00009 KX_BlenderKeyboardDevice::KX_BlenderKeyboardDevice()

00010 {
00011 
00012 }
00013 KX_BlenderKeyboardDevice::~KX_BlenderKeyboardDevice()

00014 {
00015 
00016 }
00017 
00021 
00022 bool KX_BlenderKeyboardDevice::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)

00023 {
00024         const SCA_InputEvent & inevent =  m_eventStatusTables[m_currentTable][inputcode];
00025         bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED || 
00026                 inevent.m_status == SCA_InputEvent::KX_ACTIVE);
00027         return pressed;
00028 }
00029 /*const SCA_InputEvent& KX_BlenderKeyboardDevice::GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)

00030 {

00031         return m_eventStatusTables[m_currentTable][inputcode];

00032 }

00033 */
00039 void    KX_BlenderKeyboardDevice::NextFrame()

00040 {
00041         SCA_IInputDevice::NextFrame();
00042         
00043         // now convert justpressed keyevents into regular (active) keyevents
00044         int previousTable = 1-m_currentTable;
00045         for (int keyevent= KX_BEGINKEY; keyevent< KX_ENDKEY;keyevent++)
00046         {
00047                 SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][keyevent];
00048                 if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
00049                         oldevent.m_status == SCA_InputEvent::KX_ACTIVE  )
00050                 {
00051                         m_eventStatusTables[m_currentTable][keyevent] = oldevent;
00052                         m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_ACTIVE;
00053                 }
00054         }
00055 }
00056 
00061 
00062 
00063 bool    KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode,short val)

00064 {
00065         bool result = false;
00066         
00067         // convert event
00068         KX_EnumInputs kxevent = this->ToNative(incode);
00069 
00070         // only process it, if it's a key
00071         if (kxevent >= KX_BEGINKEY && kxevent < KX_ENDKEY)
00072         {
00073                 int previousTable = 1-m_currentTable;
00074 
00075                 if (val > 0)
00076                 {
00077                         if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0)
00078                                 result = true;
00079 
00080                         // todo: convert val ??
00081                         m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //???
00082 
00083                         switch (m_eventStatusTables[previousTable][kxevent].m_status)
00084                         {
00085                         case SCA_InputEvent::KX_JUSTACTIVATED:
00086                                 {
00087                                         m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
00088                                         break;
00089                                 }
00090                         case SCA_InputEvent::KX_ACTIVE:
00091                         
00092                                 {
00093                                         m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
00094                                         break;
00095                                 }
00096                         case SCA_InputEvent::KX_NO_INPUTSTATUS:
00097                                 {
00098                                                 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
00099                                                 break;
00100                                 }
00101                         default:
00102                                 {
00103                                         m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
00104                                 }
00105                         }
00106                         
00107                 } else
00108                 {
00109                         // blender eventval == 0
00110                         switch (m_eventStatusTables[previousTable][kxevent].m_status)
00111                         {
00112                         case SCA_InputEvent::KX_JUSTACTIVATED:
00113                                 {
00114                                         m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
00115                                         break;
00116                                 }
00117                         case SCA_InputEvent::KX_ACTIVE:
00118                                 {
00119                                         m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
00120                                         break;
00121                                 }
00122                         default:
00123                                 {
00124                                         m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
00125                                 }
00126                         }
00127                 }
00128         }
00129         return result;
00130 }

Generated at Thu Feb 1 13:03:04 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000