[Scummvm-cvs-logs] CVS: scummvm/sword2/driver _mouse.cpp,1.36,1.37 animation.cpp,1.40,1.41 driver96.h,1.71,1.72 rdwin.cpp,1.46,1.47

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sun May 9 06:33:02 CEST 2004


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12787/driver

Modified Files:
	_mouse.cpp animation.cpp driver96.h rdwin.cpp 
Log Message:
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.


Index: _mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/_mouse.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- _mouse.cpp	5 May 2004 07:22:35 -0000	1.36
+++ _mouse.cpp	9 May 2004 13:32:04 -0000	1.37
@@ -25,45 +25,6 @@
 
 #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;

Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- animation.cpp	1 May 2004 10:42:23 -0000	1.40
+++ animation.cpp	9 May 2004 13:32:04 -0000	1.41
@@ -424,9 +424,9 @@
 
 			_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;

Index: driver96.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/driver96.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- driver96.h	23 Apr 2004 07:02:10 -0000	1.71
+++ driver96.h	9 May 2004 13:32:04 -0000	1.72
@@ -43,10 +43,6 @@
 
 	RDERR_OPENVERSIONFILE,
 
-	// Keyboard error codes
-
-	RDERR_NOKEYWAITING,
-
 	// Sprite drawing error codes
 
 	RDERR_NOTIMPLEMENTED,
@@ -77,17 +73,6 @@
 	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 @@
 
 // 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 @@
 	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

Index: rdwin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/rdwin.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- rdwin.cpp	9 May 2004 13:24:07 -0000	1.46
+++ rdwin.cpp	9 May 2004 13:32:04 -0000	1.47
@@ -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::updateDisplay(bool redrawScene) {
-	_vm->_input->parseEvents();
+	_vm->parseEvents();
 	fadeServer();
 
 	if (redrawScene) {





More information about the Scummvm-git-logs mailing list