annotate engine/core/eventchannel/eventmanager.cpp @ 697:ecaa4d98f05f tip

Abstracted the GUI code and refactored the GUIChan-specific code into its own module. * Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring. * GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass. * The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class. * The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged. * Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 18 Jun 2011 00:28:40 -1000
parents 47d58c7a95d7
children
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 2
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 #include <iostream>
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 // 3rd party library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // FIFE includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // These includes are split up in two parts, separated by one empty line
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // First block: files included from the FIFE root src directory
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 // Second block: files included from the same folder
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "util/base/exception.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "eventchannel/key/ec_key.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 #include "eventchannel/key/ec_keyevent.h"
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
34 #include "eventchannel/key/ec_ikeyfilter.h"
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 #include "eventchannel/mouse/ec_mouseevent.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 #include "eventchannel/command/ec_command.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 #include "eventmanager.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 EventManager::EventManager():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 m_commandlisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 m_keylisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 m_mouselisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 m_sdleventlisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 m_keystatemap(),
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
48 m_keyfilter(0),
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 m_mousestate(0),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 m_mostrecentbtn(MouseEvent::EMPTY)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 EventManager::~EventManager() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 template<typename T>
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
58 void removeListener(std::deque<T>& vec, T& listener) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 vec.push_back(listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 template<typename T>
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
63 void addListener(std::deque<T>& vec, T& listener) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 vec.push_back(listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 void EventManager::addCommandListener(ICommandListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 addListener<ICommandListener*>(m_pending_commandlisteners, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
71 void EventManager::addCommandListenerFront(ICommandListener* listener) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
72 addListener<ICommandListener*>(m_pending_commandlisteners, listener);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
73 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
74
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 void EventManager::removeCommandListener(ICommandListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 removeListener<ICommandListener*>(m_pending_cldeletions, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 void EventManager::addKeyListener(IKeyListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 addListener<IKeyListener*>(m_pending_keylisteners, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
83 void EventManager::addKeyListenerFront(IKeyListener* listener) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
84 addListener<IKeyListener*>(m_pending_keylisteners_front, listener);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
85 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
86
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 void EventManager::removeKeyListener(IKeyListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 removeListener<IKeyListener*>(m_pending_kldeletions, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 void EventManager::addMouseListener(IMouseListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 addListener<IMouseListener*>(m_pending_mouselisteners, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
95 void EventManager::addMouseListenerFront(IMouseListener* listener) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
96 addListener<IMouseListener*>(m_pending_mouselisteners, listener);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
97 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
98
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 void EventManager::removeMouseListener(IMouseListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 removeListener<IMouseListener*>(m_pending_mldeletions, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 void EventManager::addSdlEventListener(ISdlEventListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 addListener<ISdlEventListener*>(m_pending_sdleventlisteners, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
107 void EventManager::addSdlEventListenerFront(ISdlEventListener* listener) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
108 addListener<ISdlEventListener*>(m_pending_sdleventlisteners, listener);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
109 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
110
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 void EventManager::removeSdlEventListener(ISdlEventListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 removeListener<ISdlEventListener*>(m_pending_sdldeletions, listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 void EventManager::dispatchCommand(Command& command) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 if(!m_pending_commandlisteners.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
117 std::deque<ICommandListener*>::iterator i = m_pending_commandlisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 while (i != m_pending_commandlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 m_commandlisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 m_pending_commandlisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
125 if(!m_pending_commandlisteners_front.empty()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
126 std::deque<ICommandListener*>::iterator i = m_pending_commandlisteners_front.begin();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
127 while (i != m_pending_commandlisteners_front.end()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
128 m_commandlisteners.push_front(*i);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
129 ++i;
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
130 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
131 m_pending_commandlisteners_front.clear();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
132 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
133
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 if (!m_pending_cldeletions.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
135 std::deque<ICommandListener*>::iterator i = m_pending_cldeletions.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 while (i != m_pending_cldeletions.end()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
137 std::deque<ICommandListener*>::iterator j = m_commandlisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 while (j != m_commandlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 m_commandlisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 m_pending_cldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
150 std::deque<ICommandListener*>::iterator i = m_commandlisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 while (i != m_commandlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 (*i)->onCommand(command);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 if (command.isConsumed()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 void EventManager::dispatchKeyEvent(KeyEvent& evt) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 if(!m_pending_keylisteners.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
162 std::deque<IKeyListener*>::iterator i = m_pending_keylisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 while (i != m_pending_keylisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 m_keylisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 m_pending_keylisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
170 if(!m_pending_keylisteners_front.empty()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
171 std::deque<IKeyListener*>::iterator i = m_pending_keylisteners_front.begin();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
172 while (i != m_pending_keylisteners_front.end()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
173 m_keylisteners.push_front(*i);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
174 ++i;
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
175 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
176 m_pending_keylisteners_front.clear();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
177 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
178
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 if (!m_pending_kldeletions.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
180 std::deque<IKeyListener*>::iterator i = m_pending_kldeletions.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 while (i != m_pending_kldeletions.end()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
182 std::deque<IKeyListener*>::iterator j = m_keylisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 while (j != m_keylisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 m_keylisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 m_pending_kldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
195 std::deque<IKeyListener*>::iterator i = m_keylisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 while (i != m_keylisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 switch (evt.getType()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 case KeyEvent::PRESSED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 (*i)->keyPressed(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 case KeyEvent::RELEASED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 (*i)->keyReleased(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 default:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 void EventManager::dispatchMouseEvent(MouseEvent& evt) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 if(!m_pending_mouselisteners.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
213 std::deque<IMouseListener*>::iterator i = m_pending_mouselisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 while (i != m_pending_mouselisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 m_mouselisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 m_pending_mouselisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
221 if(!m_pending_mouselisteners_front.empty()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
222 std::deque<IMouseListener*>::iterator i = m_pending_mouselisteners_front.begin();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
223 while (i != m_pending_mouselisteners_front.end()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
224 m_mouselisteners.push_front(*i);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
225 ++i;
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
226 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
227 m_pending_mouselisteners_front.clear();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
228 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
229
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 if (!m_pending_mldeletions.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
231 std::deque<IMouseListener*>::iterator i = m_pending_mldeletions.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 while (i != m_pending_mldeletions.end()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
233 std::deque<IMouseListener*>::iterator j = m_mouselisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 while (j != m_mouselisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 m_mouselisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 m_pending_mldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
246 std::deque<IMouseListener*>::iterator i = m_mouselisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 while (i != m_mouselisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 switch (evt.getType()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 case MouseEvent::MOVED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 (*i)->mouseMoved(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 case MouseEvent::PRESSED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 (*i)->mousePressed(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 case MouseEvent::RELEASED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 (*i)->mouseReleased(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 case MouseEvent::WHEEL_MOVED_DOWN:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 (*i)->mouseWheelMovedDown(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 case MouseEvent::WHEEL_MOVED_UP:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 (*i)->mouseWheelMovedUp(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 case MouseEvent::CLICKED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 (*i)->mouseClicked(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 case MouseEvent::ENTERED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 (*i)->mouseEntered(evt);
2
e84dccee1bb7 * add myself to authors
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
269 break;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 case MouseEvent::EXITED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 (*i)->mouseExited(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 case MouseEvent::DRAGGED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 (*i)->mouseDragged(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 default:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 if (evt.isConsumed()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
286 bool EventManager::dispatchSdlEvent(SDL_Event& evt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
287 bool ret = false;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 if (!m_pending_sdleventlisteners.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
289 std::deque<ISdlEventListener*>::iterator i = m_pending_sdleventlisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 while(i != m_pending_sdleventlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 m_sdleventlisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
292 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 m_pending_sdleventlisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
297 if (!m_pending_sdleventlisteners_front.empty()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
298 std::deque<ISdlEventListener*>::iterator i = m_pending_sdleventlisteners_front.begin();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
299 while(i != m_pending_sdleventlisteners_front.end()) {
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
300 m_sdleventlisteners.push_front(*i);
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
301 ++i;
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
302 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
303 m_pending_sdleventlisteners_front.clear();
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
304 }
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
305
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306 if (!m_pending_sdldeletions.empty()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
307 std::deque<ISdlEventListener*>::iterator i = m_pending_sdldeletions.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 while (i != m_pending_sdldeletions.end()) {
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
309 std::deque<ISdlEventListener*>::iterator j = m_sdleventlisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 while (j != m_sdleventlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 m_sdleventlisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
313 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 m_pending_sdldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
320 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
322 std::deque<ISdlEventListener*>::iterator i = m_sdleventlisteners.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 while (i != m_sdleventlisteners.end()) {
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
324 ret = ret || (*i)->onSdlEvent(evt);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 }
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
327 return ret;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329
103
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
330 bool EventManager::combineEvents(SDL_Event& event1, const SDL_Event& event2) {
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
331 if(event1.type == event2.type) {
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
332 switch (event1.type) {
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
333 case SDL_MOUSEMOTION:
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
334 if(event1.motion.state == event2.motion.state) {
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
335 event1.motion.x = event2.motion.x;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
336 event1.motion.y = event2.motion.y;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
337 event1.motion.xrel += event2.motion.xrel;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
338 event1.motion.yrel += event2.motion.yrel;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
339 return true;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
340 }
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
341 return false;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
342 }
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
343 }
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
344 return false;
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
345 }
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
346
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
347 void EventManager::processEvents() {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
348 // The double SDL_PollEvent calls don't throw away events,
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
349 // but try to combine (mouse motion) events.
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
350 SDL_Event event, next_event;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
351 bool has_next_event = SDL_PollEvent(&event);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
352 while (has_next_event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
353 has_next_event = SDL_PollEvent(&next_event);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
354 if(has_next_event && combineEvents(event, next_event))
103
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
355 continue;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
356
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
357 switch (event.type) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
358 case SDL_QUIT: {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
359 Command cmd;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
360 cmd.setSource(this);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
361 cmd.setCommandType(CMD_QUIT_GAME);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
362 dispatchCommand(cmd);
96
76fb866be8ea Add input and app focus events (e.g. iconify) (patch by phiker)
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
363 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
364 break;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
365
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
366 case SDL_ACTIVEEVENT:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
367 processActiveEvent(event);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
368 break;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
369
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
370 case SDL_KEYDOWN:
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
371 case SDL_KEYUP:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
372 processKeyEvent(event);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
373 break;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
374
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
375 case SDL_MOUSEBUTTONUP:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
376 case SDL_MOUSEMOTION:
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
377 case SDL_MOUSEBUTTONDOWN:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
378 processMouseEvent(event);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
379 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
380 }
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
381 if(has_next_event)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
382 event = next_event;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
383 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
384 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
385
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
386 void EventManager::processActiveEvent(SDL_Event event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
387 if(dispatchSdlEvent(event))
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
388 return;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
389
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
390 Command cmd;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
391 cmd.setSource(this);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
392 SDL_ActiveEvent actevt = event.active;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
393 if (actevt.state == SDL_APPMOUSEFOCUS)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
394 {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
395 if (actevt.gain)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
396 cmd.setCommandType(CMD_MOUSE_FOCUS_GAINED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
397 else
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
398 cmd.setCommandType(CMD_MOUSE_FOCUS_LOST);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
399 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
400 else if (actevt.state == SDL_APPINPUTFOCUS)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
401 {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
402 if (actevt.gain)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
403 cmd.setCommandType(CMD_INPUT_FOCUS_GAINED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
404 else
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
405 cmd.setCommandType(CMD_INPUT_FOCUS_LOST);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
406 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
407 else if (actevt.state == SDL_APPACTIVE)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
408 {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
409 if (actevt.gain)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
410 cmd.setCommandType(CMD_APP_RESTORED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
411 else
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
412 cmd.setCommandType(CMD_APP_ICONIFIED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
413 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
414 dispatchCommand(cmd);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
415 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
416
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
417 void EventManager::processKeyEvent(SDL_Event event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
418 KeyEvent keyevt;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
419 keyevt.setSource(this);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
420 fillKeyEvent(event, keyevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
421 m_keystatemap[keyevt.getKey().getValue()] = (keyevt.getType() == KeyEvent::PRESSED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
422
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
423 bool dispatchAsSdl = !keyevt.getKey().isFunctionKey();
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
424 if( dispatchAsSdl && m_keyfilter ) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
425 dispatchAsSdl = !m_keyfilter->isFiltered(keyevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
426 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
427
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
428 if( dispatchAsSdl ) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
429 if( dispatchSdlEvent(event) )
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
430 return;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
431 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
432
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
433 dispatchKeyEvent(keyevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
434 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
435
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
436 void EventManager::processMouseEvent(SDL_Event event) {
694
ca1fcb96907d Added pre- and post-rendering hooks for executing custom rendering code.
M. George Hansen <technopolitica@gmail.com>
parents: 624
diff changeset
437 // FIXME Technomage 2011-02-02: Guichan just consumes all mouse events.
695
47d58c7a95d7 Fixed a bug in VFSDirectory that prevented absolute paths from being resolved.
M. George Hansen <technopolitica@gmail.com>
parents: 694
diff changeset
438 if(dispatchSdlEvent(event))
47d58c7a95d7 Fixed a bug in VFSDirectory that prevented absolute paths from being resolved.
M. George Hansen <technopolitica@gmail.com>
parents: 694
diff changeset
439 return;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
440
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
441 MouseEvent mouseevt;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
442 mouseevt.setSource(this);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
443 fillMouseEvent(event, mouseevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
444 fillModifiers(mouseevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
445 if (event.type == SDL_MOUSEBUTTONDOWN) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
446 m_mousestate |= static_cast<int>(mouseevt.getButton());
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
447 m_mostrecentbtn = mouseevt.getButton();
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
448 } else if (event.type == SDL_MOUSEBUTTONUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
449 m_mousestate &= ~static_cast<int>(mouseevt.getButton());
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
450 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
451 // fire scrollwheel events only once
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
452 if (event.button.button == SDL_BUTTON_WHEELDOWN || event.button.button == SDL_BUTTON_WHEELUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
453 if (event.type == SDL_MOUSEBUTTONUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
454 return;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
455 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
456 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
457 dispatchMouseEvent(mouseevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
458 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
459
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
460
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
461 void EventManager::fillMouseEvent(const SDL_Event& sdlevt, MouseEvent& mouseevt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
462 mouseevt.setX(sdlevt.button.x);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
463 mouseevt.setY(sdlevt.button.y);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
464 mouseevt.setButton(MouseEvent::EMPTY);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
465 mouseevt.setType(MouseEvent::MOVED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
466 if ((sdlevt.type == SDL_MOUSEBUTTONUP) || (sdlevt.type == SDL_MOUSEBUTTONDOWN)) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
467 switch (sdlevt.button.button) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
468 case SDL_BUTTON_LEFT:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
469 mouseevt.setButton(MouseEvent::LEFT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
470 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
471 case SDL_BUTTON_RIGHT:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
472 mouseevt.setButton(MouseEvent::RIGHT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
473 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
474 case SDL_BUTTON_MIDDLE:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
475 mouseevt.setButton(MouseEvent::MIDDLE);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
476 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
477 default:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
478 mouseevt.setButton(MouseEvent::UNKNOWN_BUTTON);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
479 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
480 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
481
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
482 if (sdlevt.type == SDL_MOUSEBUTTONUP ) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
483 mouseevt.setType(MouseEvent::RELEASED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
484 } else {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
485 mouseevt.setType(MouseEvent::PRESSED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
486 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
487
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
488 switch (sdlevt.button.button) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
489 case SDL_BUTTON_WHEELDOWN:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
490 mouseevt.setType(MouseEvent::WHEEL_MOVED_DOWN);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
491 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
492 case SDL_BUTTON_WHEELUP:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
493 mouseevt.setType(MouseEvent::WHEEL_MOVED_UP);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
494 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
495 default:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
496 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
497 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
498 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
499 if ((mouseevt.getType() == MouseEvent::MOVED) && m_mousestate) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
500 mouseevt.setType(MouseEvent::DRAGGED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
501 mouseevt.setButton(m_mostrecentbtn);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
502 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
503 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
504
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
505 void EventManager::fillKeyEvent(const SDL_Event& sdlevt, KeyEvent& keyevt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
506 if (sdlevt.type == SDL_KEYDOWN) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
507 keyevt.setType(KeyEvent::PRESSED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
508 } else if (sdlevt.type == SDL_KEYUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
509 keyevt.setType(KeyEvent::RELEASED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
510 } else {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
511 throw EventException("Invalid event type in fillKeyEvent");
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
512 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
513 SDL_keysym keysym = sdlevt.key.keysym;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
514
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
515 keyevt.setShiftPressed(keysym.mod & KMOD_SHIFT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
516 keyevt.setControlPressed(keysym.mod & KMOD_CTRL);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
517 keyevt.setAltPressed(keysym.mod & KMOD_ALT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
518 keyevt.setMetaPressed(keysym.mod & KMOD_META);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
519 keyevt.setNumericPad(keysym.sym >= SDLK_KP0 && keysym.sym <= SDLK_KP_EQUALS);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
520 keyevt.setKey(Key(static_cast<Key::KeyType>(keysym.sym), keysym.unicode));
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
521 }
428
a1884665aa95 Added the ability to add an event listener to the front of the event listener deque in the event manager. fixes[t:454]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
522
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
523 void EventManager::fillModifiers(InputEvent& evt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
524 evt.setAltPressed(m_keystatemap[Key::ALT_GR] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
525 m_keystatemap[Key::LEFT_ALT] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
526 m_keystatemap[Key::RIGHT_ALT]);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
527 evt.setControlPressed(m_keystatemap[Key::LEFT_CONTROL] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
528 m_keystatemap[Key::RIGHT_CONTROL]);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
529 evt.setMetaPressed(m_keystatemap[Key::LEFT_META] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
530 m_keystatemap[Key::RIGHT_META]);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
531 evt.setShiftPressed(m_keystatemap[Key::LEFT_SHIFT] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
532 m_keystatemap[Key::RIGHT_SHIFT]);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
533 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
534
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
535 EventSourceType EventManager::getEventSourceType() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
536 return ES_ENGINE;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
537 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
538
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
539 void EventManager::setKeyFilter(IKeyFilter* keyFilter) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
540 m_keyfilter = keyFilter;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
541 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
542 }