00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * キーボード実装 00022 * @author Junpee 00023 */ 00024 00025 #include "LampBasic.h" 00026 #include "Input/Keyboard/Keyboard.h" 00027 00028 namespace Lamp{ 00029 00030 //------------------------------------------------------------------------------ 00031 // コンストラクタ 00032 Keyboard::Keyboard(KeyboardDevice* device) : device_(device){ 00033 } 00034 //------------------------------------------------------------------------------ 00035 // デストラクタ 00036 Keyboard::~Keyboard(){ 00037 } 00038 //------------------------------------------------------------------------------ 00039 // 次のステート設定 00040 void Keyboard::setNextState(const KeyboardState& state){ 00041 preState_ = state_; 00042 state_ = state; 00043 } 00044 //------------------------------------------------------------------------------ 00045 // 文字列への変換 00046 String Keyboard::toString() const{ 00047 String result, temp; 00048 result = getName(); 00049 result += " ("; 00050 if(isAttached()){ result += " Attached"; } 00051 if(isPolled()){ result += " NeedPolling"; } 00052 result += " )\n"; 00053 // キー 00054 temp.format("Keys %d\n", getKeyCount()); 00055 result += temp; 00056 00057 result += " Press "; 00058 for(int i = 0; i < maxKeyCount; i++){ 00059 Key key = (Key)i; 00060 if(pressed(key)){ result += keyToString(key) + " "; } 00061 } 00062 result += "\n"; 00063 00064 result += " Down "; 00065 for(int i = 0; i < maxKeyCount; i++){ 00066 Key key = (Key)i; 00067 if(down(key)){ result += keyToString(key) + " "; } 00068 } 00069 result += "\n"; 00070 00071 result += " Up "; 00072 for(int i = 0; i < maxKeyCount; i++){ 00073 Key key = (Key)i; 00074 if(up(key)){ result += keyToString(key) + " "; } 00075 } 00076 result += "\n"; 00077 return result; 00078 } 00079 //------------------------------------------------------------------------------ 00080 } // End of namespace Lamp 00081 //------------------------------------------------------------------------------