[657] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #include "OgreStableHeaders.h"
|
---|
| 26 |
|
---|
| 27 | #include "OgreString.h"
|
---|
| 28 | #include "OgreKeyEvent.h"
|
---|
| 29 | #include "OgreStringConverter.h"
|
---|
| 30 | #include "OgrePositionTarget.h"
|
---|
| 31 | #include "OgreInput.h"
|
---|
| 32 |
|
---|
| 33 | namespace Ogre {
|
---|
| 34 |
|
---|
| 35 | KeyEvent::KeyEvent(PositionTarget* source, int id, int key, Real when, int modifiers) :
|
---|
| 36 | InputEvent(source, id, when, modifiers),
|
---|
| 37 | mKey(key)
|
---|
| 38 | {
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | int KeyEvent::getKey()
|
---|
| 42 | {
|
---|
| 43 | return mKey;
|
---|
| 44 |
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | char KeyEvent::getKeyChar()
|
---|
| 49 | {
|
---|
| 50 | return InputReader::getKeyChar(mKey, mModifiers);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | /**
|
---|
| 54 | * Returns a parameter string identifying this event.
|
---|
| 55 | * This method is useful for event-logging and for debugging.
|
---|
| 56 | *
|
---|
| 57 | * @return a string identifying the event and its attributes
|
---|
| 58 | */
|
---|
| 59 | String KeyEvent::paramString() const {
|
---|
| 60 | String typeStr;
|
---|
| 61 | switch(mId) {
|
---|
| 62 | case KE_KEY_PRESSED:
|
---|
| 63 | typeStr = "KEY_PRESSED";
|
---|
| 64 | break;
|
---|
| 65 | case KE_KEY_RELEASED:
|
---|
| 66 | typeStr = "KEY_RELEASED";
|
---|
| 67 | break;
|
---|
| 68 | case KE_KEY_CLICKED:
|
---|
| 69 | typeStr = "KEY_CLICKED";
|
---|
| 70 | break;
|
---|
| 71 | case KE_KEY_FOCUSIN:
|
---|
| 72 | typeStr = "KEY_FOCUSIN";
|
---|
| 73 | break;
|
---|
| 74 | case KE_KEY_FOCUSOUT:
|
---|
| 75 | typeStr = "KEY_FOCUSOUT";
|
---|
| 76 | break;
|
---|
| 77 | default:
|
---|
| 78 | typeStr = "unknown type";
|
---|
| 79 | }
|
---|
| 80 | return typeStr + ", key="+StringConverter::toString(mKey);
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|