aboutsummaryrefslogtreecommitdiff
path: root/sword2/sword2.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-07-09 13:21:21 +0000
committerTorbjörn Andersson2005-07-09 13:21:21 +0000
commitf7a6729a01ce8c07dddf4a7f7c0b25f8690e2c1a (patch)
treed14d72b8cc3acabeb0877fd00a0f358f01812306 /sword2/sword2.cpp
parent866d3e3db357293aea3e70a55b3944bf3dccd5ac (diff)
downloadscummvm-rg350-f7a6729a01ce8c07dddf4a7f7c0b25f8690e2c1a.tar.gz
scummvm-rg350-f7a6729a01ce8c07dddf4a7f7c0b25f8690e2c1a.tar.bz2
scummvm-rg350-f7a6729a01ce8c07dddf4a7f7c0b25f8690e2c1a.zip
This should really be two or three different commits, but I'm too lazy for
that: * Re-worked the elevator script bug workaround so that it's more consistent with the other two script bug workarounds. * Some renamings to make it more clear that game events and input events are two completely different things. * Added function for clearing pending input events, and used that to fix an annoying keyboard repeat bug when closing the debug console. (The console would keep re-opening because the key press to open it kept repeating even though the key had been released.) svn-id: r18522
Diffstat (limited to 'sword2/sword2.cpp')
-rw-r--r--sword2/sword2.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index 06363f51f5..a0d8d27d22 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -260,7 +260,7 @@ int Sword2Engine::init(GameDetector &detector) {
// During normal gameplay, we care neither about mouse button releases
// nor the scroll wheel.
- setEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN);
+ setInputEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN);
setupPersistentResources();
initialiseFontResourceFlags();
@@ -463,18 +463,29 @@ KeyboardEvent *Sword2Engine::keyboardEvent() {
return &_keyboardEvent;
}
-uint32 Sword2Engine::setEventFilter(uint32 filter) {
- uint32 oldFilter = _eventFilter;
+uint32 Sword2Engine::setInputEventFilter(uint32 filter) {
+ uint32 oldFilter = _inputEventFilter;
- _eventFilter = filter;
+ _inputEventFilter = filter;
return oldFilter;
}
/**
+ * Clear the input events. This is so that we won't get any keyboard repeat
+ * right after using the debugging console.
+ */
+
+void Sword2Engine::clearInputEvents() {
+ _keyboardEvent.pending = false;
+ _keyboardEvent.repeat = 0;
+ _mouseEvent.pending = false;
+}
+
+/**
* OSystem Event Handler. Full of cross platform goodness and 99% fat free!
*/
-void Sword2Engine::parseEvents() {
+void Sword2Engine::parseInputEvents() {
OSystem::Event event;
uint32 now = _system->getMillis();
@@ -482,7 +493,7 @@ void Sword2Engine::parseEvents() {
while (_system->pollEvent(event)) {
switch (event.type) {
case OSystem::EVENT_KEYDOWN:
- if (!(_eventFilter & RD_KEYDOWN)) {
+ if (!(_inputEventFilter & RD_KEYDOWN)) {
_keyboardEvent.pending = true;
_keyboardEvent.repeat = now + 400;
_keyboardEvent.ascii = event.kbd.ascii;
@@ -494,42 +505,42 @@ void Sword2Engine::parseEvents() {
_keyboardEvent.repeat = 0;
break;
case OSystem::EVENT_MOUSEMOVE:
- if (!(_eventFilter & RD_KEYDOWN)) {
+ if (!(_inputEventFilter & RD_KEYDOWN)) {
_mouse->setPos(event.mouse.x, event.mouse.y - MENUDEEP);
}
break;
case OSystem::EVENT_LBUTTONDOWN:
- if (!(_eventFilter & RD_LEFTBUTTONDOWN)) {
+ if (!(_inputEventFilter & RD_LEFTBUTTONDOWN)) {
_mouseEvent.pending = true;
_mouseEvent.buttons = RD_LEFTBUTTONDOWN;
}
break;
case OSystem::EVENT_RBUTTONDOWN:
- if (!(_eventFilter & RD_RIGHTBUTTONDOWN)) {
+ if (!(_inputEventFilter & RD_RIGHTBUTTONDOWN)) {
_mouseEvent.pending = true;
_mouseEvent.buttons = RD_RIGHTBUTTONDOWN;
}
break;
case OSystem::EVENT_LBUTTONUP:
- if (!(_eventFilter & RD_LEFTBUTTONUP)) {
+ if (!(_inputEventFilter & RD_LEFTBUTTONUP)) {
_mouseEvent.pending = true;
_mouseEvent.buttons = RD_LEFTBUTTONUP;
}
break;
case OSystem::EVENT_RBUTTONUP:
- if (!(_eventFilter & RD_RIGHTBUTTONUP)) {
+ if (!(_inputEventFilter & RD_RIGHTBUTTONUP)) {
_mouseEvent.pending = true;
_mouseEvent.buttons = RD_RIGHTBUTTONUP;
}
break;
case OSystem::EVENT_WHEELUP:
- if (!(_eventFilter & RD_WHEELUP)) {
+ if (!(_inputEventFilter & RD_WHEELUP)) {
_mouseEvent.pending = true;
_mouseEvent.buttons = RD_WHEELUP;
}
break;
case OSystem::EVENT_WHEELDOWN:
- if (!(_eventFilter & RD_WHEELDOWN)) {
+ if (!(_inputEventFilter & RD_WHEELDOWN)) {
_mouseEvent.pending = true;
_mouseEvent.buttons = RD_WHEELDOWN;
}