arsa  2.7
IEventReceiver.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_EVENT_RECEIVER_H_INCLUDED__
6 #define __I_EVENT_RECEIVER_H_INCLUDED__
7 
8 #include "ILogger.h"
9 #include "Keycodes.h"
10 #include "irrString.h"
11 
12 namespace irr
13 {
16  {
18 
23 
25 
31 
33 
36 
39 
42 
45 
48 
50 
58 
60 
63 
65 
78 
81 
84 
87  EGUIET_FORCE_32_BIT = 0x7fffffff
88 
89  };
90 
93  {
96 
99 
102 
105 
108 
111 
114 
118 
122 
126 
130 
134 
138 
142 
146 
150 
153  };
154 
157  {
158  EMBSM_LEFT = 0x01,
159  EMBSM_RIGHT = 0x02,
160  EMBSM_MIDDLE = 0x04,
161 
163  EMBSM_EXTRA1 = 0x08,
164 
166  EMBSM_EXTRA2 = 0x10,
167 
168  EMBSM_FORCE_32_BIT = 0x7fffffff
169  };
170 
173  {
176 
179 
182 
185  };
186 
188  {
191 
192  // TODO: for example ESET_WINDOWS_MESSAGE for win32 message loop events
193 
196  };
197 
200  {
203 
206 
209 
212 
215 
218 
221  };
222 
223  namespace gui
224  {
225 
226  class IGUIElement;
227 
230  {
232 
235 
237 
239 
241 
243 
245 
247 
249 
252 
255 
258 
261 
263 
265 
267 
269 
272 
275 
278 
281 
284 
287 
290 
293 
296 
299 
302 
305 
308 
311 
316 
319 
322 
325 
328 
332 
335  };
336  } // end namespace gui
337 
338 
340 struct SEvent
341 {
343  struct SGUIEvent
344  {
347 
350 
353 
354  };
355 
357  struct SMouseInput
358  {
361 
364 
366 
368 
370  bool Shift:1;
371 
373  bool Control:1;
374 
379 
381  bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
382 
384  bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
385 
387  bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
388 
391  };
392 
394  struct SKeyInput
395  {
397  wchar_t Char;
398 
401 
405 
407  bool PressedDown:1;
408 
410  bool Shift:1;
411 
413  bool Control:1;
414  };
415 
417  struct STouchInput
418  {
419  // Touch ID.
420  size_t ID;
421 
422  // X position of simple touch.
424 
425  // Y position of simple touch.
427 
430  };
431 
434  {
435 
436  // X acceleration.
438 
439  // Y acceleration.
441 
442  // Z acceleration.
444  };
445 
448  {
449 
450  // X rotation.
452 
453  // Y rotation.
455 
456  // Z rotation.
458  };
459 
462  {
463 
464  // X angle - roll.
466 
467  // Y angle - pitch.
469 
470  // Z angle - yaw.
472  };
473 
475 
483  {
484  enum
485  {
487 
488  AXIS_X = 0, // e.g. analog stick 1 left to right
489  AXIS_Y, // e.g. analog stick 1 top to bottom
490  AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right
491  AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom
494  NUMBER_OF_AXES=18 // (please tell Irrlicht maintainers if you absolutely need more axes)
495  };
496 
500 
510 
517 
519 
522 
524  bool IsButtonPressed(u32 button) const
525  {
526  if(button >= (u32)NUMBER_OF_BUTTONS)
527  return false;
528 
529  return (ButtonStates & (1 << button)) ? true : false;
530  }
531  };
532 
534  struct SLogEvent
535  {
537  const c8* Text;
538 
541  };
542 
544  struct SUserEvent
545  {
547  size_t UserData1;
548 
550  size_t UserData2;
551  };
552 
553  // Raw events from the OS
555  {
557  struct SAndroidCmd
558  {
561  };
562 
563  // TOOD: more structs for iphone, Windows, X11, etc.
564 
566  union
567  {
569  };
570  };
571 
572  // Application state event
574  {
576  };
577 
579  //union
580  //{
593  //};
594 
595 };
596 
598 
604 {
605 public:
606 
608  virtual ~IEventReceiver() {}
609 
611 
616  virtual bool OnEvent(const SEvent& event) = 0;
617 };
618 
619 
622 {
624 
628 
631 
634 
636 
639 
641 
643  enum
644  {
647 
650 
653  } PovHat;
654 }; // struct SJoystickInfo
655 
656 
657 } // end namespace irr
658 
659 #endif
660 
A checkbox has changed its check state.
s32 Y
Y position of mouse cursor.
size_t UserData2
Another user specified data as int.
The touch changed its position.
bool isMiddlePressed() const
Is the middle button pressed down?
The application will be paused.
signed short s16
16 bit signed variable.
Definition: irrTypes.h:52
From Android command handler for native activity messages.
u32 Axes
The number of axes that the joystick has, i.e. X, Y, Z, R, U, V.
An event of the graphical user interface.
The mouse cursor changed its position.
core::stringc Name
The name that the joystick uses to identify itself.
A key input event.
A file has been selected in the file dialog.
EKEY_CODE
Definition: Keycodes.h:11
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Any kind of keyboard event.
Any kind of gyroscope event.
The application has been resumed.
A hat is definitely present.
EAPPLICATION_EVENT_TYPE EventType
EMOUSE_INPUT_EVENT
Enumeration for all mouse input events.
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
gui::IGUIElement * Element
If the event has something to do with another element, it will be held here.
A scrollbar has changed its position.
Any kind of device motion event.
Right mouse button was left up.
ETOUCH_INPUT_EVENT Event
Type of touch event.
char c8
8 bit character variable.
Definition: irrTypes.h:35
A directory has been selected in the file dialog.
A user event with user data.
ESYSTEM_EVENT_TYPE EventType
EKEY_CODE Key
Key which has been pressed or released.
No real event. Just for convenience to get number of events.
struct SDeviceMotionEvent DeviceMotionEvent
currently only on windows
size_t UserData1
Some user specified data as int.
A mouse input event.
bool isLeftPressed() const
Is the left button pressed down?
struct STouchInput TouchInput
A gui element has got the focus.
EAPPLICATION_EVENT_TYPE
Enumeration for a commonly used application state events (it's useful mainly for mobile devices)
Touch was left up.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
An item in the listbox was selected, which was already selected.
A new item in a listbox was selected.
A file open dialog has been closed without choosing a file.
gui::EGUI_EVENT_TYPE EventType
Type of GUI Event.
bool isRightPressed() const
Is the right button pressed down?
wchar_t Char
Character corresponding to the key (0, if not a character, value undefined in key releases)
const c8 * Text
Pointer to text which has been logged.
A tree view node was selected. See IGUITreeView::getLastEventNode().
struct SAccelerometerEvent AccelerometerEvent
The text in an editbox was changed. This does not include automatic changes in text-breaking.
Very simple string class with some useful features.
Definition: irrString.h:37
A gyroscope event.
double f64
64 bit floating point variable.
Definition: irrTypes.h:112
u8 Joystick
The ID of the joystick.
unsigned char u8
8 bit unsigned variable.
Definition: irrTypes.h:22
s32 Cmd
APP_CMD_ enums defined in android_native_app_glue.h from the Android NDK.
No real event, but to get number of event types.
Middle mouse button was left up.
The marked area in an editbox was changed.
A joystick (joypad, gamepad) input event.
virtual ~IEventReceiver()
Destructor.
struct SJoystickEvent JoystickEvent
The value of a spin box has changed.
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
Any kind of touch event.
ETOUCH_INPUT_EVENT
Enumeration for all touch input events.
ELOG_LEVEL Level
Log level in which the text has been logged.
Interface of an object which can receive events.
'Yes' was clicked on a messagebox
bool Shift
True if shift was also pressed.
Right mouse button was pressed down.
No real event, but to get number of event types.
u32 Buttons
The number of buttons that the joystick has.
Information on a joystick, returned from irr::IrrlichtDevice::activateJoysticks()
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
gui::IGUIElement * Caller
IGUIElement who called the event.
currently only on windows
In an editbox 'ENTER' was pressed.
bool Control
True if ctrl was also pressed.
u8 Joystick
The ID of the joystick which generated this event.
The application received a memory warning.
struct _cl_event * event
f32 Wheel
mouse wheel delta, often 1.0 or -1.0, but can have other values < 0.f or > 0.f;
The mouse cursor hovered over a gui element.
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
Pass on raw events from the OS.
'OK' was clicked on a messagebox
EEVENT_TYPE EventType
The application will be terminated.
struct SSystemEvent SystemEvent
bool Control
True if ctrl was also pressed.
Left mouse button was pressed down.
A gui element has lost its focus.
EEVENT_TYPE
Enumeration for all event types there are.
struct SAndroidCmd AndroidCmd
ELOG_LEVEL
Definition: ILogger.h:17
Base class of all GUI elements.
Definition: IGUIElement.h:23
EGUI_EVENT_TYPE
Enumeration for all events which are sendable by the gui system.
A tree view node was collapsed. See IGUITreeView::getLastEventNode().
A tree view node was expanded. See IGUITreeView::getLastEventNode().
The tab was changed in an tab control.
struct SGUIEvent GUIEvent
bool IsButtonPressed(u32 button) const
A helper function to check if a button is pressed.
Any kind of user event.
Any kind of accelerometer event.
struct SMouseInput MouseInput
E_MOUSE_BUTTON_STATE_MASK
Masks for mouse button states.
The mouse cursor left the hovered element.
enum irr::SJoystickInfo::@4 PovHat
An indication of whether the joystick has a POV hat.
'No' was clicked on a messagebox
ESYSTEM_EVENT_TYPE
struct SApplicationEvent ApplicationEvent
EMOUSE_INPUT_EVENT Event
Type of mouse event.
A device motion event.
bool Shift
True if shift was also pressed.
struct SUserEvent UserEvent
A button was clicked.
The presence or absence of a hat cannot be determined.
Application state events like a resume, pause etc.
virtual bool OnEvent(const SEvent &event)=0
Called if an event happened.
Middle mouse button was pressed down.
The application will be resumed.
The selection in a combo box has been changed.
Android command handler native activity messages.
A touch input event.
struct SGyroscopeEvent GyroscopeEvent
Touch was pressed down.
No real event. Just for convenience to get number of events.
A table has changed.
struct SLogEvent LogEvent
A hat is definitely not present.
struct SKeyInput KeyInput
A menu item was selected in a (context) menu.
No real event. Just for convenience to get number of events.
Left mouse button was left up.
Any kind of mouse event.
A accelerometer event.
A tree view node lost selection. See IGUITreeView::getLastEventNode().
'Cancel' was clicked on a messagebox
The application has been paused.
s16 Axis[NUMBER_OF_AXES]
Any kind of GUI event.
An element would like to close.
s32 X
X position of mouse cursor.
Any kind of log event.
bool PressedDown
If not true, then the key was left up.