aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-05-09 13:32:04 +0000
committerTorbjörn Andersson2004-05-09 13:32:04 +0000
commitfc970b3c75fd64f399a4c22222d7e295825184c9 (patch)
tree92998da511ba26705bbdc7cbe161e32bb9e031b6 /sword2/driver
parent577600537c2e3cfdacb4e53ccfdab7e06b55a0ed (diff)
downloadscummvm-rg350-fc970b3c75fd64f399a4c22222d7e295825184c9.tar.gz
scummvm-rg350-fc970b3c75fd64f399a4c22222d7e295825184c9.tar.bz2
scummvm-rg350-fc970b3c75fd64f399a4c22222d7e295825184c9.zip
Removed the buffering of mouse and keyboard events. I don't think any of
our other engines do this, so there is little reason for BS2 to. I did add a filtering mechanism so that mouse button releases and scroll wheeling is ignored during normal gameplay, but I don't know if that was necessary either. Since this left little more than an empty husk where the Input class used to be, I've eliminated that class and buried its remains in Sword2Engine. svn-id: r13812
Diffstat (limited to 'sword2/driver')
-rw-r--r--sword2/driver/_mouse.cpp39
-rw-r--r--sword2/driver/animation.cpp4
-rw-r--r--sword2/driver/driver96.h71
-rw-r--r--sword2/driver/rdwin.cpp45
4 files changed, 3 insertions, 156 deletions
diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp
index c4fe24a18a..223669a777 100644
--- a/sword2/driver/_mouse.cpp
+++ b/sword2/driver/_mouse.cpp
@@ -25,45 +25,6 @@ namespace Sword2 {
#define MOUSEFLASHFRAME 6
-/**
- * Logs the mouse button event passed in buttons. The button events were
- * originaly defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN
- * and RD_RIGHTBUTTONUP. ScummVM adds RD_WHEELDOWN and RD_WHEELUP.
- */
-
-void Input::logMouseEvent(uint16 buttons) {
- // We need to leave the one, which is the current event, alone!
- if (_mouseBacklog == MAX_MOUSE_EVENTS - 1)
- return;
-
- _mouseLog[(_mouseBacklog + _mouseLogPos) % MAX_MOUSE_EVENTS].buttons = buttons;
- _mouseBacklog++;
-}
-
-bool Input::checkForMouseEvents(void) {
- return _mouseBacklog != 0;
-}
-
-/**
- * Get the next pending mouse event.
- * @return a pointer to the mouse event, or NULL of there is none
- */
-
-MouseEvent *Input::mouseEvent(void) {
- MouseEvent *me;
-
- if (_mouseBacklog) {
- me = &_mouseLog[_mouseLogPos];
- if (++_mouseLogPos == MAX_MOUSE_EVENTS)
- _mouseLogPos = 0;
-
- _mouseBacklog--;
- return me;
- }
-
- return NULL;
-}
-
void Graphics::decompressMouse(byte *decomp, byte *comp, int width, int height, int pitch, int xOff, int yOff) {
int32 size = width * height;
int32 i = 0;
diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp
index b7d177ed84..f975b4be7d 100644
--- a/sword2/driver/animation.cpp
+++ b/sword2/driver/animation.cpp
@@ -424,9 +424,9 @@ int32 MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
_vm->_graphics->updateDisplay();
- KeyboardEvent ke;
+ KeyboardEvent *ke = _vm->keyboardEvent();
- if ((_vm->_input->readKey(&ke) == RD_OK && ke.keycode == 27) || _vm->_quit) {
+ if ((ke && ke->keycode == 27) || _vm->_quit) {
_snd->stopHandle(handle);
skipCutscene = true;
break;
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h
index 6356b9a287..0bf6803c4e 100644
--- a/sword2/driver/driver96.h
+++ b/sword2/driver/driver96.h
@@ -43,10 +43,6 @@ enum {
RDERR_OPENVERSIONFILE,
- // Keyboard error codes
-
- RDERR_NOKEYWAITING,
-
// Sprite drawing error codes
RDERR_NOTIMPLEMENTED,
@@ -77,17 +73,6 @@ enum {
RDERR_INVALIDID
};
-// Mouse button defines
-
-enum {
- RD_LEFTBUTTONDOWN = 0x01,
- RD_LEFTBUTTONUP = 0x02,
- RD_RIGHTBUTTONDOWN = 0x04,
- RD_RIGHTBUTTONUP = 0x08,
- RD_WHEELUP = 0x10,
- RD_WHEELDOWN = 0x20
-};
-
// Sprite defines
enum {
@@ -176,16 +161,6 @@ enum {
// Structure definitions
-struct MouseEvent {
- uint16 buttons;
-};
-
-struct KeyboardEvent {
- uint16 ascii;
- int keycode;
- int modifiers;
-};
-
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
@@ -230,52 +205,6 @@ struct MovieTextObject {
uint16 *speech;
};
-// Input handling class
-
-// Mouse buffer size
-#define MAX_MOUSE_EVENTS 16
-
-// Key buffer size
-#define MAX_KEY_BUFFER 32
-
-class Input {
-private:
- Sword2Engine *_vm;
-
- uint8 _mouseBacklog;
- uint8 _mouseLogPos;
- MouseEvent _mouseLog[MAX_MOUSE_EVENTS];
-
- void logMouseEvent(uint16 buttons);
-
- // The number of key presses waiting to be processed.
- uint8 _keyBacklog;
-
- // Index of the next key to read from the buffer.
- uint8 _keyLogPos;
-
- // The keyboard buffer
- KeyboardEvent _keyBuffer[MAX_KEY_BUFFER];
-
- void writeKey(uint16 ascii, int keycode, int modifiers);
-
-public:
- int16 _mouseX;
- int16 _mouseY;
-
- Input(Sword2Engine *vm) :
- _vm(vm), _mouseBacklog(0), _mouseLogPos(0), _keyBacklog(0),
- _keyLogPos(0), _mouseX(0), _mouseY(0) {};
-
- void parseEvents(void);
-
- MouseEvent *mouseEvent(void);
- bool checkForMouseEvents(void);
-
- bool keyWaiting(void);
- int32 readKey(KeyboardEvent *ev);
-};
-
} // End of namespace Sword2
#endif
diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp
index e6bdc9cccd..f981fd1151 100644
--- a/sword2/driver/rdwin.cpp
+++ b/sword2/driver/rdwin.cpp
@@ -24,49 +24,6 @@
namespace Sword2 {
-// ---------------------------------------------------------------------------
-// OSystem Event Handler. Full of cross platform goodness and 99% fat free!
-// ---------------------------------------------------------------------------
-
-void Input::parseEvents(void) {
- OSystem::Event event;
-
- while (_vm->_system->poll_event(&event)) {
- switch (event.event_code) {
- case OSystem::EVENT_KEYDOWN:
- writeKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
- break;
- case OSystem::EVENT_MOUSEMOVE:
- _mouseX = event.mouse.x;
- _mouseY = event.mouse.y - MENUDEEP;
- break;
- case OSystem::EVENT_LBUTTONDOWN:
- logMouseEvent(RD_LEFTBUTTONDOWN);
- break;
- case OSystem::EVENT_RBUTTONDOWN:
- logMouseEvent(RD_RIGHTBUTTONDOWN);
- break;
- case OSystem::EVENT_LBUTTONUP:
- logMouseEvent(RD_LEFTBUTTONUP);
- break;
- case OSystem::EVENT_RBUTTONUP:
- logMouseEvent(RD_RIGHTBUTTONUP);
- break;
- case OSystem::EVENT_WHEELUP:
- logMouseEvent(RD_WHEELUP);
- break;
- case OSystem::EVENT_WHEELDOWN:
- logMouseEvent(RD_WHEELDOWN);
- break;
- case OSystem::EVENT_QUIT:
- _vm->closeGame();
- break;
- default:
- break;
- }
- }
-}
-
/**
* Tell updateDisplay() that the scene needs to be completely updated.
*/
@@ -100,7 +57,7 @@ void Graphics::markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1) {
*/
void Graphics::updateDisplay(bool redrawScene) {
- _vm->_input->parseEvents();
+ _vm->parseEvents();
fadeServer();
if (redrawScene) {