[Scummvm-cvs-logs] SF.net SVN: scummvm:[33959] residual/trunk
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Sun Aug 17 09:21:36 CEST 2008
Revision: 33959
http://scummvm.svn.sourceforge.net/scummvm/?rev=33959&view=rev
Author: aquadran
Date: 2008-08-17 07:21:35 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
added default-events manager from scummvm
Modified Paths:
--------------
residual/trunk/dists/msvc7/residual.vcproj
residual/trunk/dists/msvc71/residual.vcproj
residual/trunk/dists/msvc8/residual.vcproj
residual/trunk/dists/msvc9/residual.vcproj
residual/trunk/engine/backend/module.mk
Added Paths:
-----------
residual/trunk/common/events.h
residual/trunk/common/keyboard.h
residual/trunk/common/rect.h
residual/trunk/engine/backend/events/
residual/trunk/engine/backend/events/default/
residual/trunk/engine/backend/events/default/default-events.cpp
residual/trunk/engine/backend/events/default/default-events.h
Added: residual/trunk/common/events.h
===================================================================
--- residual/trunk/common/events.h (rev 0)
+++ residual/trunk/common/events.h 2008-08-17 07:21:35 UTC (rev 33959)
@@ -0,0 +1,179 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ *
+ * Residual is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the AUTHORS
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef COMMON_EVENTS_H
+#define COMMON_EVENTS_H
+
+#include "common/keyboard.h"
+#include "common/rect.h"
+#include "common/noncopyable.h"
+
+namespace Common {
+
+/**
+ * The types of events backends may generate.
+ * @see Event
+ *
+ * @todo Merge EVENT_LBUTTONDOWN, EVENT_RBUTTONDOWN and EVENT_WHEELDOWN;
+ * likewise 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 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,
+ EVENT_RBUTTONDOWN = 6,
+ EVENT_RBUTTONUP = 7,
+ EVENT_WHEELUP = 8,
+ EVENT_WHEELDOWN = 9,
+ EVENT_MBUTTONDOWN = 13,
+ EVENT_MBUTTONUP = 14,
+
+ EVENT_QUIT = 10,
+ EVENT_SCREEN_CHANGED = 11,
+ /**
+ * The backend requests the agi engine's predictive dialog to be shown.
+ * TODO: Fingolfin suggests that it would be of better value to expand
+ * on this notion by generalizing its use. For example the backend could
+ * use events to ask for the save game dialog or to pause the engine.
+ * An associated enumerated type can accomplish this.
+ **/
+ EVENT_PREDICTIVE_DIALOG = 12
+};
+
+/**
+ * Data structure for an event. A pointer to an instance of Event
+ * 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. */
+ EventType type;
+ /** Flag to indicate if the event is real or synthetic. E.g. keyboard
+ * repeat events are synthetic.
+ */
+ bool synthetic;
+ /**
+ * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and
+ * EVENT_KEYUP). For all other event types, content is undefined.
+ */
+ KeyState kbd;
+ /**
+ * The mouse coordinates, in virtual screen coordinates. Only valid
+ * for mouse events.
+ * Virtual screen coordinates means: the coordinate system of the
+ * screen area as defined by the most recent call to initSize().
+ */
+ Common::Point mouse;
+};
+
+
+/**
+ * The EventManager provides user input events to the client code.
+ * In addition, it keeps track of the state of various input devices,
+ * like keys, mouse position and buttons.
+ */
+class EventManager : NonCopyable {
+public:
+ EventManager() {}
+ virtual ~EventManager() {}
+
+ enum {
+ LBUTTON = 1 << 0,
+ RBUTTON = 1 << 1
+ };
+
+ /**
+ * Get the next event in the event queue.
+ * @param event point to an Event struct, which will be filled with the event data.
+ * @return true if an event was retrieved.
+ */
+ virtual bool pollEvent(Common::Event &event) = 0;
+
+ /** Register random source so it can be serialized in game test purposes **/
+ virtual void registerRandomSource(Common::RandomSource &rnd, const char *name) = 0;
+
+ virtual void processMillis(uint32 &millis) = 0;
+
+ /** Return the current mouse position */
+ virtual Common::Point getMousePos() const = 0;
+
+ /**
+ * Return a bitmask with the button states:
+ * - bit 0: left button up=1, down=0
+ * - bit 1: right button up=1, down=0
+ */
+ virtual int getButtonState() const = 0;
+
+ /** Get a bitmask with the current modifier state */
+ virtual int getModifierState() const = 0;
+
+ /**
+ * Should the application terminate? Set to true if we
+ * received an EVENT_QUIT.
+ */
+ virtual int shouldQuit() const = 0;
+
+ // Optional: check whether a given key is currently pressed ????
+ //virtual bool isKeyPressed(int keycode) = 0;
+
+ // TODO: Keyboard repeat support?
+
+ // TODO: Consider removing OSystem::getScreenChangeID and
+ // replacing it by a generic getScreenChangeID method here
+};
+
+} // End of namespace Common
+
+#endif
Property changes on: residual/trunk/common/events.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: residual/trunk/common/keyboard.h
===================================================================
--- residual/trunk/common/keyboard.h (rev 0)
+++ residual/trunk/common/keyboard.h 2008-08-17 07:21:35 UTC (rev 33959)
@@ -0,0 +1,266 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ *
+ * Residual is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the AUTHORS
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef COMMON_KEYBOARD_H
+#define COMMON_KEYBOARD_H
+
+#include "common/sys.h"
+
+namespace Common {
+
+enum KeyCode {
+ KEYCODE_INVALID = 0,
+
+ KEYCODE_BACKSPACE = 8,
+ KEYCODE_TAB = 9,
+ KEYCODE_CLEAR = 12,
+ KEYCODE_RETURN = 13,
+ KEYCODE_PAUSE = 19,
+ KEYCODE_ESCAPE = 27,
+ KEYCODE_SPACE = 32,
+ KEYCODE_EXCLAIM = 33,
+ KEYCODE_QUOTEDBL = 34,
+ KEYCODE_HASH = 35,
+ KEYCODE_DOLLAR = 36,
+ KEYCODE_AMPERSAND = 38,
+ KEYCODE_QUOTE = 39,
+ KEYCODE_LEFTPAREN = 40,
+ KEYCODE_RIGHTPAREN = 41,
+ KEYCODE_ASTERISK = 42,
+ KEYCODE_PLUS = 43,
+ KEYCODE_COMMA = 44,
+ KEYCODE_MINUS = 45,
+ KEYCODE_PERIOD = 46,
+ KEYCODE_SLASH = 47,
+ KEYCODE_0 = 48,
+ KEYCODE_1 = 49,
+ KEYCODE_2 = 50,
+ KEYCODE_3 = 51,
+ KEYCODE_4 = 52,
+ KEYCODE_5 = 53,
+ KEYCODE_6 = 54,
+ KEYCODE_7 = 55,
+ KEYCODE_8 = 56,
+ KEYCODE_9 = 57,
+ KEYCODE_COLON = 58,
+ KEYCODE_SEMICOLON = 59,
+ KEYCODE_LESS = 60,
+ KEYCODE_EQUALS = 61,
+ KEYCODE_GREATER = 62,
+ KEYCODE_QUESTION = 63,
+ KEYCODE_AT = 64,
+
+ KEYCODE_LEFTBRACKET = 91,
+ KEYCODE_BACKSLASH = 92,
+ KEYCODE_RIGHTBRACKET= 93,
+ KEYCODE_CARET = 94,
+ KEYCODE_UNDERSCORE = 95,
+ KEYCODE_BACKQUOTE = 96,
+ KEYCODE_a = 97,
+ KEYCODE_b = 98,
+ KEYCODE_c = 99,
+ KEYCODE_d = 100,
+ KEYCODE_e = 101,
+ KEYCODE_f = 102,
+ KEYCODE_g = 103,
+ KEYCODE_h = 104,
+ KEYCODE_i = 105,
+ KEYCODE_j = 106,
+ KEYCODE_k = 107,
+ KEYCODE_l = 108,
+ KEYCODE_m = 109,
+ KEYCODE_n = 110,
+ KEYCODE_o = 111,
+ KEYCODE_p = 112,
+ KEYCODE_q = 113,
+ KEYCODE_r = 114,
+ KEYCODE_s = 115,
+ KEYCODE_t = 116,
+ KEYCODE_u = 117,
+ KEYCODE_v = 118,
+ KEYCODE_w = 119,
+ KEYCODE_x = 120,
+ KEYCODE_y = 121,
+ KEYCODE_z = 122,
+ KEYCODE_DELETE = 127,
+
+ // Numeric keypad
+ KEYCODE_KP0 = 256,
+ KEYCODE_KP1 = 257,
+ KEYCODE_KP2 = 258,
+ KEYCODE_KP3 = 259,
+ KEYCODE_KP4 = 260,
+ KEYCODE_KP5 = 261,
+ KEYCODE_KP6 = 262,
+ KEYCODE_KP7 = 263,
+ KEYCODE_KP8 = 264,
+ KEYCODE_KP9 = 265,
+ KEYCODE_KP_PERIOD = 266,
+ KEYCODE_KP_DIVIDE = 267,
+ KEYCODE_KP_MULTIPLY = 268,
+ KEYCODE_KP_MINUS = 269,
+ KEYCODE_KP_PLUS = 270,
+ KEYCODE_KP_ENTER = 271,
+ KEYCODE_KP_EQUALS = 272,
+
+ // Arrows + Home/End pad
+ KEYCODE_UP = 273,
+ KEYCODE_DOWN = 274,
+ KEYCODE_RIGHT = 275,
+ KEYCODE_LEFT = 276,
+ KEYCODE_INSERT = 277,
+ KEYCODE_HOME = 278,
+ KEYCODE_END = 279,
+ KEYCODE_PAGEUP = 280,
+ KEYCODE_PAGEDOWN = 281,
+
+ // Function keys
+ KEYCODE_F1 = 282,
+ KEYCODE_F2 = 283,
+ KEYCODE_F3 = 284,
+ KEYCODE_F4 = 285,
+ KEYCODE_F5 = 286,
+ KEYCODE_F6 = 287,
+ KEYCODE_F7 = 288,
+ KEYCODE_F8 = 289,
+ KEYCODE_F9 = 290,
+ KEYCODE_F10 = 291,
+ KEYCODE_F11 = 292,
+ KEYCODE_F12 = 293,
+ KEYCODE_F13 = 294,
+ KEYCODE_F14 = 295,
+ KEYCODE_F15 = 296,
+
+ // Key state modifier keys
+ KEYCODE_NUMLOCK = 300,
+ KEYCODE_CAPSLOCK = 301,
+ KEYCODE_SCROLLOCK = 302,
+ KEYCODE_RSHIFT = 303,
+ KEYCODE_LSHIFT = 304,
+ KEYCODE_RCTRL = 305,
+ KEYCODE_LCTRL = 306,
+ KEYCODE_RALT = 307,
+ KEYCODE_LALT = 308,
+ KEYCODE_RMETA = 309,
+ KEYCODE_LMETA = 310,
+ KEYCODE_LSUPER = 311, // Left "Windows" key
+ KEYCODE_RSUPER = 312, // Right "Windows" key
+ KEYCODE_MODE = 313, // "Alt Gr" key
+ KEYCODE_COMPOSE = 314, // Multi-key compose key
+
+ // Miscellaneous function keys
+ KEYCODE_HELP = 315,
+ KEYCODE_PRINT = 316,
+ KEYCODE_SYSREQ = 317,
+ KEYCODE_BREAK = 318,
+ KEYCODE_MENU = 319,
+ KEYCODE_POWER = 320, // Power Macintosh power key
+ KEYCODE_EURO = 321, // Some european keyboards
+ KEYCODE_UNDO = 322 // Atari keyboard has Undo
+};
+
+/**
+ * List of certan special and some fake 'ascii' values used in keyboard events.
+ * The values for the function keys listed here are based on what certain SCUMM
+ * games expect in their scripts.
+ * @todo Get rid of the function key values, and instead enforce that engines use
+ * the keycode value to handle these.
+ */
+enum {
+ ASCII_BACKSPACE = 8,
+ ASCII_TAB = 9,
+ ASCII_RETURN = 13,
+ ASCII_ESCAPE = 27,
+ ASCII_SPACE = 32,
+
+ ASCII_F1 = 315,
+ ASCII_F2 = 316,
+ ASCII_F3 = 317,
+ ASCII_F4 = 318,
+ ASCII_F5 = 319,
+ ASCII_F6 = 320,
+ ASCII_F7 = 321,
+ ASCII_F8 = 322,
+ ASCII_F9 = 323,
+ ASCII_F10 = 324,
+ ASCII_F11 = 325,
+ ASCII_F12 = 326
+};
+
+/**
+ * Keyboard modifier flags, used for Event::kbd::flags.
+ */
+enum {
+ KBD_CTRL = 1 << 0,
+ KBD_ALT = 1 << 1,
+ KBD_SHIFT = 1 << 2
+};
+
+/**
+ * Keyboard status, as used in the Event struct.
+ */
+struct KeyState {
+ /**
+ * Abstract key code (will be the same for any given key regardless
+ * of modifiers being held at the same time.
+ * For example, this is the same for both 'A' and Shift-'A'.
+ * @todo Document which values are to be used for non-ASCII keys
+ * like F1-F10. For now, let's just say that our primary backend
+ * is the SDL one, and it uses the values SDL uses... so until
+ * we fix this, your best bet is to get a copy of SDL_keysym.h
+ * and look at that, if you want to find out a key code.
+ */
+ KeyCode keycode;
+
+ /**
+ * ASCII-value of the pressed key (if any).
+ * This depends on modifiers, i.e. pressing the 'A' key results in
+ * different values here depending on the status of shift, alt and
+ * caps lock.
+ */
+ uint16 ascii;
+
+ /**
+ * Status of the modifier keys. Bits are set in this for each
+ * pressed modifier
+ * @see KBD_CTRL, KBD_ALT, KBD_SHIFT
+ */
+ byte flags;
+
+ KeyState(KeyCode kc = KEYCODE_INVALID, uint16 asc = 0, byte f = 0) {
+ keycode = kc;
+ ascii = asc ? asc : (uint16)kc;
+ flags = f;
+ }
+
+ void reset() {
+ keycode = KEYCODE_INVALID;
+ ascii = flags = 0;
+ }
+};
+
+} // End of namespace Common
+
+#endif
Property changes on: residual/trunk/common/keyboard.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: residual/trunk/common/rect.h
===================================================================
--- residual/trunk/common/rect.h (rev 0)
+++ residual/trunk/common/rect.h 2008-08-17 07:21:35 UTC (rev 33959)
@@ -0,0 +1,218 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ *
+ * Residual is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the AUTHORS
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef COMMON_RECT_H
+#define COMMON_RECT_H
+
+#include "common/sys.h"
+#include "common/util.h"
+
+namespace Common {
+
+/*! @brief simple class for handling both 2D position and size
+
+ This small class is an helper for position and size values.
+*/
+struct Point {
+ int16 x; //!< The horizontal part of the point
+ int16 y; //!< The vertical part of the point
+
+ Point() : x(0), y(0) {}
+ Point(const Point &p) : x(p.x), y(p.y) {}
+ explicit Point(int16 x1, int16 y1) : x(x1), y(y1) {}
+ Point & operator=(const Point & p) { x = p.x; y = p.y; return *this; };
+ bool operator==(const Point & p) const { return x == p.x && y == p.y; };
+ bool operator!=(const Point & p) const { return x != p.x || y != p.y; };
+
+ /**
+ * Return the square of the distance between this point and the point p.
+ *
+ * @param p the other point
+ * @return the distance between this and p
+ */
+ uint sqrDist(const Point & p) const {
+ int diffx = ABS(p.x - x);
+ if (diffx >= 0x1000)
+ return 0xFFFFFF;
+
+ int diffy = ABS(p.y - y);
+ if (diffy >= 0x1000)
+ return 0xFFFFFF;
+
+ return uint(diffx*diffx + diffy*diffy);
+ }
+};
+
+/*! @brief simple class for handling a rectangular zone.
+
+ This small class is an helper for rectangles.
+ Note: This implementation is built around the assumption that (top,left) is
+ part of the rectangle, but (bottom,right) is not! This is reflected in
+ various methods, including contains(), intersects() and others.
+
+ Another very wide spread approach to rectangle classes treats (bottom,right)
+ also as a part of the rectangle.
+
+ Coneptually, both are sound, but the approach we use saves many intermediate
+ computations (like computing the height in our case is done by doing this:
+ height = bottom - top;
+ while in the alternate system, it would be
+ height = bottom - top + 1;
+
+ When writing code using our Rect class, always keep this principle in mind!
+*/
+struct Rect {
+ int16 top, left; //!< The point at the top left of the rectangle (part of the rect).
+ int16 bottom, right; //!< The point at the bottom right of the rectangle (not part of the rect).
+
+ Rect() : top(0), left(0), bottom(0), right(0) {}
+ Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
+ Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) {
+ assert(isValidRect());
+ }
+ int16 width() const { return right - left; }
+ int16 height() const { return bottom - top; }
+
+ void setWidth(int16 aWidth) {
+ right = left + aWidth;
+ }
+
+ void setHeight(int16 aHeight) {
+ bottom = top + aHeight;
+ }
+
+ /*! @brief check if given position is inside this rectangle
+
+ @param x the horizontal position to check
+ @param y the vertical position to check
+
+ @return true if the given position is inside this rectangle, false otherwise
+ */
+ bool contains(int16 x, int16 y) const {
+ return (left <= x) && (x < right) && (top <= y) && (y < bottom);
+ }
+
+ /*! @brief check if given point is inside this rectangle
+
+ @param p the point to check
+
+ @return true if the given point is inside this rectangle, false otherwise
+ */
+ bool contains(const Point &p) const {
+ return contains(p.x, p.y);
+ }
+
+ /*! @brief check if given rectangle intersects with this rectangle
+
+ @param r the rectangle to check
+
+ @return true if the given rectangle is inside the rectangle, false otherwise
+ */
+ bool intersects(const Rect &r) const {
+ return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom);
+ }
+
+ /*! @brief extend this rectangle so that it contains r
+
+ @param r the rectangle to extend by
+ */
+ void extend(const Rect &r) {
+ left = MIN(left, r.left);
+ right = MAX(right, r.right);
+ top = MIN(top, r.top);
+ bottom = MAX(bottom, r.bottom);
+ }
+
+ /*! @brief extend this rectangle in all four directions by the given number of pixels
+
+ @param offset the size to grow by
+ */
+ void grow(int16 offset) {
+ top -= offset;
+ left -= offset;
+ bottom += offset;
+ right += offset;
+ }
+
+ void clip(const Rect &r) {
+ assert(isValidRect());
+ assert(r.isValidRect());
+
+ if (top < r.top) top = r.top;
+ else if (top > r.bottom) top = r.bottom;
+
+ if (left < r.left) left = r.left;
+ else if (left > r.right) left = r.right;
+
+ if (bottom > r.bottom) bottom = r.bottom;
+ else if (bottom < r.top) bottom = r.top;
+
+ if (right > r.right) right = r.right;
+ else if (right < r.left) right = r.left;
+ }
+
+ void clip(int maxw, int maxh) {
+ clip(Rect(0, 0, maxw, maxh));
+ }
+
+ bool isEmpty() const {
+ return (left >= right || top >= bottom);
+ }
+
+ bool isValidRect() const {
+ return (left <= right && top <= bottom);
+ }
+
+ void moveTo(int16 x, int16 y) {
+ bottom += y - top;
+ right += x - left;
+ top = y;
+ left = x;
+ }
+
+ void translate(int16 dx, int16 dy) {
+ left += dx; right += dx;
+ top += dy; bottom += dy;
+ }
+
+ void moveTo(const Point &p) {
+ moveTo(p.x, p.y);
+ }
+
+ void debugPrint(int debuglevel = 0, const char *caption = "Rect:") const {
+ debug(debuglevel, "%s %d, %d, %d, %d", caption, left, top, right, bottom);
+ }
+
+ /*! @brief create a rectangle around the given center */
+ static Rect center(int16 cx, int16 cy, int16 w, int16 h) {
+ w /= 2;
+ h /= 2;
+ return Rect(cx - w, cy - h, cx + w, cy + h);
+ }
+};
+
+} // End of namespace Common
+
+#endif
Property changes on: residual/trunk/common/rect.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: residual/trunk/dists/msvc7/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc7/residual.vcproj 2008-08-17 07:10:36 UTC (rev 33958)
+++ residual/trunk/dists/msvc7/residual.vcproj 2008-08-17 07:21:35 UTC (rev 33959)
@@ -142,6 +142,9 @@
RelativePath="..\..\common\error.h">
</File>
<File
+ RelativePath="..\..\common\events.h">
+ </File>
+ <File
RelativePath="..\..\common\file.cpp">
</File>
<File
@@ -169,6 +172,9 @@
RelativePath="..\..\common\hashmap.h">
</File>
<File
+ RelativePath="..\..\common\keyboard.h">
+ </File>
+ <File
RelativePath="..\..\common\list.h">
</File>
<File
@@ -202,6 +208,9 @@
RelativePath="..\..\common\ptr.h">
</File>
<File
+ RelativePath="..\..\common\rect.h">
+ </File>
+ <File
RelativePath="..\..\common\savefile.h">
</File>
<File
@@ -226,6 +235,9 @@
RelativePath="..\..\common\timer.h">
</File>
<File
+ RelativePath="..\..\common\util.cpp">
+ </File>
+ <File
RelativePath="..\..\common\util.h">
</File>
<File
@@ -784,6 +796,20 @@
</File>
</Filter>
</Filter>
+ <Filter
+ Name="events">
+ <Filter
+ Name="default">
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
</Filter>
</Filter>
<Filter
Modified: residual/trunk/dists/msvc71/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc71/residual.vcproj 2008-08-17 07:10:36 UTC (rev 33958)
+++ residual/trunk/dists/msvc71/residual.vcproj 2008-08-17 07:21:35 UTC (rev 33959)
@@ -156,6 +156,9 @@
RelativePath="..\..\common\error.h">
</File>
<File
+ RelativePath="..\..\common\events.h">
+ </File>
+ <File
RelativePath="..\..\common\file.cpp">
</File>
<File
@@ -183,6 +186,9 @@
RelativePath="..\..\common\hashmap.h">
</File>
<File
+ RelativePath="..\..\common\keyboard.h">
+ </File>
+ <File
RelativePath="..\..\common\list.h">
</File>
<File
@@ -216,6 +222,9 @@
RelativePath="..\..\common\ptr.h">
</File>
<File
+ RelativePath="..\..\common\rect.h">
+ </File>
+ <File
RelativePath="..\..\common\savefile.h">
</File>
<File
@@ -240,6 +249,9 @@
RelativePath="..\..\common\timer.h">
</File>
<File
+ RelativePath="..\..\common\util.cpp">
+ </File>
+ <File
RelativePath="..\..\common\util.h">
</File>
<File
@@ -798,6 +810,20 @@
</File>
</Filter>
</Filter>
+ <Filter
+ Name="events">
+ <Filter
+ Name="default">
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
</Filter>
</Filter>
<Filter
Modified: residual/trunk/dists/msvc8/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc8/residual.vcproj 2008-08-17 07:10:36 UTC (rev 33958)
+++ residual/trunk/dists/msvc8/residual.vcproj 2008-08-17 07:21:35 UTC (rev 33959)
@@ -228,6 +228,10 @@
>
</File>
<File
+ RelativePath="..\..\common\events.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\file.cpp"
>
</File>
@@ -264,6 +268,10 @@
>
</File>
<File
+ RelativePath="..\..\common\keyboard.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\list.h"
>
</File>
@@ -308,6 +316,10 @@
>
</File>
<File
+ RelativePath="..\..\common\rect.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\savefile.h"
>
</File>
@@ -340,6 +352,10 @@
>
</File>
<File
+ RelativePath="..\..\common\util.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\common\util.h"
>
</File>
@@ -1066,6 +1082,22 @@
</File>
</Filter>
</Filter>
+ <Filter
+ Name="events"
+ >
+ <Filter
+ Name="default"
+ >
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
</Filter>
</Filter>
<Filter
Modified: residual/trunk/dists/msvc9/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc9/residual.vcproj 2008-08-17 07:10:36 UTC (rev 33958)
+++ residual/trunk/dists/msvc9/residual.vcproj 2008-08-17 07:21:35 UTC (rev 33959)
@@ -233,6 +233,10 @@
>
</File>
<File
+ RelativePath="..\..\common\events.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\file.cpp"
>
</File>
@@ -269,6 +273,10 @@
>
</File>
<File
+ RelativePath="..\..\common\keyboard.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\list.h"
>
</File>
@@ -313,6 +321,10 @@
>
</File>
<File
+ RelativePath="..\..\common\rect.h"
+ >
+ </File>
+ <File
RelativePath="..\..\common\savefile.h"
>
</File>
@@ -345,6 +357,10 @@
>
</File>
<File
+ RelativePath="..\..\common\util.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\common\util.h"
>
</File>
@@ -1071,6 +1087,22 @@
</File>
</Filter>
</Filter>
+ <Filter
+ Name="events"
+ >
+ <Filter
+ Name="default"
+ >
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\backend\events\default\default-events.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
</Filter>
</Filter>
<Filter
Property changes on: residual/trunk/engine/backend/events/default
___________________________________________________________________
Added: svn:ignore
+ .deps
*.d
*.o
Added: residual/trunk/engine/backend/events/default/default-events.cpp
===================================================================
--- residual/trunk/engine/backend/events/default/default-events.cpp (rev 0)
+++ residual/trunk/engine/backend/events/default/default-events.cpp 2008-08-17 07:21:35 UTC (rev 33959)
@@ -0,0 +1,438 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ *
+ * Residual is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the AUTHORS
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(DISABLE_DEFAULT_EVENTMANAGER)
+
+#include "common/config-manager.h"
+#include "engine/backend/events/default/default-events.h"
+
+#define RECORD_SIGNATURE 0x54455354
+#define RECORD_VERSION 1
+
+void readRecord(Common::InSaveFile *inFile, uint32 &diff, Common::Event &event) {
+ diff = inFile->readUint32LE();
+
+ event.type = (Common::EventType)inFile->readUint32LE();
+
+ switch(event.type) {
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYUP:
+ event.kbd.keycode = (Common::KeyCode)inFile->readSint32LE();
+ event.kbd.ascii = inFile->readUint16LE();
+ event.kbd.flags = inFile->readByte();
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_WHEELUP:
+ case Common::EVENT_WHEELDOWN:
+ event.mouse.x = inFile->readSint16LE();
+ event.mouse.y = inFile->readSint16LE();
+ break;
+ default:
+ break;
+ }
+}
+
+void writeRecord(Common::OutSaveFile *outFile, uint32 diff, Common::Event &event) {
+ outFile->writeUint32LE(diff);
+
+ outFile->writeUint32LE((uint32)event.type);
+
+ switch(event.type) {
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYUP:
+ outFile->writeSint32LE(event.kbd.keycode);
+ outFile->writeUint16LE(event.kbd.ascii);
+ outFile->writeByte(event.kbd.flags);
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_WHEELUP:
+ case Common::EVENT_WHEELDOWN:
+ outFile->writeSint16LE(event.mouse.x);
+ outFile->writeSint16LE(event.mouse.y);
+ break;
+ default:
+ break;
+ }
+}
+
+DefaultEventManager::DefaultEventManager(Driver *boss) :
+ _boss(boss),
+ _buttonState(0),
+ _modifierState(0),
+ _shouldQuit(false) {
+
+ assert(_boss);
+
+ _recordFile = NULL;
+ _recordTimeFile = NULL;
+ _playbackFile = NULL;
+ _playbackTimeFile = NULL;
+ _timeMutex = _boss->createMutex();
+ _recorderMutex = _boss->createMutex();
+
+ _eventCount = 0;
+ _lastEventCount = 0;
+ _lastMillis = 0;
+
+ Common::String recordModeString = ConfMan.get("record_mode");
+ if (recordModeString.compareToIgnoreCase("record") == 0) {
+ _recordMode = kRecorderRecord;
+ } else {
+ if (recordModeString.compareToIgnoreCase("playback") == 0) {
+ _recordMode = kRecorderPlayback;
+ } else {
+ _recordMode = kPassthrough;
+ }
+ }
+
+ _recordFileName = ConfMan.get("record_file_name");
+ if (_recordFileName.empty()) {
+ _recordFileName = "record.bin";
+ }
+ _recordTempFileName = ConfMan.get("record_temp_file_name");
+ if (_recordTempFileName.empty()) {
+ _recordTempFileName = "record.tmp";
+ }
+ _recordTimeFileName = ConfMan.get("record_time_file_name");
+ if (_recordTimeFileName.empty()) {
+ _recordTimeFileName = "record.time";
+ }
+
+ // Reset key repeat
+ _currentKeyDown.keycode = 0;
+
+ // recorder stuff
+ if (_recordMode == kRecorderRecord) {
+ _recordCount = 0;
+ _recordTimeCount = 0;
+ _recordFile = _boss->getSavefileManager()->openForSaving(_recordTempFileName.c_str());
+ _recordTimeFile = _boss->getSavefileManager()->openForSaving(_recordTimeFileName.c_str());
+ _recordSubtitles = ConfMan.getBool("subtitles");
+ }
+
+ uint32 sign;
+ uint32 version;
+ uint32 randomSourceCount;
+ if (_recordMode == kRecorderPlayback) {
+ _playbackCount = 0;
+ _playbackTimeCount = 0;
+ _playbackFile = _boss->getSavefileManager()->openForLoading(_recordFileName.c_str());
+ _playbackTimeFile = _boss->getSavefileManager()->openForLoading(_recordTimeFileName.c_str());
+
+ if (!_playbackFile) {
+ warning("Cannot open playback file %s. Playback was switched off", _recordFileName.c_str());
+ _recordMode = kPassthrough;
+ }
+
+ if (!_playbackTimeFile) {
+ warning("Cannot open playback time file %s. Playback was switched off", _recordTimeFileName.c_str());
+ _recordMode = kPassthrough;
+ }
+ }
+
+ if (_recordMode == kRecorderPlayback) {
+ sign = _playbackFile->readUint32LE();
+ if (sign != RECORD_SIGNATURE) {
+ error("Unknown record file signature");
+ }
+ version = _playbackFile->readUint32LE();
+
+ // conf vars
+ ConfMan.setBool("subtitles", _playbackFile->readByte() != 0);
+
+ _recordCount = _playbackFile->readUint32LE();
+ _recordTimeCount = _playbackFile->readUint32LE();
+ randomSourceCount = _playbackFile->readUint32LE();
+ for (uint i = 0; i < randomSourceCount; ++i) {
+ RandomSourceRecord rec;
+ rec.name = "";
+ uint32 sLen = _playbackFile->readUint32LE();
+ for (uint j = 0; j < sLen; ++j) {
+ char c = _playbackFile->readSByte();
+ rec.name += c;
+ }
+ rec.seed = _playbackFile->readUint32LE();
+ _randomSourceRecords.push_back(rec);
+ }
+
+ _hasPlaybackEvent = false;
+ }
+}
+
+DefaultEventManager::~DefaultEventManager() {
+ _boss->lockMutex(_timeMutex);
+ _boss->lockMutex(_recorderMutex);
+ _recordMode = kPassthrough;
+ _boss->unlockMutex(_timeMutex);
+ _boss->unlockMutex(_recorderMutex);
+
+ if (_playbackFile != NULL) {
+ delete _playbackFile;
+ }
+ if (_playbackTimeFile != NULL) {
+ delete _playbackTimeFile;
+ }
+
+ if (_recordFile != NULL) {
+ _recordFile->finalize();
+ delete _recordFile;
+ _recordTimeFile->finalize();
+ delete _recordTimeFile;
+
+ _playbackFile = _boss->getSavefileManager()->openForLoading(_recordTempFileName.c_str());
+
+ _recordFile = _boss->getSavefileManager()->openForSaving(_recordFileName.c_str());
+ _recordFile->writeUint32LE(RECORD_SIGNATURE);
+ _recordFile->writeUint32LE(RECORD_VERSION);
+
+ // conf vars
+ _recordFile->writeByte(_recordSubtitles ? 1 : 0);
+
+ _recordFile->writeUint32LE(_recordCount);
+ _recordFile->writeUint32LE(_recordTimeCount);
+
+ _recordFile->writeUint32LE(_randomSourceRecords.size());
+ for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
+ _recordFile->writeUint32LE(_randomSourceRecords[i].name.size());
+ _recordFile->writeString(_randomSourceRecords[i].name);
+ _recordFile->writeUint32LE(_randomSourceRecords[i].seed);
+ }
+
+ for (uint i = 0; i < _recordCount; ++i) {
+ uint32 tempDiff;
+ Common::Event tempEvent;
+ readRecord(_playbackFile, tempDiff, tempEvent);
+ writeRecord(_recordFile, tempDiff, tempEvent);
+ }
+
+ _recordFile->finalize();
+ delete _recordFile;
+ delete _playbackFile;
+
+ //TODO: remove recordTempFileName'ed file
+ }
+ _boss->deleteMutex(_timeMutex);
+ _boss->deleteMutex(_recorderMutex);
+}
+
+bool DefaultEventManager::playback(Common::Event &event) {
+
+ if (!_hasPlaybackEvent) {
+ if (_recordCount > _playbackCount) {
+ readRecord(_playbackFile, const_cast<uint32&>(_playbackDiff), _playbackEvent);
+ _playbackCount++;
+ _hasPlaybackEvent = true;
+ }
+ }
+
+ if (_hasPlaybackEvent) {
+ if (_playbackDiff <= (_eventCount - _lastEventCount)) {
+ switch(_playbackEvent.type) {
+ case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_WHEELUP:
+ case Common::EVENT_WHEELDOWN:
+// _boss->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
+ break;
+ default:
+ break;
+ }
+ event = _playbackEvent;
+ _hasPlaybackEvent = false;
+ _lastEventCount = _eventCount;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void DefaultEventManager::record(Common::Event &event) {
+ writeRecord(_recordFile, _eventCount - _lastEventCount, event);
+
+ _recordCount++;
+ _lastEventCount = _eventCount;
+}
+
+void DefaultEventManager::registerRandomSource(Common::RandomSource &rnd, const char *name) {
+
+ if (_recordMode == kRecorderRecord) {
+ RandomSourceRecord rec;
+ rec.name = name;
+ rec.seed = rnd.getSeed();
+ _randomSourceRecords.push_back(rec);
+ }
+
+ if (_recordMode == kRecorderPlayback) {
+ for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
+ if (_randomSourceRecords[i].name == name) {
+ rnd.setSeed(_randomSourceRecords[i].seed);
+ _randomSourceRecords.remove_at(i);
+ break;
+ }
+ }
+ }
+}
+
+void DefaultEventManager::processMillis(uint32 &millis) {
+ uint32 d;
+ if (_recordMode == kPassthrough) {
+ return;
+ }
+
+ _boss->lockMutex(_timeMutex);
+ if (_recordMode == kRecorderRecord) {
+ //Simple RLE compression
+ d = millis - _lastMillis;
+ if (d >= 0xff) {
+ _recordTimeFile->writeByte(0xff);
+ _recordTimeFile->writeUint32LE(d);
+ } else {
+ _recordTimeFile->writeByte(d);
+ }
+ _recordTimeCount++;
+ }
+
+ if (_recordMode == kRecorderPlayback) {
+ if (_recordTimeCount > _playbackTimeCount) {
+ d = _playbackTimeFile->readByte();
+ if (d == 0xff) {
+ d = _playbackTimeFile->readUint32LE();
+ }
+ millis = _lastMillis + d;
+ _playbackTimeCount++;
+ }
+ }
+
+ _lastMillis = millis;
+ _boss->unlockMutex(_timeMutex);
+}
+
+bool DefaultEventManager::pollEvent(Common::Event &event) {
+ uint32 time = _boss->getMillis();
+ bool result;
+
+// result = _boss->pollEvent(event);
+
+ if (_recordMode != kPassthrough) {
+
+ _boss->lockMutex(_recorderMutex);
+ _eventCount++;
+
+ if (_recordMode == kRecorderPlayback) {
+ if (event.type != Common::EVENT_QUIT) {
+ result = playback(event);
+ }
+ } else {
+ if (_recordMode == kRecorderRecord) {
+ if (result) {
+ record(event);
+ }
+ }
+ }
+ _boss->unlockMutex(_recorderMutex);
+ }
+
+ if (result) {
+ event.synthetic = false;
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ _modifierState = event.kbd.flags;
+
+ // init continuous event stream
+ // not done on PalmOS because keyboard is emulated and keyup is not generated
+#if !defined(PALMOS_MODE)
+ _currentKeyDown.ascii = event.kbd.ascii;
+ _currentKeyDown.keycode = event.kbd.keycode;
+ _currentKeyDown.flags = event.kbd.flags;
+ _keyRepeatTime = time + kKeyRepeatInitialDelay;
+#endif
+ break;
+ case Common::EVENT_KEYUP:
+ _modifierState = event.kbd.flags;
+ if (event.kbd.keycode == _currentKeyDown.keycode) {
+ // Only stop firing events if it's the current key
+ _currentKeyDown.keycode = 0;
+ }
+ break;
+
+ case Common::EVENT_MOUSEMOVE:
+ _mousePos = event.mouse;
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ _mousePos = event.mouse;
+ _buttonState |= LBUTTON;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _mousePos = event.mouse;
+ _buttonState &= ~LBUTTON;
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ _mousePos = event.mouse;
+ _buttonState |= RBUTTON;
+ break;
+ case Common::EVENT_RBUTTONUP:
+ _mousePos = event.mouse;
+ _buttonState &= ~RBUTTON;
+ break;
+
+ case Common::EVENT_QUIT:
+ _shouldQuit = true;
+ break;
+
+ default:
+ break;
+ }
+ } else {
+ // Check if event should be sent again (keydown)
+ if (_currentKeyDown.keycode != 0 && _keyRepeatTime < time) {
+ // fire event
+ event.type = Common::EVENT_KEYDOWN;
+ event.synthetic = true;
+ event.kbd.ascii = _currentKeyDown.ascii;
+ event.kbd.keycode = (Common::KeyCode)_currentKeyDown.keycode;
+ event.kbd.flags = _currentKeyDown.flags;
+ _keyRepeatTime = time + kKeyRepeatSustainDelay;
+ result = true;
+ }
+ }
+
+ return result;
+}
+
+#endif // !defined(DISABLE_DEFAULT_EVENTMANAGER)
Property changes on: residual/trunk/engine/backend/events/default/default-events.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: residual/trunk/engine/backend/events/default/default-events.h
===================================================================
--- residual/trunk/engine/backend/events/default/default-events.h (rev 0)
+++ residual/trunk/engine/backend/events/default/default-events.h 2008-08-17 07:21:35 UTC (rev 33959)
@@ -0,0 +1,121 @@
+/* Residual - Virtual machine to run LucasArts' 3D adventure games
+ *
+ * Residual is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the AUTHORS
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_DEFAULT_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_DEFAULT_H
+
+#include "common/events.h"
+#include "common/savefile.h"
+
+#include "engine/backend/platform/driver.h"
+
+/*
+At some point we will remove pollEvent from OSystem and change
+DefaultEventManager to use a "boss" derived from this class:
+class EventProvider {
+public
+ virtual bool pollEvent(Common::Event &event) = 0;
+};
+
+Backends which wish to use the DefaultEventManager then simply can
+use a subclass of EventProvider.
+*/
+
+class DefaultEventManager : public Common::EventManager {
+ Driver *_boss;
+
+ Common::Point _mousePos;
+ int _buttonState;
+ int _modifierState;
+ bool _shouldQuit;
+
+ class RandomSourceRecord {
+ public:
+ Common::String name;
+ uint32 seed;
+ };
+ Common::Array<RandomSourceRecord> _randomSourceRecords;
+
+ bool _recordSubtitles;
+ volatile uint32 _recordCount;
+ volatile uint32 _lastRecordEvent;
+ volatile uint32 _recordTimeCount;
+ Common::OutSaveFile *_recordFile;
+ Common::OutSaveFile *_recordTimeFile;
+ Common::MutexRef _timeMutex;
+ Common::MutexRef _recorderMutex;
+ volatile uint32 _lastMillis;
+
+ volatile uint32 _playbackCount;
+ volatile uint32 _playbackDiff;
+ volatile bool _hasPlaybackEvent;
+ volatile uint32 _playbackTimeCount;
+ Common::Event _playbackEvent;
+ Common::InSaveFile *_playbackFile;
+ Common::InSaveFile *_playbackTimeFile;
+
+ volatile uint32 _eventCount;
+ volatile uint32 _lastEventCount;
+
+ enum RecordMode {
+ kPassthrough = 0,
+ kRecorderRecord = 1,
+ kRecorderPlayback = 2
+ };
+ volatile RecordMode _recordMode;
+ Common::String _recordFileName;
+ Common::String _recordTempFileName;
+ Common::String _recordTimeFileName;
+
+ // for continuous events (keyDown)
+ enum {
+ kKeyRepeatInitialDelay = 400,
+ kKeyRepeatSustainDelay = 100
+ };
+
+ struct {
+ uint16 ascii;
+ byte flags;
+ int keycode;
+ } _currentKeyDown;
+ uint32 _keyRepeatTime;
+
+ void record(Common::Event &event);
+ bool playback(Common::Event &event);
+public:
+ DefaultEventManager(Driver *boss);
+ ~DefaultEventManager();
+
+ virtual bool pollEvent(Common::Event &event);
+ virtual void registerRandomSource(Common::RandomSource &rnd, const char *name);
+ virtual void processMillis(uint32 &millis);
+
+ virtual Common::Point getMousePos() const { return _mousePos; }
+ virtual int getButtonState() const { return _buttonState; }
+ virtual int getModifierState() const { return _modifierState; }
+ virtual int shouldQuit() const { return _shouldQuit; }
+};
+
+#endif
Property changes on: residual/trunk/engine/backend/events/default/default-events.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: residual/trunk/engine/backend/module.mk
===================================================================
--- residual/trunk/engine/backend/module.mk 2008-08-17 07:10:36 UTC (rev 33958)
+++ residual/trunk/engine/backend/module.mk 2008-08-17 07:21:35 UTC (rev 33959)
@@ -1,6 +1,7 @@
MODULE := engine/backend
MODULE_OBJS := \
+ events/default/default-events.o \
fs/amigaos4/amigaos4-fs-factory.o \
fs/posix/posix-fs-factory.o \
fs/windows/windows-fs-factory.o \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list