summaryrefslogtreecommitdiffstats
path: root/src/common/event.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-19 22:53:06 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-19 22:53:06 +0200
commit7479f486b671acb2a6aea2c84a56b383aaba00ca (patch)
tree4043545a14234dfaa2d7d08d59c7ee9ee97f0de9 /src/common/event.h
parent901f10b2bac18a2063cd21798f22b3917e8519b5 (diff)
parent57d33d79ea570773d84ad81d4a61f50e079979ef (diff)
downloadcolobot-7479f486b671acb2a6aea2c84a56b383aaba00ca.tar.gz
colobot-7479f486b671acb2a6aea2c84a56b383aaba00ca.tar.bz2
colobot-7479f486b671acb2a6aea2c84a56b383aaba00ca.zip
Forgotten fix in dev-graphics
Diffstat (limited to 'src/common/event.h')
-rw-r--r--src/common/event.h196
1 files changed, 98 insertions, 98 deletions
diff --git a/src/common/event.h b/src/common/event.h
index 3192931..378960c 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -14,23 +14,26 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// event.h
+/**
+ * \file common/event.h
+ * \brief Event types, structs and event queue
+ */
#pragma once
-#include <common/key.h>
-#include <common/event_ids.h>
-#include <math/point.h>
-
-#include <string.h>
-
+#include "common/key.h"
+#include "common/event_ids.h"
+#include "math/point.h"
+#include "math/vector.h"
class CInstanceManager;
-/** \enum PressState
- \brief State of key/mouse button */
+/**
+ * \enum PressState
+ * \brief State of key/mouse button
+ */
enum PressState
{
STATE_PRESSED,
@@ -38,21 +41,22 @@ enum PressState
};
-/** \struct KeyEventData
- \brief Additional data for keyboard event */
+/**
+ * \struct KeyEventData
+ * \brief Additional data for keyboard event
+ */
struct KeyEventData
{
//! STATE_PRESSED or STATE_RELEASED */
PressState state;
- //! Key symbol: KEY(...) macro value (from common/key.h)
+ //! If true, the key is a virtual code generated by key modifier press or joystick button press
+ bool virt;
+ //! Key symbol: KEY(...) macro value or virtual key VIRTUAL_... (from common/key.h)
unsigned int key;
//! Keyboard modifiers: a bitmask made of KEY_MOD(...) macro values (from common/key.h)
unsigned int mod;
//! Unicode character
unsigned int unicode;
-
- KeyEventData()
- : state(STATE_PRESSED), key(0), mod(0), unicode(0) {}
};
/** \struct MouseMotionEventData
@@ -60,16 +64,15 @@ struct KeyEventData
struct MouseMoveEventData
{
//! Current button state
- unsigned char state;
+ PressState state;
//! Position of mouse in normalized coordinates (0..1)
Math::Point pos;
-
- MouseMoveEventData()
- : state(STATE_PRESSED) {}
};
-/** \struct MouseButtonEventData
- \brief Additional data mouse button event */
+/**
+ * \struct MouseButtonEventData
+ * \brief Additional data mouse button event
+ */
struct MouseButtonEventData
{
//! The mouse button index
@@ -78,39 +81,58 @@ struct MouseButtonEventData
PressState state;
//! Position of mouse in normalized coordinates (0..1)
Math::Point pos;
+};
+
+/**
+ * \enum WheelDirection
+ * \brief Direction of mouse wheel movement
+ */
+enum WheelDirection
+{
+ WHEEL_UP,
+ WHEEL_DOWN
+};
- MouseButtonEventData()
- : button(0), state(STATE_PRESSED) {}
+/**
+ * \enum MouseWheelEventData
+ * \brief Additional data for mouse wheel event.
+ */
+struct MouseWheelEventData
+{
+ //! Wheel direction
+ WheelDirection dir;
+ //! Position of mouse in normalized coordinates (0..1)
+ Math::Point pos;
};
-/** \struct JoyAxisEventData
- \brief Additional data for joystick axis event */
+/**
+ * \struct JoyAxisEventData
+ * \brief Additional data for joystick axis event
+ */
struct JoyAxisEventData
{
//! The joystick axis index
unsigned char axis;
//! The axis value (range: -32768 to 32767)
int value;
-
- JoyAxisEventData()
- : axis(axis), value(value) {}
};
-/** \struct JoyButtonEventData
- \brief Additional data for joystick button event */
+/**
+ * \struct JoyButtonEventData
+ * \brief Additional data for joystick button event
+ */
struct JoyButtonEventData
{
//! The joystick button index
unsigned char button;
//! STATE_PRESSED or STATE_RELEASED
PressState state;
-
- JoyButtonEventData()
- : button(0), state(STATE_PRESSED) {}
};
-/** \enum ActiveEventFlags
- \brief Type of focus gained/lost */
+/**
+ * \enum ActiveEventFlags
+ * \brief Type of focus gained/lost
+ */
enum ActiveEventFlags
{
//! Application window focus
@@ -122,30 +144,29 @@ enum ActiveEventFlags
};
-/** \struct ActiveEventData
- \brief Additional data for active event */
+/**
+ * \struct ActiveEventData
+ * \brief Additional data for active event
+ */
struct ActiveEventData
{
//! Flags (bitmask of enum values ActiveEventFlags)
unsigned char flags;
//! True if the focus was gained; false otherwise
bool gain;
-
- ActiveEventData()
- : flags(0), gain(false) {}
};
/**
- \struct Event
- \brief Event sent by system, interface or game
-
- Event is described by its type (EventType) and the union
- \a data contains additional data about the event.
- Different members of the union are filled with different event types.
- With some events, nothing is filled (it's zeroed out).
- The union contains roughly the same information as SDL_Event struct
- but packaged to independent structs and fields.
+ * \struct Event
+ * \brief Event sent by system, interface or game
+ *
+ * Event is described by its type (EventType) and the union
+ * \a data contains additional data about the event.
+ * Different members of the union are filled with different event types.
+ * With some events, nothing is filled (it's zeroed out).
+ * The union contains roughly the same information as SDL_Event struct
+ * but packaged to independent structs and fields.
**/
struct Event
{
@@ -163,6 +184,8 @@ struct Event
MouseButtonEventData mouseButton;
//! Additional data for EVENT_MOUSE_MOVE
MouseMoveEventData mouseMove;
+ //! Additional data for EVENT_MOUSE_WHEEL
+ MouseWheelEventData mouseWheel;
//! Additional data for EVENT_JOY
JoyAxisEventData joyAxis;
//! Additional data for EVENT_JOY_AXIS
@@ -171,70 +194,49 @@ struct Event
ActiveEventData active;
};
- // TODO: refactor/rewrite
+ //! State of tracked keys (mask of TrackedKey enum values)
+ unsigned int trackedKeys;
+
+ //! Mouse position is provided also for other types of events besides mouse events
+ Math::Point mousePos;
+
+ //! Motion vector set by keyboard or joystick
+ Math::Vector motionInput;
+
+ // TODO: remove and replace references with trackedKeys
+ short keyState;
+
+ // TODO: remove and replace references with mousePos
+ Math::Point pos;
+
+ // TODO: remove
long param; // parameter
- Math::Point pos; // mouse position (0 .. 1)
- float axeX; // control the X axis (-1 .. 1)
- float axeY; // control of the Y axis (-1 .. 1)
- float axeZ; // control the Z axis (-1 .. 1)
- short keyState; // state of the keyboard (KS_ *)
+
+ // TODO: remove in longer term (use CApplication's new time functions instead)
float rTime; // relative time
Event(EventType aType = EVENT_NULL)
{
type = aType;
systemEvent = false;
+ trackedKeys = 0;
param = 0;
- axeX = axeY = axeZ = 0.0f;
- keyState = 0;
rTime = 0.0f;
}
};
-/**
- \enum KeyRank
- \brief Slots for key assignment of user controls
- */
-
-// TODO: move to global.h ?
-
-enum KeyRank
-{
- KEYRANK_LEFT = 0,
- KEYRANK_RIGHT = 1,
- KEYRANK_UP = 2,
- KEYRANK_DOWN = 3,
- KEYRANK_GUP = 4,
- KEYRANK_GDOWN = 5,
- KEYRANK_CAMERA = 6,
- KEYRANK_DESEL = 7,
- KEYRANK_ACTION = 8,
- KEYRANK_NEAR = 9,
- KEYRANK_AWAY = 10,
- KEYRANK_NEXT = 11,
- KEYRANK_HUMAN = 12,
- KEYRANK_QUIT = 13,
- KEYRANK_HELP = 14,
- KEYRANK_PROG = 15,
- KEYRANK_VISIT = 16,
- KEYRANK_SPEED10 = 17,
- KEYRANK_SPEED15 = 18,
- KEYRANK_SPEED20 = 19,
- KEYRANK_SPEED30 = 20,
- KEYRANK_AIMUP = 21,
- KEYRANK_AIMDOWN = 22,
- KEYRANK_CBOT = 23,
-};
+//! Returns an unique event type (above the standard IDs)
+EventType GetUniqueEventType();
/**
- \class CEventQueue
- \brief Global event queue
-
- Provides an interface to a global FIFO queue with events (both system- and user-generated).
- The queue has a fixed maximum size but it should not be a problem.
+ * \class CEventQueue
+ * \brief Global event queue
+ *
+ * Provides an interface to a global FIFO queue with events (both system- and user-generated).
+ * The queue has a fixed maximum size but it should not be a problem.
*/
class CEventQueue
{
@@ -261,5 +263,3 @@ protected:
int m_tail;
int m_total;
};
-
-