## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# csutil/event.h

Go to the documentation of this file.

    00001 /*
    00002     Event system related helpers
    00003     Copyright (C) 2003 by Jorrit Tyberghein
    00004               (C) 2003 by Frank Richter
    00005               (C) 2005 by Adam D. Bradley <artdodge@cs.bu.edu>
    00006
    00007     This library is free software; you can redistribute it and/or
    00008     modify it under the terms of the GNU Library General Public
    00009     License as published by the Free Software Foundation; either
    00010     version 2 of the License, or (at your option) any later version.
    00011
    00012     This library is distributed in the hope that it will be useful,
    00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015     Library General Public License for more details.
    00016
    00017     You should have received a copy of the GNU Library General Public
    00018     License along with this library; if not, write to the Free
    00019     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00020 */
    00021
    00022 #ifndef __CS_CSUTIL_EVENT_H__
    00023 #define __CS_CSUTIL_EVENT_H__
    00024
    00025 #include "csextern.h"
    00026 #include "iutil/event.h"
    00027
    00040 class CS_CRYSTALSPACE_EXPORT csKeyEventHelper
    00041 {
    00042 public:
    00044   CS_PURE_METHOD static utf32_char GetRawCode (const iEvent* event);
    00046   CS_PURE_METHOD static utf32_char GetCookedCode (const iEvent* event);
    00048   static void GetModifiers (const iEvent* event, csKeyModifiers& modifiers);
    00050   CS_PURE_METHOD static csKeyEventType GetEventType (const iEvent* event);
    00055   CS_PURE_METHOD static bool GetAutoRepeat (const iEvent* event);
    00057   CS_PURE_METHOD static csKeyCharType GetCharacterType (const iEvent* event);
    00059   static bool GetEventData (const iEvent* event, csKeyEventData& data);
    00065   CS_CONST_METHOD static uint32 GetModifiersBits (
    00066     const csKeyModifiers& modifiers);
    00071   CS_PURE_METHOD static uint32 GetModifiersBits (const iEvent* event);
    00079   static void GetModifiers (uint32 mask, csKeyModifiers& modifiers);
    00080 };
    00083 /* forward declaration */
    00084 class csEvent;
    00085
    00091 class CS_CRYSTALSPACE_EXPORT csMouseEventHelper
    00092 {
    00093 public:
    00095
    00096   static csEvent *NewEvent (csRef<iEventNameRegistry> &reg,
    00097     csTicks, csEventID name, csMouseEventType etype, int x, int y,
    00098     uint32 AxesChanged, uint button, bool buttonstate, uint32 buttonMask,
    00099     uint32 modifiers);
    00100   static csEvent *NewEvent (csRef<iEventNameRegistry> &reg, csTicks,
    00101     csEventID name, uint8 n, csMouseEventType etype, int x, int y,
    00102     uint32 axesChanged, uint button, bool buttonstate, uint32 buttonMask,
    00103     uint32 modifiers);
    00104   static csEvent *NewEvent (csRef<iEventNameRegistry> &reg, csTicks,
    00105     csEventID name, uint8 n, csMouseEventType etype, const int32 *axes,
    00106     uint8 numAxes, uint32 axesChanged, uint button, bool buttonstate,
    00107     uint32 buttonMask, uint32 modifiers);
    00109
    00111   CS_PURE_METHOD static csMouseEventType GetEventType (const iEvent* event);
    00113   CS_PURE_METHOD static uint GetNumber(const iEvent *event);
    00115   CS_PURE_METHOD static int GetX(const iEvent *event)
    00116   { return csMouseEventHelper::GetAxis(event, 0); }
    00118   CS_PURE_METHOD static int GetY(const iEvent *event)
    00119   { return csMouseEventHelper::GetAxis(event, 1); }
    00121   CS_PURE_METHOD static int GetAxis(const iEvent *event, uint axis);
    00123   CS_PURE_METHOD static uint GetNumAxes(const iEvent *event);
    00125   CS_PURE_METHOD static uint GetButton(const iEvent *event);
    00127   CS_PURE_METHOD static bool GetButtonState(const iEvent *event);
    00129   CS_PURE_METHOD static uint32 GetButtonMask(const iEvent *event);
    00131   CS_PURE_METHOD static void GetModifiers(const iEvent *event,
    00132     csKeyModifiers& modifiers)
    00133   { csKeyEventHelper::GetModifiers(event, modifiers); }
    00135   CS_PURE_METHOD static uint32 GetModifiers(const iEvent *event)
    00136   {
    00137     csKeyModifiers modifiers;
    00138     csKeyEventHelper::GetModifiers(event, modifiers);
    00139     return csKeyEventHelper::GetModifiersBits(modifiers);
    00140   }
    00142   CS_PURE_METHOD static bool GetEventData (const iEvent* event,
    00143     csMouseEventData& data);
    00144 };
    00145
    00153 class CS_CRYSTALSPACE_EXPORT csJoystickEventHelper
    00154 {
    00155 public:
    00157
    00158   static csEvent *NewEvent (csRef<iEventNameRegistry> &reg, csTicks,
    00159     csEventID name, int n, int x, int y, uint32 axesChanged, uint button,
    00160     bool buttonState, uint32 buttonMask, uint32 modifiers);
    00161   static csEvent *NewEvent (csRef<iEventNameRegistry> &reg, csTicks,
    00162     csEventID name, int n, const int32* axes, uint8 numAxes, uint32 axesChanged,
    00163     uint button, bool buttonState, uint32 buttonMask, uint32 modifiers);
    00165
    00167   CS_PURE_METHOD static uint GetNumber(const iEvent *event);
    00169   CS_PURE_METHOD CS_DEPRECATED_METHOD static int GetX(const iEvent *event)
    00170   { return csJoystickEventHelper::GetAxis(event, 0); }
    00172   CS_PURE_METHOD CS_DEPRECATED_METHOD static int GetY(const iEvent *event)
    00173   { return csJoystickEventHelper::GetAxis(event, 1); }
    00175   CS_PURE_METHOD static int GetAxis(const iEvent *event, uint);
    00177   CS_PURE_METHOD static uint GetNumAxes(const iEvent *);
    00179   CS_PURE_METHOD static uint GetButton(const iEvent *event);
    00181   CS_PURE_METHOD static bool GetButtonState(const iEvent *event);
    00183   CS_PURE_METHOD static uint32 GetButtonMask(const iEvent *event);
    00185   static void GetModifiers(const iEvent *event, csKeyModifiers& modifiers)
    00186   { csKeyEventHelper::GetModifiers(event, modifiers); }
    00188   CS_PURE_METHOD static uint32 GetModifiers(const iEvent *event)
    00189   {
    00190     csKeyModifiers modifiers;
    00191     csKeyEventHelper::GetModifiers(event, modifiers);
    00192     return csKeyEventHelper::GetModifiersBits(modifiers);
    00193   }
    00195   static bool GetEventData (const iEvent* event, csJoystickEventData& data);
    00196 };
    00197
    00205 class CS_CRYSTALSPACE_EXPORT csInputEventHelper
    00206 {
    00207 public:
    00209   CS_PURE_METHOD static uint GetButton (iEventNameRegistry *,
    00210         const iEvent *event);
    00212   CS_PURE_METHOD static bool GetButtonState (iEventNameRegistry *,
    00213         const iEvent *event);
    00214 };
    00215
    00223 class CS_CRYSTALSPACE_EXPORT csCommandEventHelper
    00224 {
    00225 public:
    00227   static csEvent *NewEvent (csTicks, csEventID name, bool Broadcast,
    00228     intptr_t info = 0);
    00229
    00231   CS_PURE_METHOD static uint GetCode(const iEvent *event);
    00233   CS_PURE_METHOD static intptr_t GetInfo(const iEvent *event);
    00235   static bool GetEventData (const iEvent* event, csCommandEventData& data);
    00236 };
    00237
    00242 #endif // __CS_CSUTIL_EVENT_H__