annotate engine/core/eventchannel/eventmanager.cpp @ 574:58c0bbeeeb35

* Changed getID() to getId(). fixes[ticket:461]
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 02 Jul 2010 06:02:21 +0000
parents a1884665aa95
children b312d170ab0c
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 #include "eventchannel/trigger/ec_trigger.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 #include "eventmanager.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 EventManager::EventManager():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 m_commandlisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 m_keylisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 m_mouselisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 m_sdleventlisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 m_keystatemap(),
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
49 m_keyfilter(0),
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 m_mousestate(0),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 m_mostrecentbtn(MouseEvent::EMPTY)
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
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 EventManager::~EventManager() {
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
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 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
59 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
60 vec.push_back(listener);
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
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 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
64 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
65 vec.push_back(listener);
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
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 void EventManager::addCommandListener(ICommandListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 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
70 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71
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
72 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
73 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
74 }
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
75
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 void EventManager::removeCommandListener(ICommandListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 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
78 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 void EventManager::addKeyListener(IKeyListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 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
82 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83
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
84 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
85 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
86 }
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
87
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 void EventManager::removeKeyListener(IKeyListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 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
90 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 void EventManager::addMouseListener(IMouseListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 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
94 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95
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
96 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
97 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
98 }
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
99
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 void EventManager::removeMouseListener(IMouseListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 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
102 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 void EventManager::addSdlEventListener(ISdlEventListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 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
106 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107
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
108 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
109 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
110 }
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
111
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 void EventManager::removeSdlEventListener(ISdlEventListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 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
114 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 void EventManager::dispatchCommand(Command& command) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 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
118 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
119 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
120 m_commandlisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 m_pending_commandlisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125
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
126 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
127 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
128 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
129 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
130 ++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
131 }
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 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
133 }
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
134
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 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
136 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
137 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
138 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
139 while (j != m_commandlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 m_commandlisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 m_pending_cldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150
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
151 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
152 while (i != m_commandlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 (*i)->onCommand(command);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 if (command.isConsumed()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 ++i;
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
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 void EventManager::dispatchKeyEvent(KeyEvent& evt) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 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
163 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
164 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
165 m_keylisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 m_pending_keylisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170
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
171 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
172 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
173 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
174 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
175 ++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
176 }
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 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
178 }
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
179
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 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
181 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
182 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
183 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
184 while (j != m_keylisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 m_keylisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 m_pending_kldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195
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
196 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
197 while (i != m_keylisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 switch (evt.getType()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 case KeyEvent::PRESSED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 (*i)->keyPressed(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 case KeyEvent::RELEASED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 (*i)->keyReleased(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 default:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 ++i;
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
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 void EventManager::dispatchMouseEvent(MouseEvent& evt) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 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
214 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
215 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
216 m_mouselisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 m_pending_mouselisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221
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
222 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
223 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
224 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
225 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
226 ++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
227 }
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 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
229 }
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
230
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 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
232 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
233 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
234 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
235 while (j != m_mouselisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 m_mouselisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 m_pending_mldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
246
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
247 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
248 while (i != m_mouselisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 switch (evt.getType()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 case MouseEvent::MOVED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 (*i)->mouseMoved(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 case MouseEvent::PRESSED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 (*i)->mousePressed(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 case MouseEvent::RELEASED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 (*i)->mouseReleased(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 case MouseEvent::WHEEL_MOVED_DOWN:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 (*i)->mouseWheelMovedDown(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 case MouseEvent::WHEEL_MOVED_UP:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263 (*i)->mouseWheelMovedUp(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 case MouseEvent::CLICKED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 (*i)->mouseClicked(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 case MouseEvent::ENTERED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 (*i)->mouseEntered(evt);
2
e84dccee1bb7 * add myself to authors
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
270 break;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 case MouseEvent::EXITED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 (*i)->mouseExited(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 case MouseEvent::DRAGGED:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 (*i)->mouseDragged(evt);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 default:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 if (evt.isConsumed()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 ++i;
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 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
287 bool EventManager::dispatchSdlEvent(SDL_Event& evt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
288 bool ret = false;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289 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
290 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
291 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
292 m_sdleventlisteners.push_back(*i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 m_pending_sdleventlisteners.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297
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
298 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
299 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
300 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
301 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
302 ++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
303 }
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 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
305 }
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
306
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 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
308 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
309 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
310 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
311 while (j != m_sdleventlisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 if(*j == *i) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
313 m_sdleventlisteners.erase(j);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 ++j;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
320 m_pending_sdldeletions.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
322
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
323 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
324 while (i != m_sdleventlisteners.end()) {
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
325 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
326 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 }
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
328 return ret;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330
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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 }
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 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
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 }
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 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
346 }
c512dff398c2 combine events (currently only mouse motion events), that helps reducing lag in clients
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 96
diff changeset
347
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
348 void EventManager::processEvents() {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
349 // The double SDL_PollEvent calls don't throw away events,
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
350 // but try to combine (mouse motion) events.
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
351 SDL_Event event, next_event;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
352 bool has_next_event = SDL_PollEvent(&event);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
353 while (has_next_event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
354 has_next_event = SDL_PollEvent(&next_event);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
355 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
356 continue;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
357
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
358 switch (event.type) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
359 case SDL_QUIT: {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
360 Command cmd;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
361 cmd.setSource(this);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
362 cmd.setCommandType(CMD_QUIT_GAME);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
363 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
364 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
365 break;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
366
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
367 case SDL_ACTIVEEVENT:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
368 processActiveEvent(event);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
369 break;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
370
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
371 case SDL_KEYDOWN:
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
372 case SDL_KEYUP:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
373 processKeyEvent(event);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
374 break;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
375
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
376 case SDL_MOUSEBUTTONUP:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
377 case SDL_MOUSEMOTION:
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
378 case SDL_MOUSEBUTTONDOWN:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
379 processMouseEvent(event);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
380 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
381 }
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
382 if(has_next_event)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
383 event = next_event;
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 pollTriggers();
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
386 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
387
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
388 void EventManager::processActiveEvent(SDL_Event event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
389 if(dispatchSdlEvent(event))
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
390 return;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
391
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
392 Command cmd;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
393 cmd.setSource(this);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
394 SDL_ActiveEvent actevt = event.active;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
395 if (actevt.state == SDL_APPMOUSEFOCUS)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
396 {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
397 if (actevt.gain)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
398 cmd.setCommandType(CMD_MOUSE_FOCUS_GAINED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
399 else
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
400 cmd.setCommandType(CMD_MOUSE_FOCUS_LOST);
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 else if (actevt.state == SDL_APPINPUTFOCUS)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
403 {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
404 if (actevt.gain)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
405 cmd.setCommandType(CMD_INPUT_FOCUS_GAINED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
406 else
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
407 cmd.setCommandType(CMD_INPUT_FOCUS_LOST);
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 else if (actevt.state == SDL_APPACTIVE)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
410 {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
411 if (actevt.gain)
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
412 cmd.setCommandType(CMD_APP_RESTORED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
413 else
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
414 cmd.setCommandType(CMD_APP_ICONIFIED);
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 dispatchCommand(cmd);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
417 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
418
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
419 void EventManager::processKeyEvent(SDL_Event event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
420 KeyEvent keyevt;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
421 keyevt.setSource(this);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
422 fillKeyEvent(event, keyevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
423 m_keystatemap[keyevt.getKey().getValue()] = (keyevt.getType() == KeyEvent::PRESSED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
424
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
425 bool dispatchAsSdl = !keyevt.getKey().isFunctionKey();
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
426 if( dispatchAsSdl && m_keyfilter ) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
427 dispatchAsSdl = !m_keyfilter->isFiltered(keyevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
428 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
429
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
430 if( dispatchAsSdl ) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
431 if( dispatchSdlEvent(event) )
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
432 return;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
433 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
434
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
435 dispatchKeyEvent(keyevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
436 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
437
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
438 void EventManager::processMouseEvent(SDL_Event event) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
439 if(dispatchSdlEvent(event))
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
440 return;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
441
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
442 MouseEvent mouseevt;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
443 mouseevt.setSource(this);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
444 fillMouseEvent(event, mouseevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
445 fillModifiers(mouseevt);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
446 if (event.type == SDL_MOUSEBUTTONDOWN) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
447 m_mousestate |= static_cast<int>(mouseevt.getButton());
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
448 m_mostrecentbtn = mouseevt.getButton();
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
449 } else if (event.type == SDL_MOUSEBUTTONUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
450 m_mousestate &= ~static_cast<int>(mouseevt.getButton());
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
451 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
452 // fire scrollwheel events only once
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
453 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
454 if (event.type == SDL_MOUSEBUTTONUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
455 return;
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 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
458 dispatchMouseEvent(mouseevt);
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
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
462 void EventManager::fillMouseEvent(const SDL_Event& sdlevt, MouseEvent& mouseevt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
463 mouseevt.setX(sdlevt.button.x);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
464 mouseevt.setY(sdlevt.button.y);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
465 mouseevt.setButton(MouseEvent::EMPTY);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
466 mouseevt.setType(MouseEvent::MOVED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
467 if ((sdlevt.type == SDL_MOUSEBUTTONUP) || (sdlevt.type == SDL_MOUSEBUTTONDOWN)) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
468 switch (sdlevt.button.button) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
469 case SDL_BUTTON_LEFT:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
470 mouseevt.setButton(MouseEvent::LEFT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
471 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
472 case SDL_BUTTON_RIGHT:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
473 mouseevt.setButton(MouseEvent::RIGHT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
474 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
475 case SDL_BUTTON_MIDDLE:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
476 mouseevt.setButton(MouseEvent::MIDDLE);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
477 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
478 default:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
479 mouseevt.setButton(MouseEvent::UNKNOWN_BUTTON);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
480 break;
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
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
483 if (sdlevt.type == SDL_MOUSEBUTTONUP ) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
484 mouseevt.setType(MouseEvent::RELEASED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
485 } else {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
486 mouseevt.setType(MouseEvent::PRESSED);
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
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
489 switch (sdlevt.button.button) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
490 case SDL_BUTTON_WHEELDOWN:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
491 mouseevt.setType(MouseEvent::WHEEL_MOVED_DOWN);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
492 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
493 case SDL_BUTTON_WHEELUP:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
494 mouseevt.setType(MouseEvent::WHEEL_MOVED_UP);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
495 break;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
496 default:
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
497 break;
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 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
500 if ((mouseevt.getType() == MouseEvent::MOVED) && m_mousestate) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
501 mouseevt.setType(MouseEvent::DRAGGED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
502 mouseevt.setButton(m_mostrecentbtn);
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
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
506 void EventManager::fillKeyEvent(const SDL_Event& sdlevt, KeyEvent& keyevt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
507 if (sdlevt.type == SDL_KEYDOWN) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
508 keyevt.setType(KeyEvent::PRESSED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
509 } else if (sdlevt.type == SDL_KEYUP) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
510 keyevt.setType(KeyEvent::RELEASED);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
511 } else {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
512 throw EventException("Invalid event type in fillKeyEvent");
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
513 }
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
514 SDL_keysym keysym = sdlevt.key.keysym;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
515
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
516 keyevt.setShiftPressed(keysym.mod & KMOD_SHIFT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
517 keyevt.setControlPressed(keysym.mod & KMOD_CTRL);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
518 keyevt.setAltPressed(keysym.mod & KMOD_ALT);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
519 keyevt.setMetaPressed(keysym.mod & KMOD_META);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
520 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
521 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
522 }
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
523
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
524 void EventManager::fillModifiers(InputEvent& evt) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
525 evt.setAltPressed(m_keystatemap[Key::ALT_GR] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
526 m_keystatemap[Key::LEFT_ALT] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
527 m_keystatemap[Key::RIGHT_ALT]);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
528 evt.setControlPressed(m_keystatemap[Key::LEFT_CONTROL] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
529 m_keystatemap[Key::RIGHT_CONTROL]);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
530 evt.setMetaPressed(m_keystatemap[Key::LEFT_META] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
531 m_keystatemap[Key::RIGHT_META]);
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
532 evt.setShiftPressed(m_keystatemap[Key::LEFT_SHIFT] |
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
533 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
534 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
535
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
536 EventSourceType EventManager::getEventSourceType() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
537 return ES_ENGINE;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
538 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
539
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
540 void EventManager::registerTrigger(Trigger& trigger){
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
541 m_triggers.push_back(&trigger);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
542 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
543
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
544 void EventManager::unregisterTrigger(Trigger& trigger){
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
545 m_triggers.remove(&trigger);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
546 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
547
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
548 void EventManager::pollTriggers(){
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
549 for (std::list<Trigger*>::iterator it = m_triggers.begin(); it!=m_triggers.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
550 (*it)->pollTrigger();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
551 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
552 }
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
553
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
554 void EventManager::setKeyFilter(IKeyFilter* keyFilter) {
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
555 m_keyfilter = keyFilter;
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 111
diff changeset
556 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
557 }