[Scummvm-cvs-logs] CVS: scummvm/common system.h,1.74,1.75

Max Horn fingolfin at users.sourceforge.net
Sun Dec 5 09:44:02 CET 2004


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26853/common

Modified Files:
	system.h 
Log Message:
Clean up OSystem::Event

Index: system.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- system.h	27 Nov 2004 15:58:04 -0000	1.74
+++ system.h	5 Dec 2004 17:42:17 -0000	1.75
@@ -394,10 +394,18 @@
 	/**
 	 * The types of events backends may generate.
 	 * @see Event
+	 *
+	 * @todo Merge EVENT_LBUTTONDOWN, EVENT_RBUTTONDOWN and EVENT_WHEELDOWN;
+	 *       likewiese EVENT_LBUTTONUP, EVENT_RBUTTONUP, EVENT_WHEELUP.
+	 *       To do that, we just have to add a field to the Event which
+	 *       indicates which button was pressed.
 	 */
-	enum EventCode {
+	enum EventType {
+		/** A key was pressed, details in Event::kbd. */
 		EVENT_KEYDOWN = 1,
+		/** A key was released, details in Event::kbd. */
 		EVENT_KEYUP = 2,
+		/** The mouse moved, details in Event::mouse. */
 		EVENT_MOUSEMOVE = 3,
 		EVENT_LBUTTONDOWN = 4,
 		EVENT_LBUTTONUP = 5,
@@ -410,19 +418,46 @@
 		EVENT_SCREEN_CHANGED = 11
 	};
 
+	/**
+	 * Keyboard modifier flags, used for Event::kbd::flags.
+	 */
 	enum {
-		KBD_CTRL = 1,
-		KBD_ALT = 2,
-		KBD_SHIFT = 4
+		KBD_CTRL  = 1 << 0,
+		KBD_ALT   = 1 << 1,
+		KBD_SHIFT = 1 << 2
 	};
 
 	/**
 	 * Data structure for an event. A pointer to an instance of Event
-	 * can be passed to pollEvent. 
+	 * can be passed to pollEvent.
+	 * @todo Rework/document this structure. It should be made 100% clear which
+	 *       field is valid for which event type.
+	 *       Implementation wise, we might want to use the classic
+	 *       union-of-structs trick. It goes roughly like this:
+	 *       struct BasicEvent {
+	 *       	EventType type;
+	 *       };
+	 *       struct MouseMovedEvent : BasicEvent {
+	 *       	Common::Point pos;
+	 *       };
+	 *       struct MouseButtonEvent : MouseMovedEvent {
+	 *       	int button;
+	 *       };
+	 *       struct KeyEvent : BasicEvent {
+	 *       	...
+	 *       };
+	 *       ...
+	 *       union Event {
+	 *          EventType type;
+	 *       	MouseMovedEvent mouse;
+	 *       	MouseButtonEvent button;
+	 *       	KeyEvent key;
+	 *       	...
+	 *       };
 	 */
 	struct Event {
 		/** The type of the event. */
-		EventCode event_code;
+		EventType type;
 		/**
 		  * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and
 		  * EVENT_KEYUP). For all other event types, content is undefined.
@@ -521,7 +556,7 @@
 	 * Create a new mutex.
 	 * @return the newly created mutex, or 0 if an error occured.
 	 */
-	virtual MutexRef createMutex(void) = 0;
+	virtual MutexRef createMutex() = 0;
 
 	/**
 	 * Lock the given mutex.





More information about the Scummvm-git-logs mailing list