LCOV - code coverage report
Current view: top level - eq/fabric - event.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 8 0.0 %
Date: 2016-09-29 05:02:09 Functions: 0 3 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2006-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2011, Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *                    2012, Daniel Nachbaur <danielnachbaur@gmail.com>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQFABRIC_EVENT_H
      21             : #define EQFABRIC_EVENT_H
      22             : 
      23             : #include <eq/fabric/api.h>
      24             : #include <eq/fabric/types.h>
      25             : #include <eq/fabric/renderContext.h> // member
      26             : #include <eq/fabric/statistic.h>     // member
      27             : 
      28             : 
      29             : namespace eq
      30             : {
      31             : namespace fabric
      32             : {
      33             : 
      34             : /**
      35             :  * Event for a size or position change on a Window, Channel or View.
      36             :  * @version 1.0
      37             :  */
      38             : struct ResizeEvent
      39             : {
      40             :     int32_t x; //!< new X position, relative to parent
      41             :     int32_t y; //!< new Y position, relative to parent
      42             :     int32_t w; //!< new width
      43             :     int32_t h; //!< new height
      44             :     float dw;  //!< view only: new width relative to initial width
      45             :     float dh;  //!< view only: new height relative to initial height
      46             : };
      47             : 
      48             : /** Event for a pointer (mouse) motion or click. @version 1.0 */
      49             : struct PointerEvent
      50             : {
      51             :     int32_t x;        //!< X position relative to entity
      52             :     int32_t y;        //!< Y position relative to entity (0 is on top)
      53             :     int32_t dx;       //!< X position change since last event
      54             :     int32_t dy;       //!< Y position change since last event
      55             :     uint32_t buttons; //!< current state of all buttons
      56             :     uint32_t button;  //!< fired button
      57             :     float xAxis;      //!< x wheel rotation in clicks
      58             :     float yAxis;      //!< y wheel rotation in clicks
      59             : };
      60             : 
      61             : /** Event for a key press or release. @version 1.0 */
      62             : struct KeyEvent
      63             : {
      64             :     uint32_t key; //!<  KeyCode for special keys, ascii code otherwise
      65             :     // TODO modifier state
      66             : };
      67             : 
      68             : /**
      69             :  * Event for a SpaceMouse movement or click.
      70             :  * @warning experimental - may not be supported in the future.
      71             :  */
      72             : struct MagellanEvent
      73             : {
      74             :     uint32_t button;       //!< fired button
      75             :     uint32_t buttons;      //!< current state of all buttons
      76             :     int16_t xAxis;         //!< X translation
      77             :     int16_t yAxis;         //!< Y translation
      78             :     int16_t zAxis;         //!< Z translation
      79             :     int16_t xRotation;     //!< X rotation
      80             :     int16_t yRotation;     //!< Y rotation
      81             :     int16_t zRotation;     //!< Z rotation
      82             : };
      83             : 
      84             : #   define EQ_USER_EVENT_SIZE 128
      85             : /**
      86             :  * User-defined event.
      87             :  *
      88             :  * See the eqPixelBench example on how to use user-defined events.
      89             :  * @version 1.0
      90             :  */
      91             : struct UserEvent
      92             : {
      93             :     char data[ EQ_USER_EVENT_SIZE ]; //!< Application-specific data
      94             : };
      95             : 
      96             : /**
      97             :  * Event structure to report window system and other events.
      98             :  *
      99             :  * Depending on the Event::Type, the corresponding specific event data is filled
     100             :  * into the anonymous union. The originator typically contains the co::Object
     101             :  * identifier of the entity emitting the event. The rendering context is only
     102             :  * set for pointer events.
     103             :  * @version 1.0
     104             :  */
     105           0 : struct Event
     106             : {
     107             :     /** Construct a new event. */
     108             :     EQFABRIC_API Event();
     109             : 
     110             :     /** The type of the event. */
     111             :     enum Type // Also update string table in event.cpp
     112             :     {
     113             :         WINDOW_EXPOSE = 0,    //!< A window is dirty
     114             :         WINDOW_RESIZE,        //!< Window resize data in resize
     115             :         WINDOW_CLOSE,         //!< A window has been closed
     116             :         WINDOW_HIDE,          //!< A window is hidden
     117             :         WINDOW_SHOW,          //!< A window is shown
     118             :         WINDOW_SCREENSAVER,   //!< A window screensaver request (Win32 only)
     119             :         //!< Channel pointer movement data in pointerMotion
     120             :         CHANNEL_POINTER_MOTION,
     121             :         /** Channel pointer button press data in pointerButtonPress */
     122             :         CHANNEL_POINTER_BUTTON_PRESS,
     123             :         /** Channel pointer button release data in pointerButtonRelease */
     124             :         CHANNEL_POINTER_BUTTON_RELEASE,
     125             :         //!< Channel pointer Mouse wheel data in wheel
     126             :         CHANNEL_POINTER_WHEEL,
     127             :         //!< Window pointer Mouse wheel data in wheel
     128             :         WINDOW_POINTER_WHEEL,
     129             :         //!< Window pointer movement data in pointerMotion
     130             :         WINDOW_POINTER_MOTION,
     131             :         /** Window pointer button press data in pointerButtonPress */
     132             :         WINDOW_POINTER_BUTTON_PRESS,
     133             :         /** Window pointer button release data in pointerButtonRelease */
     134             :         WINDOW_POINTER_BUTTON_RELEASE,
     135             :         /** Window pointer grabbed by system window */
     136             :         WINDOW_POINTER_GRAB,
     137             :         /** Window pointer to be released by system window */
     138             :         WINDOW_POINTER_UNGRAB,
     139             : 
     140             :         KEY_PRESS,            //!< Key press data in keyPress
     141             :         KEY_RELEASE,          //!< Key release data in keyRelease
     142             :         CHANNEL_RESIZE,       //!< Channel resize data in resize
     143             :         STATISTIC,            //!< Statistic event in statistic
     144             :         VIEW_RESIZE,          //!< View resize data in resize
     145             :         EXIT,                 //!< Exit request due to runtime error
     146             :         MAGELLAN_AXIS,        //!< SpaceMouse movement data in magellan
     147             :         MAGELLAN_BUTTON,      //!< SpaceMouse button data in magellan
     148             :         NODE_TIMEOUT,         //!< Node has timed out
     149             : 
     150             :         /**
     151             :          * Observer moved (head tracking update). Contains observer originator
     152             :          * identifier and 4x4 float tracking matrix.
     153             :          * @version 1.5.2
     154             :          */
     155             :         OBSERVER_MOTION,
     156             : 
     157             :         /**
     158             :          * Config error event. Contains the originator id, the error code and
     159             :          * 0-n Strings with additional information.
     160             :          * @version 1.7.1
     161             :          */
     162             :         CONFIG_ERROR,
     163             :         NODE_ERROR, //!< Node error event. @sa CONFIG_ERROR
     164             :         PIPE_ERROR, //!< Pipe error event. @sa CONFIG_ERROR
     165             :         WINDOW_ERROR, //!< Window error event. @sa CONFIG_ERROR
     166             :         CHANNEL_ERROR, //!< Channel error event. @sa CONFIG_ERROR
     167             : 
     168             :         UNKNOWN,              //!< Event type not known by the event handler
     169             :         /** User-defined events have to be of this type or higher */
     170             :         USER = UNKNOWN + 5, // some buffer for binary-compatible patches
     171             :         ALL // must be last
     172             :     };
     173             : 
     174             :     uint32_t type;           //!< The event type
     175             : 
     176             :     // keep before 'uint128_t originator' for alignment
     177             :     uint32_t serial;       //!< server-unique originator serial number
     178             : 
     179             :     /** The config time when the event was created. @version 1.1.1 */
     180             :     int64_t time;
     181             : 
     182             :     /** The identifier of the entity emitting the event. */
     183             :     uint128_t originator;
     184             : 
     185             :     /** Data for the event corresponding to the event type. */
     186             :     union
     187             :     {
     188             :         ResizeEvent   resize;             //!< Resize event data
     189             :         ResizeEvent   show;               //!< Window show event data
     190             :         ResizeEvent   hide;               //!< Window hide event data
     191             : 
     192             :         PointerEvent  pointer;            //!< Pointer event data
     193             :         PointerEvent  pointerMotion;      //!< Pointer motion data
     194             :         PointerEvent  pointerButtonPress; //!< Mouse button press data
     195             :         PointerEvent  pointerButtonRelease; //!< Mouse button release data
     196             :         PointerEvent  pointerWheel;       //!< Mouse wheel motion data
     197             : 
     198             :         KeyEvent      key;                //!< Key event data
     199             :         KeyEvent      keyPress;           //!< Key press event data
     200             :         KeyEvent      keyRelease;         //!< Key release event data
     201             : 
     202             :         Statistic     statistic;          //!< Statistic event
     203             :         MagellanEvent magellan;           //!< SpaceMouse data
     204             : 
     205             :         UserEvent     user;               //!< User-defined event data
     206             :     };
     207             : 
     208             :     /** The last rendering context for the pointer position. */
     209             :     RenderContext context;
     210             : };
     211             : 
     212             : /** Print the event to the given output stream. @version 1.0 */
     213             : EQFABRIC_API std::ostream& operator << ( std::ostream&, const Event& );
     214             : /** Print the event type to the given output stream. @version 1.0 */
     215             : EQFABRIC_API std::ostream& operator << ( std::ostream&, const Event::Type& );
     216             : /** Print the resize event to the given output stream. @version 1.0 */
     217             : EQFABRIC_API std::ostream& operator << ( std::ostream&, const ResizeEvent& );
     218             : /** Print the pointer event to the given output stream. @version 1.0 */
     219             : EQFABRIC_API std::ostream& operator << ( std::ostream&, const PointerEvent& );
     220             : /** Print the key event to the given output stream. @version 1.0 */
     221             : EQFABRIC_API std::ostream& operator << ( std::ostream&, const KeyEvent& );
     222             : /** Print the space mouse event to the given output stream. @version 1.0 */
     223             : EQFABRIC_API std::ostream& operator << ( std::ostream&, const MagellanEvent& );
     224             : }
     225             : }
     226             : 
     227             : namespace lunchbox
     228             : {
     229           0 : template<> inline void byteswap( eq::fabric::Event& value )
     230             : {
     231           0 :     byteswap( value.type );
     232           0 :     byteswap( value.serial );
     233           0 :     byteswap( value.time );
     234           0 :     byteswap( value.originator );
     235             :     // #145 Todo byteswap union
     236             :     //byteswap( value.union );
     237           0 :     byteswap( value.context );
     238           0 : }
     239             : }
     240             : 
     241             : #endif // EQFABRIC_EVENT_H

Generated by: LCOV version 1.11