[Scummvm-cvs-logs] CVS: scummvm/bs2 controls.cpp,1.16,1.17 function.cpp,1.12,1.13 logic.cpp,1.12,1.13 mem_view.cpp,1.7,1.8 resman.cpp,1.40,1.41 startup.cpp,1.11,1.12 sword2.cpp,1.34,1.35

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Tue Sep 23 09:01:13 CEST 2003


Update of /cvsroot/scummvm/scummvm/bs2
In directory sc8-pr-cvs1:/tmp/cvs-serv12449

Modified Files:
	controls.cpp function.cpp logic.cpp mem_view.cpp resman.cpp 
	startup.cpp sword2.cpp 
Log Message:
Changed the keyboard handling to store "keyboard events", rather than just
characters. Hopefully this will make things work smoother on the Mac, but I
have no way of testing that.


Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/controls.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- controls.cpp	21 Sep 2003 16:11:26 -0000	1.16
+++ controls.cpp	23 Sep 2003 15:59:52 -0000	1.17
@@ -243,7 +243,7 @@
 	virtual void onMouseMove(int x, int y) {}
 	virtual void onMouseDown(int x, int y) {}
 	virtual void onMouseUp(int x, int y) {}
-	virtual void onKey(char key) {}
+	virtual void onKey(_keyboardEvent *ke) {}
 	virtual void onTick() {}
 
 	virtual void releaseMouse(int x, int y) {}
@@ -376,14 +376,14 @@
 		int16 newMouseX = mousex;
 		int16 newMouseY = mousey + 40;
 
-		char key;
-		int32 keyboardStatus = ReadKey(&key);
 		_mouseEvent *me = MouseEvent();
+		_keyboardEvent ke;
+		int32 keyboardStatus = ReadKey(&ke);
 
 		if (keyboardStatus == RD_OK) {
-			if (key == 27)
+			if (ke.keycode == 27)
 				setResult(0);
-			else if (key == 13)
+			else if (ke.keycode == '\n' || ke.keycode == '\r')
 				setResult(1);
 		}
 
@@ -416,8 +416,8 @@
 				}
 			}
 
-			if (keyboardStatus == RD_OK && key != 0)
-				_widgets[i]->onKey(key);
+			if (keyboardStatus == RD_OK)
+				_widgets[i]->onKey(&ke);
 
 			_widgets[i]->onTick();
 		}
@@ -972,9 +972,13 @@
 		}
 	}
 
