source: OGRE/trunk/ogrenew/OgreMain/src/OgreKeyTarget.cpp @ 692

Revision 692, 2.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

RevLine 
[692]1
2/*
3-----------------------------------------------------------------------------
4This source file is part of OGRE
5    (Object-oriented Graphics Rendering Engine)
6For the latest info, see http://www.ogre3d.org/
7
8Copyright (c) 2000-2005 The OGRE Team
9Also see acknowledgements in Readme.html
10
11This program is free software you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the Free Software
13Foundation either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License along with
21this program if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://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
33namespace 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
Note: See TracBrowser for help on using the repository browser.