Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
IEventReceiver.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef NIRT_I_EVENT_RECEIVER_HPP_INCLUDED
6#define NIRT_I_EVENT_RECEIVER_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/ILogger.hpp>
9#include <nirtcpp/core/engine/Keycodes.hpp>
10#include <nirtcpp/core/engine/irrString.hpp>
11
12namespace nirt
13{
75
131
134 {
135 EMBSM_LEFT = 0x01,
136 EMBSM_RIGHT = 0x02,
137 EMBSM_MIDDLE = 0x04,
138
141
144
145 EMBSM_FORCE_32_BIT = 0x7fffffff
146 };
147
163
164 namespace gui
165 {
166
167 class IGUIElement;
168
277 } // end namespace gui
278
279
282{
283public:
298
299public:
302 {
303 public:
304 // Touch ID.
305 size_t ID;
306
307 // X position of simple touch.
308 s32 X;
309
310 // Y position of simple touch.
311 s32 Y;
312
315 };
316
317public:
320 {
321 public:
324
327
329
331
333 bool Shift:1;
334
336 bool Control:1;
337
342
344 bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
345
347 bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
348
350 bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
351
354 };
355
356public:
359 {
360 public:
362 wchar_t Char;
363
365 EKEY_CODE Key;
366
369
371 bool Shift:1;
372
374 bool Control:1;
375 };
376
377public:
379
387 {
388 public:
389 enum
390 {
391 NUMBER_OF_BUTTONS = 32,
392
393 AXIS_X = 0, // e.g. analog stick 1 left to right
394 AXIS_Y, // e.g. analog stick 1 top to bottom
395 AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right
396 AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom
397 AXIS_U,
398 AXIS_V,
399 NUMBER_OF_AXES=18 // (please tell Nirtcpp maintainers if you absolutely need more axes)
400 };
401
405
414 s16 Axis[NUMBER_OF_AXES];
415
422
424
427
429 bool IsButtonPressed(u32 button) const
430 {
431 if(button >= (u32)NUMBER_OF_BUTTONS)
432 return false;
433
434 return (ButtonStates & (1 << button)) ? true : false;
435 }
436 };
437
438public:
441 {
442 public:
444 const c8* Text;
445
448 };
449
450public:
453 {
454 public:
456 size_t UserData1;
457
459 size_t UserData2;
460 };
461
462public:
463 EEVENT_TYPE EventType;
464 union
465 {
466 class SGUIEvent GUIEvent;
467 class SMouseInput MouseInput;
468 class SKeyInput KeyInput;
469 class STouchInput TouchInput;
470 class SJoystickEvent JoystickEvent;
471 class SLogEvent LogEvent;
472 class SUserEvent UserEvent;
473 };
474
475};
476
478
484{
485public:
486
488 virtual ~IEventReceiver() {}
489
491
496 virtual bool OnEvent(const SEvent& event) = 0;
497};
498
499
502{
503public:
505
509
512
515
517
520
522
524 enum
525 {
528
531
535}; // class SJoystickInfo
536
537} // namespace nirt
538
539#endif
Interface of an object which can receive events.
Definition IEventReceiver.hpp:484
virtual ~IEventReceiver()
Destructor.
Definition IEventReceiver.hpp:488
virtual bool OnEvent(const SEvent &event)=0
Called if an event happened.
Any kind of GUI event.
Definition IEventReceiver.hpp:286
gui::IGUIElement * Caller
IGUIElement who called the event.
Definition IEventReceiver.hpp:289
gui::EGUI_EVENT_TYPE EventType
Type of GUI Event.
Definition IEventReceiver.hpp:295
gui::IGUIElement * Element
If the event has something to do with another element, it will be held here.
Definition IEventReceiver.hpp:292
A joystick event.
Definition IEventReceiver.hpp:387
u16 POV
Definition IEventReceiver.hpp:421
s16 Axis[NUMBER_OF_AXES]
Definition IEventReceiver.hpp:414
u8 Joystick
The ID of the joystick which generated this event.
Definition IEventReceiver.hpp:426
bool IsButtonPressed(u32 button) const
A helper function to check if a button is pressed.
Definition IEventReceiver.hpp:429
u32 ButtonStates
Definition IEventReceiver.hpp:404
Any kind of keyboard event.
Definition IEventReceiver.hpp:359
wchar_t Char
Character corresponding to the key (0, if not a character, value undefined in key releases)
Definition IEventReceiver.hpp:362
bool Control
True if ctrl was also pressed.
Definition IEventReceiver.hpp:374
bool Shift
True if shift was also pressed.
Definition IEventReceiver.hpp:371
bool PressedDown
If not true, then the key was left up.
Definition IEventReceiver.hpp:368
EKEY_CODE Key
Key which has been pressed or released.
Definition IEventReceiver.hpp:365
Any kind of log event.
Definition IEventReceiver.hpp:441
ELOG_LEVEL Level
Log level in which the text has been logged.
Definition IEventReceiver.hpp:447
const c8 * Text
Pointer to text which has been logged.
Definition IEventReceiver.hpp:444
Any kind of mouse event.
Definition IEventReceiver.hpp:320
bool isLeftPressed() const
Is the left button pressed down?
Definition IEventReceiver.hpp:344
bool Shift
True if shift was also pressed.
Definition IEventReceiver.hpp:333
u32 ButtonStates
Definition IEventReceiver.hpp:341
f32 Wheel
mouse wheel delta, often 1.0 or -1.0, but can have other values < 0.f or > 0.f;
Definition IEventReceiver.hpp:330
bool Control
True if ctrl was also pressed.
Definition IEventReceiver.hpp:336
EMOUSE_INPUT_EVENT Event
Type of mouse event.
Definition IEventReceiver.hpp:353
bool isMiddlePressed() const
Is the middle button pressed down?
Definition IEventReceiver.hpp:350
s32 Y
Y position of mouse cursor.
Definition IEventReceiver.hpp:326
s32 X
X position of mouse cursor.
Definition IEventReceiver.hpp:323
bool isRightPressed() const
Is the right button pressed down?
Definition IEventReceiver.hpp:347
Any kind of touch event.
Definition IEventReceiver.hpp:302
ETOUCH_INPUT_EVENT Event
Type of touch event.
Definition IEventReceiver.hpp:314
Any kind of user event.
Definition IEventReceiver.hpp:453
size_t UserData1
Some user specified data as int.
Definition IEventReceiver.hpp:456
size_t UserData2
Another user specified data as int.
Definition IEventReceiver.hpp:459
SEvents hold information about an event. See nirt::IEventReceiver for details on event handling.
Definition IEventReceiver.hpp:282
Information on a joystick, returned from nirt::NirtcppDevice::activateJoysticks()
Definition IEventReceiver.hpp:502
u8 Joystick
The ID of the joystick.
Definition IEventReceiver.hpp:508
u32 Axes
The number of axes that the joystick has, i.e. X, Y, Z, R, U, V.
Definition IEventReceiver.hpp:519
@ POV_HAT_UNKNOWN
The presence or absence of a hat cannot be determined.
Definition IEventReceiver.hpp:533
@ POV_HAT_ABSENT
A hat is definitely not present.
Definition IEventReceiver.hpp:530
@ POV_HAT_PRESENT
A hat is definitely present.
Definition IEventReceiver.hpp:527
enum nirt::SJoystickInfo::@13 PovHat
An indication of whether the joystick has a POV hat.
core::stringc Name
The name that the joystick uses to identify itself.
Definition IEventReceiver.hpp:511
u32 Buttons
The number of buttons that the joystick has.
Definition IEventReceiver.hpp:514
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Base class of all GUI elements.
Definition IGUIElement.hpp:24
EGUI_EVENT_TYPE
Enumeration for all events which are sendable by the gui system.
Definition IEventReceiver.hpp:171
@ EGET_ELEMENT_HOVERED
The mouse cursor hovered over a gui element.
Definition IEventReceiver.hpp:183
@ EGET_TREEVIEW_NODE_DESELECT
A tree view node lost selection. See IGUITreeView::getLastEventNode().
Definition IEventReceiver.hpp:259
@ EGET_FILE_SELECTED
A file has been selected in the file dialog.
Definition IEventReceiver.hpp:212
@ EGET_COMBO_BOX_CHANGED
The selection in a combo box has been changed.
Definition IEventReceiver.hpp:248
@ EGET_TAB_CHANGED
The tab was changed in an tab control.
Definition IEventReceiver.hpp:242
@ EGET_EDITBOX_CHANGED
The text in an editbox was changed. This does not include automatic changes in text-breaking.
Definition IEventReceiver.hpp:236
@ EGET_ELEMENT_CLOSED
An element would like to close.
Definition IEventReceiver.hpp:192
@ EGET_ELEMENT_FOCUS_LOST
A gui element has lost its focus.
Definition IEventReceiver.hpp:175
@ EGET_CHECKBOX_CHANGED
A checkbox has changed its check state.
Definition IEventReceiver.hpp:201
@ EGET_TABLE_CHANGED
A table has changed.
Definition IEventReceiver.hpp:254
@ EGET_TREEVIEW_NODE_COLLAPSE
A tree view node was collapsed. See IGUITreeView::getLastEventNode().
Definition IEventReceiver.hpp:268
@ EGET_SPINBOX_CHANGED
The value of a spin box has changed.
Definition IEventReceiver.hpp:251
@ EGET_SCROLL_BAR_CHANGED
A scrollbar has changed its position.
Definition IEventReceiver.hpp:198
@ EGET_EDITBOX_MARKING_CHANGED
The marked area in an editbox was changed.
Definition IEventReceiver.hpp:239
@ EGET_TREEVIEW_NODE_COLLAPS
Definition IEventReceiver.hpp:272
@ EGET_TREEVIEW_NODE_SELECT
A tree view node was selected. See IGUITreeView::getLastEventNode().
Definition IEventReceiver.hpp:262
@ EGET_MESSAGEBOX_CANCEL
'Cancel' was clicked on a messagebox
Definition IEventReceiver.hpp:230
@ EGET_MESSAGEBOX_OK
'OK' was clicked on a messagebox
Definition IEventReceiver.hpp:227
@ EGET_MESSAGEBOX_YES
'Yes' was clicked on a messagebox
Definition IEventReceiver.hpp:221
@ EGET_LISTBOX_SELECTED_AGAIN
An item in the listbox was selected, which was already selected.
Definition IEventReceiver.hpp:209
@ EGET_ELEMENT_FOCUSED
A gui element has got the focus.
Definition IEventReceiver.hpp:179
@ EGET_ELEMENT_LEFT
The mouse cursor left the hovered element.
Definition IEventReceiver.hpp:187
@ EGET_LISTBOX_CHANGED
A new item in a listbox was selected.
Definition IEventReceiver.hpp:205
@ EGET_EDITBOX_ENTER
In an editbox 'ENTER' was pressed.
Definition IEventReceiver.hpp:233
@ EGET_FILE_CHOOSE_DIALOG_CANCELLED
A file open dialog has been closed without choosing a file.
Definition IEventReceiver.hpp:218
@ EGET_BUTTON_CLICKED
A button was clicked.
Definition IEventReceiver.hpp:195
@ EGET_DIRECTORY_SELECTED
A directory has been selected in the file dialog.
Definition IEventReceiver.hpp:215
@ EGET_MESSAGEBOX_NO
'No' was clicked on a messagebox
Definition IEventReceiver.hpp:224
@ EGET_MENU_ITEM_SELECTED
A menu item was selected in a (context) menu.
Definition IEventReceiver.hpp:245
@ EGET_TREEVIEW_NODE_EXPAND
A tree view node was expanded. See IGUITreeView::getLastEventNode().
Definition IEventReceiver.hpp:265
@ EGET_COUNT
No real event. Just for convenience to get number of events.
Definition IEventReceiver.hpp:275
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.hpp:46
ETOUCH_INPUT_EVENT
Enumeration for all touch input events.
Definition IEventReceiver.hpp:150
@ ETIE_LEFT_UP
Touch was left up.
Definition IEventReceiver.hpp:155
@ ETIE_PRESSED_DOWN
Touch was pressed down.
Definition IEventReceiver.hpp:152
@ ETIE_COUNT
No real event. Just for convenience to get number of events.
Definition IEventReceiver.hpp:161
@ ETIE_MOVED
The touch changed its position.
Definition IEventReceiver.hpp:158
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.hpp:24
E_MOUSE_BUTTON_STATE_MASK
Masks for mouse button states.
Definition IEventReceiver.hpp:134
@ EMBSM_EXTRA1
currently only on windows
Definition IEventReceiver.hpp:140
@ EMBSM_EXTRA2
currently only on windows
Definition IEventReceiver.hpp:143
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
char c8
8 bit character variable.
Definition irrTypes.hpp:37
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110
ELOG_LEVEL
Definition ILogger.hpp:18
EMOUSE_INPUT_EVENT
Enumeration for all mouse input events.
Definition IEventReceiver.hpp:78
@ EMIE_RMOUSE_DOUBLE_CLICK
Definition IEventReceiver.hpp:110
@ EMIE_MMOUSE_PRESSED_DOWN
Middle mouse button was pressed down.
Definition IEventReceiver.hpp:86
@ EMIE_LMOUSE_LEFT_UP
Left mouse button was left up.
Definition IEventReceiver.hpp:89
@ EMIE_RMOUSE_PRESSED_DOWN
Right mouse button was pressed down.
Definition IEventReceiver.hpp:83
@ EMIE_MMOUSE_TRIPLE_CLICK
Definition IEventReceiver.hpp:126
@ EMIE_LMOUSE_TRIPLE_CLICK
Definition IEventReceiver.hpp:118
@ EMIE_COUNT
No real event. Just for convenience to get number of events.
Definition IEventReceiver.hpp:129
@ EMIE_RMOUSE_LEFT_UP
Right mouse button was left up.
Definition IEventReceiver.hpp:92
@ EMIE_MMOUSE_LEFT_UP
Middle mouse button was left up.
Definition IEventReceiver.hpp:95
@ EMIE_MOUSE_MOVED
The mouse cursor changed its position.
Definition IEventReceiver.hpp:98
@ EMIE_MMOUSE_DOUBLE_CLICK
Definition IEventReceiver.hpp:114
@ EMIE_LMOUSE_DOUBLE_CLICK
Definition IEventReceiver.hpp:106
@ EMIE_MOUSE_WHEEL
Definition IEventReceiver.hpp:102
@ EMIE_RMOUSE_TRIPLE_CLICK
Definition IEventReceiver.hpp:122
@ EMIE_LMOUSE_PRESSED_DOWN
Left mouse button was pressed down.
Definition IEventReceiver.hpp:80
signed short s16
16 bit signed variable.
Definition irrTypes.hpp:54
EEVENT_TYPE
Enumeration for all event types there are.
Definition IEventReceiver.hpp:16
@ EET_LOG_TEXT_EVENT
A log event.
Definition IEventReceiver.hpp:53
@ EET_GUI_EVENT
An event of the graphical user interface.
Definition IEventReceiver.hpp:22
@ EET_TOUCH_INPUT_EVENT
A touch input event.
Definition IEventReceiver.hpp:38
@ EET_MOUSE_INPUT_EVENT
A mouse input event.
Definition IEventReceiver.hpp:30
@ EET_USER_EVENT
A user event with user data.
Definition IEventReceiver.hpp:68
@ EGUIET_FORCE_32_BIT
Definition IEventReceiver.hpp:72
@ EET_JOYSTICK_INPUT_EVENT
A joystick (joypad, gamepad) input event.
Definition IEventReceiver.hpp:48
@ EET_KEY_INPUT_EVENT
A key input event.
Definition IEventReceiver.hpp:35

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print