[Scummvm-cvs-logs] scummvm master -> b2fad340b5f6cf2c54cb64241003867f5a5a893c

bluegr bluegr at gmail.com
Thu Dec 24 17:25:57 CET 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b2fad340b5 LAB: More cleanup of the keyboard handling code


Commit: b2fad340b5f6cf2c54cb64241003867f5a5a893c
    https://github.com/scummvm/scummvm/commit/b2fad340b5f6cf2c54cb64241003867f5a5a893c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-24T18:25:16+02:00

Commit Message:
LAB: More cleanup of the keyboard handling code

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 5dbe60f..83c50b9 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -59,6 +59,17 @@ static const byte mouseData[] = {
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
 
+EventManager::EventManager(LabEngine *vm) : _vm(vm) {
+	_leftClick = false;
+	_rightClick = false;
+
+	_lastButtonHit = nullptr;
+	_screenButtonList = nullptr;
+	_hitButton = nullptr;
+	_mousePos = Common::Point(0, 0);
+	_keyPressed = Common::KEYCODE_INVALID;
+}
+
 Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) {
 	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
 		Button *button = *buttonItr;
@@ -104,23 +115,6 @@ Button *EventManager::getButton(uint16 id) {
 	return nullptr;
 }
 
-EventManager::EventManager(LabEngine *vm) : _vm(vm) {
-	_leftClick = false;
-	_rightClick = false;
-
-	_lastButtonHit = nullptr;
-	_screenButtonList = nullptr;
-	_hitButton = nullptr;
-	_mousePos = Common::Point(0, 0);
-
-	_nextKeyIn = 0;
-	_nextKeyOut = 0;
-
-	for (int i = 0; i < 64; i++)
-		_keyBuf[i] = Common::KEYCODE_INVALID;
-
-}
-
 void EventManager::updateMouse() {
 	if (!_hitButton)
 		return;
@@ -168,19 +162,6 @@ void EventManager::setMousePos(Common::Point pos) {
 		_vm->_system->warpMouse(pos.x * 2, pos.y);
 }
 
-Common::KeyCode EventManager::keyPress() {
-	Common::KeyCode key = Common::KEYCODE_INVALID;
-
-	processInput();
-
-	if (_nextKeyIn != _nextKeyOut) {
-		key = _keyBuf[_nextKeyOut];
-		_nextKeyOut = (_nextKeyOut + 1) % 64;
-	}
-
-	return key;
-}
-
 void EventManager::processInput() {
 	Common::Event event;
 	Button *curButton = nullptr;
@@ -220,13 +201,9 @@ void EventManager::processInput() {
 					continue;
 				}
 				// Intentional fall through
-			default: {
-				int n = (_nextKeyIn + 1) % 64;
-				if (n != _nextKeyOut) {
-					_keyBuf[_nextKeyIn] = event.kbd.keycode;
-					_nextKeyIn = n;
-				}
-				}
+			default:
+				_keyPressed = event.kbd;
+				break;
 			}
 			break;
 		case Common::EVENT_QUIT:
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index a5f0e94..f0e04fc 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -77,7 +77,6 @@ private:
 
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;
-	Common::KeyCode _keyBuf[64];
 
 	Button *_hitButton;
 	Button *_lastButtonHit;
@@ -93,11 +92,6 @@ private:
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
 
 	/**
-	 * Checks whether or not a key has been pressed.
-	 */
-	Common::KeyCode keyPress();
-
-	/**
 	 * Checks whether or not the coords fall within one of the buttons in a list
 	 * of buttons.
 	 */
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index af52a6a..6f01562 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -117,8 +117,7 @@ IntuiMessage *EventManager::getMsg() {
 	static IntuiMessage message;
 
 	updateMouse();
-
-	Common::KeyCode curKey = keyPress();
+	processInput();
 
 	if (_lastButtonHit) {
 		updateMouse();
@@ -135,8 +134,10 @@ IntuiMessage *EventManager::getMsg() {
 			message._mouse.x /= 2;
 		_leftClick = _rightClick = false;
 		return &message;
-	} else if (curKey != Common::KEYCODE_INVALID) {
-		message._code = curKey;
+	} else if (_keyPressed.keycode != Common::KEYCODE_INVALID) {
+		message._code = _keyPressed.keycode;
+		_keyPressed.keycode = Common::KEYCODE_INVALID;
+
 		Button *curButton = checkNumButtonHit(_screenButtonList, message._code);
 
 		if (curButton) {






More information about the Scummvm-git-logs mailing list