[Scummvm-cvs-logs] CVS: scummvm/bs2/driver d_draw.cpp,1.23,1.24 driver96.h,1.39,1.40 keyboard.cpp,1.5,1.6 keyboard.h,1.2,1.3 rdwin.cpp,1.21,1.22

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


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

Modified Files:
	d_draw.cpp driver96.h keyboard.cpp keyboard.h rdwin.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: d_draw.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/d_draw.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- d_draw.cpp	23 Sep 2003 06:34:19 -0000	1.23
+++ d_draw.cpp	23 Sep 2003 15:59:52 -0000	1.24
@@ -463,9 +463,9 @@
 
 			ServiceWindows();
 
-			char key;
+			_keyboardEvent ke;
 
-			if (ReadKey(&key) == RD_OK && key == 27) {
+			if (ReadKey(&ke) == RD_OK && ke.keycode == 27) {
 				g_sword2->_mixer->stopHandle(handle);
 				break;
 			}

Index: driver96.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/driver96.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- driver96.h	23 Sep 2003 06:31:13 -0000	1.39
+++ driver96.h	23 Sep 2003 15:59:52 -0000	1.40
@@ -1207,11 +1207,16 @@
 //	---------------------
 //
 
-typedef struct
-{
+typedef struct {
 	uint16 buttons;
 } _mouseEvent;
 
+typedef struct {
+	uint16 ascii;
+	int keycode;
+	int modifiers;
+} _keyboardEvent;
+
 #if !defined(__GNUC__)
 	#pragma START_PACK_STRUCTS
 #endif
@@ -1369,7 +1374,7 @@
 //	Keyboard functions - from keyboard.c
 //-----------------------------------------------------------------------------
 extern BOOL  KeyWaiting(void);
-extern int32 ReadKey(char *key);
+extern int32 ReadKey(_keyboardEvent *ke);
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------

Index: keyboard.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/keyboard.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- keyboard.cpp	23 Sep 2003 06:30:52 -0000	1.5
+++ keyboard.cpp	23 Sep 2003 15:59:52 -0000	1.6
@@ -66,11 +66,15 @@
 uint8 keyBacklog = 0;	// The number of key presses waiting to be processed.
 uint8 keyPointer = 0;	// Index of the next key to read from the buffer.
 
-char keyBuffer[MAX_KEY_BUFFER];		// The keyboard buffer
+_keyboardEvent keyBuffer[MAX_KEY_BUFFER];		// The keyboard buffer
 
-void WriteKey(char key) {
+void WriteKey(uint16 ascii, int keycode, int modifiers) {
 	if (keyBuffer && keyBacklog < MAX_KEY_BUFFER) {
-		keyBuffer[(keyPointer + keyBacklog) % MAX_KEY_BUFFER] = key;
+		_keyboardEvent *slot = &keyBuffer[(keyPointer + keyBacklog) % MAX_KEY_BUFFER];
+
+		slot->ascii = ascii;
+		slot->keycode = keycode;
+		slot->modifiers = modifiers;
 		keyBacklog++;
 	}
 }
@@ -82,16 +86,19 @@
 	return FALSE;
 }
 
-
-
-int32 ReadKey(char *key) {
+int32 ReadKey(_keyboardEvent *ev) {
 	if (!keyBacklog)
 		return RDERR_NOKEYWAITING;
 
-	if (key == NULL)
+	if (ev == NULL)
 		return RDERR_INVALIDPOINTER;
 
-	*key = keyBuffer[keyPointer++];
+	ev->ascii = keyBuffer[keyPointer].ascii;
+	ev->keycode = keyBuffer[keyPointer].keycode;
+	ev->modifiers = keyBuffer[keyPointer].modifiers;
+
+	keyPointer++;
+
 	if (keyPointer == MAX_KEY_BUFFER)
 		keyPointer = 0;
 

Index: keyboard.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/keyboard.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- keyboard.h	23 Sep 2003 06:30:52 -0000	1.2
+++ keyboard.h	23 Sep 2003 15:59:52 -0000	1.3
@@ -40,6 +40,6 @@
 #ifndef KEYBOARD_H
 #define KEYBOARD_H
 
-void WriteKey(char key);		// Adds a keypress to the buffer
+void WriteKey(uint16 ascii, int keycode, int modifier);		// Adds a keypress to the buffer
 
 #endif

Index: rdwin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/driver/rdwin.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- rdwin.cpp	18 Sep 2003 02:07:16 -0000	1.21
+++ rdwin.cpp	23 Sep 2003 15:59:52 -0000	1.22
@@ -155,7 +155,7 @@
 				if (event.kbd.keycode == 'w')
 					GrabScreenShot();
 			}
-			WriteKey(event.kbd.ascii);
+			WriteKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
 			break;
 		case OSystem::EVENT_MOUSEMOVE:
 			mousex = event.mouse.x;





More information about the Scummvm-git-logs mailing list