00001 #include "GlutKeyboardDevice.h"
00002
00003
00009 void GlutKeyboardDevice::NextFrame()
00010 {
00011 SCA_IInputDevice::NextFrame();
00012
00013
00014 int previousTable = 1-m_currentTable;
00015 for (int keyevent= KX_BEGINKEY; keyevent< KX_ENDKEY;keyevent++)
00016 {
00017 SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][keyevent];
00018 if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
00019 oldevent.m_status == SCA_InputEvent::KX_ACTIVE )
00020 {
00021 m_eventStatusTables[m_currentTable][keyevent] = oldevent;
00022 m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_ACTIVE;
00023 }
00024 }
00025 }
00026
00027
00028
00033
00034
00035 bool GlutKeyboardDevice::ConvertGlutEvent(int incode,int val)
00036 {
00037 bool result = false;
00038
00039
00040 KX_EnumInputs kxevent = this->ToNative(incode);
00041
00042
00043 if (kxevent >= KX_BEGINKEY && kxevent < KX_ENDKEY)
00044 {
00045 int previousTable = 1-m_currentTable;
00046
00047 if (val > 0)
00048 {
00049 if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0)
00050 result = true;
00051
00052
00053 m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ;
00054
00055 switch (m_eventStatusTables[previousTable][kxevent].m_status)
00056 {
00057 case SCA_InputEvent::KX_JUSTACTIVATED:
00058 {
00059 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
00060 break;
00061 }
00062 case SCA_InputEvent::KX_ACTIVE:
00063
00064 {
00065 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
00066 break;
00067 }
00068 case SCA_InputEvent::KX_NO_INPUTSTATUS:
00069 {
00070 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
00071 break;
00072 }
00073 default:
00074 {
00075 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
00076 }
00077 }
00078
00079 } else
00080 {
00081
00082 switch (m_eventStatusTables[previousTable][kxevent].m_status)
00083 {
00084 case SCA_InputEvent::KX_JUSTACTIVATED:
00085 {
00086 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
00087 break;
00088 }
00089 case SCA_InputEvent::KX_ACTIVE:
00090 {
00091 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED;
00092 break;
00093 }
00094 default:
00095 {
00096 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
00097 }
00098 }
00099 }
00100 }
00101 return result;
00102 }