AnnEvents.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "systemMacro.h"
4 #include "AnnUserSpaceEvent.hpp"
5 #include "AnnKeyCode.h"
6 #include "AnnHandController.hpp"
7 
8 namespace Annwvyn
9 {
10  class AnnTimer;
11  class AnnTriggerObject;
12  class AnnPlayerBody;
13 
14  enum AnnEventType {
22  };
25  {
26  public:
28  AnnEvent();
29  AnnEventType getType() const;
30 
31  protected:
33  friend class AnnEventManager;
34  };
35 
38  {
40  AnnKeyEvent();
41 
42  public:
44  KeyCode::code getKey() const;
46  bool isPressed() const;
48  bool isReleased() const;
50  bool shouldIgnore() const;
51 
52  private:
53  friend class AnnEventManager;
57  bool pressed;
59  bool ignored;
61  void setPressed();
63  void setReleased();
66  void setCode(KeyCode::code c);
67  };
68 
70  enum MouseAxisID { X,
71  Y,
72  Z,
75 
87 
90  {
91  public:
93  AnnMouseAxis();
95  MouseAxisID getMouseAxisId() const;
97  int getRelValue() const;
99  int getAbsValue() const;
100 
101  private:
103  friend class AnnEventManager;
105  friend class AnnMouseEvent;
109  int rel;
111  int abs;
112 
114  void setAxis(MouseAxisID ax);
116  void setRelValue(int rel);
118  void setAbsValue(int abs);
120  AnnMouseAxis(MouseAxisID ax, int rel, int abs);
121  };
122 
125  {
126  public:
127  AnnMouseEvent();
130  bool getButtonState(MouseButtonId id);
131 
134  AnnMouseAxis getAxis(MouseAxisID id);
135 
136  private:
138  bool buttonsStatus[ButtonCount];
139 
140  friend class AnnEventManager;
141 
145  void setButtonStatus(MouseButtonId id, bool value);
146 
150  void setAxisInformation(MouseAxisID id, AnnMouseAxis information);
151  };
152 
154  using ButtonId = int;
155  using ControllerAxisID = int;
156  using PovId = int;
157  using ControllerID = int;
158 
159  static constexpr ControllerAxisID InvalidStickAxisId = -1;
160  static constexpr float INVALID = 42.0f;
161 
164  {
165  public:
169  ControllerAxisID getAxisId() const;
171  float getRelValue() const;
173  float getAbsValue() const;
174 
175  private:
176  friend class AnnEventManager;
177  friend class AnnControllerEvent;
178 
180  int a, r;
183  void setAxis(ControllerAxisID ax);
185  void setRelValue(int rel);
187  void setAbsValue(int abs);
189  AnnControllerAxis(ControllerAxisID ax, int rel, int abs);
191  bool noRel;
192  };
193 
196  {
197  public:
200 
202  bool getNorth() const;
204  bool getSouth() const;
206  bool getEast() const;
208  bool getWest() const;
209 
211  bool getNorthEast() const;
213  bool getSouthEast() const;
215  bool getNorthWest() const;
217  bool getSouthWest() const;
218 
220  bool isCentred() const;
221 
222  private:
224  bool north;
226  bool south;
228  bool east;
230  bool west;
231 
232  friend class AnnEventManager;
233  friend class AnnControllerEvent;
234 
236  AnnControllerPov(unsigned int binaryDirection);
237  };
238 
241  {
242  public:
247 
249  size_t getNbButtons() const;
250 
252  std::vector<unsigned short> getPressed() const;
254  std::vector<unsigned short> getReleased() const;
255 
257  bool isPressed(ButtonId id);
259  bool isReleased(ButtonId id);
261  bool isDown(ButtonId id);
265  size_t getAxisCount() const;
267  ControllerID getControllerID() const;
269  std::string getVendor() const;
271  size_t getPovCount() const;
273  AnnControllerPov getPov(PovId pov);
274 
276  bool isXboxController() const;
277 
278  private:
280  bool xbox;
281  friend class AnnEventManager;
295  int stickID;
296  };
297  class AnnHandController;
298 
301  {
302  public:
306  AnnVect3 getPosition() const;
308  AnnQuaternion getOrientation() const;
310  AnnVect3 getPointingDirection() const;
312  AnnVect3 getLinearSpeed() const;
314  AnnVect3 getAngularSpeed() const;
316  AnnHandControllerAxis& getAxis(uint8_t id) const;
318  size_t getAxisCount() const;
320  size_t getButtonCount() const;
322  bool buttonPressed(uint8_t id) const;
324  bool buttonReleased(uint8_t id) const;
326  bool buttonState(uint8_t id) const;
332  AnnHandController* _getController() const;
333 
334  private:
335  friend class AnnEventManager;
337  };
338 
339  using AnnTimerID = int;
340 
343  {
344  public:
346  AnnTimeEvent();
347  AnnTimeEvent(const AnnTimer& timer);
349  AnnTimerID getID() const;
350 
351  private:
352  friend class AnnEventManager;
354  void setTimerID(AnnTimerID id);
357  };
358 
359  class AnnGameObject;
360 
363  {
364  public:
366  AnnCollisionEvent(AnnGameObject* first, AnnGameObject* second, AnnVect3 position, AnnVect3 normal);
368  bool hasObject(AnnGameObject* obj) const;
370  AnnGameObject* getA() const;
372  AnnGameObject* getB() const;
374  AnnVect3 getPosition() const;
376  AnnVect3 getNormal() const;
377 
380  bool isWallCollision(float scalarApprox = 0.0125) const;
383  bool isGroundCollision(float scalarApprox = 0.125) const;
386  bool isCeilingCollision(float scalarApprox = 0.125) const;
387 
388  private:
391  const AnnVect3 position, normal;
392  };
393 
396  {
397  public:
401  AnnGameObject* getObject() const;
402 
403  private:
406  };
407 
410  {
411  public:
413  AnnTriggerEvent();
415  bool getContactStatus() const;
417  AnnTriggerObject* getSender() const;
418 
419  private:
420  friend class AnnEventManager;
421  bool contact;
423  };
424 
427  {
428  public:
429  AnnTimerID getID() const;
430 
431  private:
432  friend class AnnEventManager;
434  AnnTimer(AnnTimerID id, double delay);
436  bool isTimeout() const;
440  double timeoutTime;
441  };
442 
445  {
446  public:
447  friend class AnnEventManager;
450  AnnControllerBuffer(OIS::JoyStick* joystick);
452  AnnControllerBuffer(const AnnControllerBuffer&) = delete;
454  AnnControllerBuffer& operator=(const AnnControllerBuffer&) = delete;
456  AnnControllerBuffer(AnnControllerBuffer&& buffer) = default;
458  AnnControllerBuffer& operator=(AnnControllerBuffer&& buffer) = default;
461 
462  void capture() const;
463 
464  private:
466  OIS::JoyStick* oisJoystick;
470  unsigned int getID() const { return id; }
472  unsigned int id;
474  static unsigned int idcounter;
475  };
476 }
int rel
Relative value.
Definition: AnnEvents.hpp:109
file for defining macros used for symbol export regarding the way the OS does things.
Collision between the player and another object.
Definition: AnnEvents.hpp:395
Internal utility class that store joystick information. RAII the oisJoystick object given to construc...
Definition: AnnEvents.hpp:444
MouseAxisID
Name and number of axes.
Definition: AnnEvents.hpp:70
static constexpr float INVALID
Definition: AnnEvents.hpp:160
int AnnTimerID
Definition: AnnEvents.hpp:339
A mouse axis information object.
Definition: AnnEvents.hpp:89
bool ignored
Keyboard event that should be ignored has this flag as "true".
Definition: AnnEvents.hpp:59
std::vector< AnnControllerAxis > axes
Axis array.
Definition: AnnEvents.hpp:285
A 3D Vector.
Definition: AnnVect3.hpp:16
unsigned int id
The ID.
Definition: AnnEvents.hpp:472
Object for representing a volume that trigger an event.
AnnTimerID tID
Timeout ID.
Definition: AnnEvents.hpp:438
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
Translation of OIS keys code to Annwvyn KeyCode.
A joystick event.
Definition: AnnEvents.hpp:240
int PovId
Definition: AnnEvents.hpp:156
AnnTimerID tID
Timer ID.
Definition: AnnEvents.hpp:356
An object that exist in the game. Graphically and Potentially Physically.
A timer timeout event.
Definition: AnnEvents.hpp:342
Represent the axis of an hand controller.
bool xbox
set to true if this is an Xbox controller (We&#39;re not using Xinput tho)
Definition: AnnEvents.hpp:280
std::vector< unsigned short > released
Released event "queue".
Definition: AnnEvents.hpp:291
std::vector< AnnControllerPov > povs
Pov Array.
Definition: AnnEvents.hpp:287
unsigned int getID() const
Get the ID if this stick.
Definition: AnnEvents.hpp:470
std::string vendor
Joystick "vendor" name (generally the brand and model)
Definition: AnnEvents.hpp:293
AnnHandControllerSide
Identify the controller as "left hand", "right hand" or "invalid hand".
KeyCode::code key
Code of the key this event relate to.
Definition: AnnEvents.hpp:55
int ControllerAxisID
Definition: AnnEvents.hpp:155
int abs
Absolute value (if applicable)
Definition: AnnEvents.hpp:111
A hand controller event.
Definition: AnnEvents.hpp:300
std::vector< byte > buttons
Button array.
Definition: AnnEvents.hpp:283
int ControllerID
Definition: AnnEvents.hpp:157
Represent a Quaternion.
AnnTriggerObject * sender
Definition: AnnEvents.hpp:422
size_t AnnHandControllerTypeHash
Hash of a string idientifier.
Represent an hand controller tracked by the VR system and that the user is actively using...
MouseButtonId
Name and number of mouse button.
Definition: AnnEvents.hpp:77
int ButtonId
A joystick event.
Definition: AnnEvents.hpp:154
OIS::JoyStick * oisJoystick
Joystick object from OIS. Deleted by constructor.
Definition: AnnEvents.hpp:466
Represent a pad&#39;s POV controller.
Definition: AnnEvents.hpp:195
AnnEventType type
Definition: AnnEvents.hpp:32
A keyboard event.
Definition: AnnEvents.hpp:37
MouseAxisID id
ID of the axis.
Definition: AnnEvents.hpp:107
static constexpr ControllerAxisID InvalidStickAxisId
Definition: AnnEvents.hpp:159
int stickID
Joystick ID for the engine.
Definition: AnnEvents.hpp:295
Internal utility class that represent a timer.
Definition: AnnEvents.hpp:426
#define AnnDllExport
Definition: systemMacro.h:24
An input event.
Definition: AnnEvents.hpp:24
AnnGameObject * col
Naked pointer to the collider.
Definition: AnnEvents.hpp:405
A mouse event information object.
Definition: AnnEvents.hpp:124
std::vector< byte > previousStickButtonStates
Array of "bool" for previous buttons.
Definition: AnnEvents.hpp:468
bool noRel
True if the there&#39;s no "relative" value.
Definition: AnnEvents.hpp:191
double timeoutTime
Time of timeout.
Definition: AnnEvents.hpp:440
A joystick axis.
Definition: AnnEvents.hpp:163
Trigger in/out event.
Definition: AnnEvents.hpp:409
std::vector< unsigned short > pressed
Pressed event "queue".
Definition: AnnEvents.hpp:289
bool pressed
Pressed state.
Definition: AnnEvents.hpp:57
static unsigned int idcounter
The counter.
Definition: AnnEvents.hpp:474
Collision event between 2 game objects.
Definition: AnnEvents.hpp:362
AnnHandController * controller
Definition: AnnEvents.hpp:336
Event Manager : Object that handle the event system.