|
Blender
V2.59
|
00001 /* 00002 * $Id: GPC_KeyboardDevice.cpp 35170 2011-02-25 13:35:11Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #include "GPC_KeyboardDevice.h" 00036 00037 #include <cstdlib> 00038 00044 void GPC_KeyboardDevice::NextFrame() 00045 { 00046 SCA_IInputDevice::NextFrame(); 00047 00048 // Now convert justpressed key events into regular (active) keyevents 00049 int previousTable = 1-m_currentTable; 00050 for (int keyevent= KX_BEGINKEY; keyevent<= KX_ENDKEY;keyevent++) 00051 { 00052 SCA_InputEvent& oldevent = m_eventStatusTables[previousTable][keyevent]; 00053 if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED || 00054 oldevent.m_status == SCA_InputEvent::KX_ACTIVE ) 00055 { 00056 m_eventStatusTables[m_currentTable][keyevent] = oldevent; 00057 m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_ACTIVE; 00058 //m_eventStatusTables[m_currentTable][keyevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED ; 00059 } 00060 } 00061 } 00062 00063 00064 00069 bool GPC_KeyboardDevice::ConvertEvent(int incode, int val) 00070 { 00071 bool result = false; 00072 00073 // convert event 00074 KX_EnumInputs kxevent = this->ToNative(incode); 00075 00076 // only process it, if it's a key 00077 if (kxevent >= KX_BEGINKEY && kxevent <= KX_ENDKEY) 00078 { 00079 int previousTable = 1-m_currentTable; 00080 00081 if (val > 0) 00082 { 00083 if (kxevent == SCA_IInputDevice::KX_ESCKEY && val != 0 && !m_hookesc) 00084 result = true; 00085 00086 // todo: convert val ?? 00087 m_eventStatusTables[m_currentTable][kxevent].m_eventval = val ; //??? 00088 00089 switch (m_eventStatusTables[previousTable][kxevent].m_status) 00090 { 00091 case SCA_InputEvent::KX_JUSTACTIVATED: 00092 case SCA_InputEvent::KX_ACTIVE: 00093 { 00094 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE; 00095 break; 00096 } 00097 00098 case SCA_InputEvent::KX_NO_INPUTSTATUS: 00099 default: 00100 { 00101 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED; 00102 } 00103 } 00104 00105 } else 00106 { 00107 00108 switch (m_eventStatusTables[previousTable][kxevent].m_status) 00109 { 00110 case SCA_InputEvent::KX_JUSTACTIVATED: 00111 case SCA_InputEvent::KX_ACTIVE: 00112 { 00113 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTRELEASED; 00114 break; 00115 } 00116 default: 00117 { 00118 m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS; 00119 } 00120 } 00121 } 00122 } 00123 return result; 00124 } 00125 00126 void GPC_KeyboardDevice::HookEscape() 00127 { 00128 m_hookesc = true; 00129 }