-	virtual void onKey(char key) {
-		if (_editable && (key == 8 || (key >= ' ' && key <= 'z')))
-			_parent->onAction(this, key);
+	virtual void onKey(_keyboardEvent *ke) {
+		if (_editable) {
+			if (ke->keycode == 8)
+				_parent->onAction(this, 8);
+			else if (ke->ascii >= ' ' && ke->ascii <= 'z')
+				_parent->onAction(this, ke->ascii);
+		}
 	}
 
 	virtual void onTick() {
@@ -1347,7 +1351,7 @@
 		return;
 	}
 
-	// Stop music instantly! (James22aug97)
+	// Stop music instantly! (James	22aug97)
 	Kill_music();
 
 	//in case we were dead - well we're not anymore!
@@ -1410,13 +1414,14 @@
 	// Wait for ESC or mouse click
 	while (1) {
 		_mouseEvent *me;
-		char c;
 
 		ServiceWindows();
 
 		if (KeyWaiting()) {
-			ReadKey(&c);
-			if (c == 27)
+			_keyboardEvent ke;
+
+			ReadKey(&ke);
+			if (ke.keycode == 27)
 				break;
 		}
 

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/function.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- function.cpp	23 Sep 2003 06:27:58 -0000	1.12
+++ function.cpp	23 Sep 2003 15:59:52 -0000	1.13
@@ -426,8 +426,6 @@
 		debug(0, "Credits music length: ~%d ms", music_length);
 
 		while (g_sound->MusicTimeRemaining()) {
-			char key;
-
 			EraseBackBuffer();
 
 			// FIXME: Draw the credits text. The actual text
@@ -436,7 +434,9 @@
 
 			ServiceWindows();
 
-			if (ReadKey(&key) == RD_OK && key == 27)
+			_keyboardEvent ke;
+
+			if (ReadKey(&ke) == RD_OK && ke.keycode == 27)
 				break;
 
 			g_system->delay_msecs(30);

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/logic.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- logic.cpp	20 Sep 2003 12:24:53 -0000	1.12
+++ logic.cpp	23 Sep 2003 15:59:52 -0000	1.13
@@ -328,7 +328,7 @@
 	uint32 *game_object_list;
 	_standardHeader *file_header;
 	int scrolls = 0;
-	char c;
+	_keyboardEvent ke;
 
 	if (current_run_list) {
 		// open and lock in place
@@ -353,8 +353,8 @@
 				} while(!KeyWaiting());
 
 				// kill the key we just pressed
-				ReadKey(&c);
-				if (c == 27)
+				ReadKey(&ke);
+				if (ke.keycode == 27)
 					break;
 
 				// clear the Press Esc message ready for the

Index: mem_view.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/mem_view.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mem_view.cpp	21 Sep 2003 16:11:26 -0000	1.7
+++ mem_view.cpp	23 Sep 2003 15:59:52 -0000	1.8
@@ -34,7 +34,7 @@
 	int pass, found_end, k, j, free = 0;
 	_standardHeader	*file_header;
 	int scrolls = 0;
-	char c;
+	_keyboardEvent ke;
 
 	char inf[][20] = {
 		{ "M_null  " },
@@ -98,8 +98,7 @@
 
 		Build_display();
 
-
-		if (scrolls==18) {
+		if (scrolls == 18) {
 			Temp_print_to_console("- Press ESC to stop or any other key to continue");
 			Build_display();
 
@@ -107,8 +106,8 @@
 				ServiceWindows();
 			} while(!KeyWaiting());
 
-			ReadKey(&c);	//kill the key we just pressed
-			if (c == 27)	//ESC
+			ReadKey(&ke);	//kill the key we just pressed
+			if (ke.keycode == 27)	//ESC
 				break;
 
 			// clear the Press Esc message ready for the new line

Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/resman.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- resman.cpp	23 Sep 2003 06:23:29 -0000	1.40
+++ resman.cpp	23 Sep 2003 15:59:52 -0000	1.41
@@ -956,7 +956,7 @@
 	uint32 nuked = 0;
   	_standardHeader *header;
 	int scrolls = 0;
-	char c;
+	_keyboardEvent ke;
 
 	j = base_mem_block;
 
@@ -990,8 +990,8 @@
 							ServiceWindows();
 						} while(!KeyWaiting());
 
-						ReadKey(&c);	//kill the key we just pressed
-						if (c == 27)	//ESC
+						ReadKey(&ke);	//kill the key we just pressed
+						if (ke.keycode == 27)	//ESC
 							break;
 
 						// clear the Press Esc message ready for the new line
@@ -1029,7 +1029,7 @@
 	uint32 nuked = 0;
  	_standardHeader *header;
 	int scrolls = 0;
-	char c;
+	_keyboardEvent ke;
 
 	j = base_mem_block;
 
@@ -1063,8 +1063,8 @@
 							} while(!KeyWaiting());
 
 
-							ReadKey(&c);	//kill the key we just pressed
-							if (c == 27)	// ESC
+							ReadKey(&ke);	//kill the key we just pressed
+							if (ke.keycode == 27)	// ESC
 								break;
 
 							// clear the Press Esc message ready for the new line

Index: startup.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/startup.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- startup.cpp	20 Sep 2003 17:00:13 -0000	1.11
+++ startup.cpp	23 Sep 2003 15:59:52 -0000	1.12
@@ -176,7 +176,7 @@
 
 	uint32 j;
 	int scrolls = 0;
-	char c;
+	_keyboardEvent ke;
 
 	if (!total_startups) {
 		Print_to_console("Sorry - no startup positions registered?");
@@ -201,8 +201,8 @@
 				} while(!KeyWaiting());
 
 				// kill the key we just pressed
-				ReadKey(&c);
-				if (c == 27)
+				ReadKey(&ke);
+				if (ke.keycode == 27)
 					break;
 
 				// clear the Press Esc message ready for the

Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/sword2.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sword2.cpp	23 Sep 2003 06:27:58 -0000	1.34
+++ sword2.cpp	23 Sep 2003 15:59:52 -0000	1.35
@@ -258,8 +258,8 @@
 void Sword2State::go() {
 	OSystem::Property prop;
 	uint32 rv;
-	uint8  breakOut = 0;
-	char	c;
+	uint8 breakOut = 0;
+	_keyboardEvent ke;
 
 	// Zdebug("[%s]", lpCmdLine);
 
@@ -377,16 +377,19 @@
 #endif
 
 			if (KeyWaiting()) {
-				ReadKey(&c);
+				ReadKey(&ke);
+
+				char c = toupper(ke.ascii);
+
 #ifdef _SWORD2_DEBUG
 				// ESC whether paused or not
-				if (c == 27) {
+				if (ke.keycode == 27) {
 					PauseAllSound(); // see sound.cpp
 					StartConsole();	 // start the console
 				} else
 #endif
 				if (gamePaused) {	// if currently paused
-					if (toupper(c) == 'P') {
+					if (c == 'P') {
 						// 'P' while paused = unpause!
 						UnpauseGame();
 					}
@@ -394,21 +397,21 @@
 					// frame-skipping only allowed on
 					// debug version
 
-					else if (toupper(c) == ' ') {
+					else if (c == ' ') {
 						// SPACE bar while paused =
 						// step one frame!
 						stepOneCycle = 1;
 						UnpauseGame();
 					}
 #endif
-				} else if (toupper(c) == 'P') {
+				} else if (c == 'P') {
 					// 'P' while not paused = pause!
 					PauseGame();
-				} else if (toupper(c) == 'C' && _gameId == GID_SWORD2) {
+				} else if (c == 'C' && _gameId == GID_SWORD2) {
 					FN_play_credits(NULL);
 				}
 #ifdef _SWORD2_DEBUG
-				else if (toupper(c) == 'S') {
+				else if (c == 'S') {
 					// 'S' toggles speed up (by skipping
 					// display rendering)
 					renderSkip = 1 - renderSkip;





More information about the Scummvm-git-logs mailing list