1 |
|
---|
2 | /*
|
---|
3 | -----------------------------------------------------------------------------
|
---|
4 | This source file is part of OGRE
|
---|
5 | (Object-oriented Graphics Rendering Engine)
|
---|
6 | For the latest info, see http://www.ogre3d.org/
|
---|
7 |
|
---|
8 | Copyright (c) 2000-2005 The OGRE Team
|
---|
9 | Also see acknowledgements in Readme.html
|
---|
10 |
|
---|
11 | This program is free software you can redistribute it and/or modify it under
|
---|
12 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
13 | Foundation either version 2 of the License, or (at your option) any later
|
---|
14 | version.
|
---|
15 |
|
---|
16 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
17 | ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
21 | this program if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
23 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
24 | -----------------------------------------------------------------------------
|
---|
25 | */
|
---|
26 | #include "OgreStableHeaders.h"
|
---|
27 |
|
---|
28 | #include "OgreKeyTarget.h"
|
---|
29 | #include "OgreKeyEvent.h"
|
---|
30 | #include "OgreEventListeners.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | namespace Ogre {
|
---|
34 | //-----------------------------------------------------------------------
|
---|
35 | void KeyTarget::processKeyEvent(KeyEvent* e)
|
---|
36 | {
|
---|
37 | // Remove all marked listeners
|
---|
38 | std::set<KeyListener*>::iterator i;
|
---|
39 | for (i = mRemovedListeners.begin(); i != mRemovedListeners.end(); i++)
|
---|
40 | {
|
---|
41 | mKeyListeners.erase(*i);
|
---|
42 | }
|
---|
43 | mRemovedListeners.clear();
|
---|
44 |
|
---|
45 | // Tell all listeners
|
---|
46 | for (i= mKeyListeners.begin(); i != mKeyListeners.end(); i++)
|
---|
47 | {
|
---|
48 | KeyListener* listener = *i;
|
---|
49 | if (listener != 0)
|
---|
50 | {
|
---|
51 | int id = e->getID();
|
---|
52 | switch(id)
|
---|
53 | {
|
---|
54 | case KeyEvent::KE_KEY_PRESSED:
|
---|
55 | listener->keyPressed(e);
|
---|
56 | break;
|
---|
57 | case KeyEvent::KE_KEY_RELEASED:
|
---|
58 | listener->keyReleased(e);
|
---|
59 | break;
|
---|
60 | case KeyEvent::KE_KEY_CLICKED:
|
---|
61 | listener->keyClicked(e);
|
---|
62 | break;
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | void KeyTarget::addKeyListener(KeyListener* l)
|
---|
69 | {
|
---|
70 | mKeyListeners.insert(l);
|
---|
71 | }
|
---|
72 |
|
---|
73 | void KeyTarget::removeKeyListener(KeyListener* l)
|
---|
74 | {
|
---|
75 | mRemovedListeners.insert(l);
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|