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