Unigine::Input Class
Header: | #include <UnigineInput.h> |
The Input class contains functions for simple manual handling of user inputs using a keyboard, a mouse or a gamepad.
This class represents an engine's singleton.
See Also#
- Input sample in C# Component Samples suite
Usage Examples#
The following example shows a way to move and rotate a node by using the Input class:
#include "AppWorldLogic.h"
#include <UnigineInput.h>
#include <UnigineConsole.h>
#include <UnigineGame.h>
#include <UniginePrimitives.h>
using namespace Unigine;
using namespace Math;
NodePtr box;
float move_speed = 1.0f;
float turn_speed = 30.0f;
int AppWorldLogic::init()
{
box = Primitives::createBox(vec3_one);
return 1;
}
int AppWorldLogic::update()
{
if (Console::isActive())
return 1;
if (Input::isKeyPressed(Input::KEY_UP) || Input::isKeyPressed(Input::KEY_W))
box->translate(Vec3_forward * move_speed * Game::getIFps());
if (Input::isKeyPressed(Input::KEY_DOWN) || Input::isKeyPressed(Input::KEY_S))
box->translate(Vec3_back * move_speed * Game::getIFps());
if (Input::isKeyPressed(Input::KEY_LEFT) || Input::isKeyPressed(Input::KEY_A))
box->rotate(0.0f, 0.0f, turn_speed * Game::getIFps());
if (Input::isKeyPressed(Input::KEY_RIGHT) || Input::isKeyPressed(Input::KEY_D))
box->rotate(0.0f, 0.0f, -turn_speed * Game::getIFps());
return 1;
}
The following code demonstrates how to receive an event that changed the button state to isKeyDown(), isKeyUp(). Such code can also be used for the mouse and touch buttons.
#include "AppWorldLogic.h"
#include <UnigineInput.h>
#include <UnigineConsole.h>
using namespace Unigine;
int AppWorldLogic::update()
{
if (Input::isKeyDown(Input::KEY_T) || Input::isKeyUp(Input::KEY_T))
{
InputEventKeyboardPtr e = Input::getKeyEvent(Input::KEY_T);
Console::messageLine("%s %d time = %lld frame = %lld", Input::getKeyName(e->getKey()), e->getAction(), e->getTimestamp(), e->getFrame());
}
return 1;
}
The following code illustrates receiving the immediate input — the user receives the event notification immediately after filtering:
#include "AppWorldLogic.h"
#include <UnigineInput.h>
#include <UnigineConsole.h>
using namespace Unigine;
int AppWorldLogic::init()
{
Input::getEventImmediateInput().connect(on_immediate_input);
return 1;
}
The following code illustrates how the event filter works. Pressing the "W" button and mouse movements will be declined, i.e. these events won't be taken as input:
#include "AppWorldLogic.h"
#include <UnigineInput.h>
using namespace Unigine;
int event_filter(InputEventPtr& e)
{
switch (e->getType())
{
case InputEvent::INPUT_EVENT_KEYBOARD:
{
// skip 'W' key repeat events
InputEventKeyboardPtr k = checked_ptr_cast<InputEventKeyboard>(e);
if (k->getKey() == Input::KEY_W && k->getAction() == InputEventKeyboard::ACTION_REPEAT)
return 1;
break;
}
case InputEvent::INPUT_EVENT_MOUSE_MOTION:
{
// skip all mouse motion events
return 1;
}
default: break;
}
return 0;
}
int AppWorldLogic::init()
{
Input::setEventsFilter(event_filter);
return 1;
}
The following code is an example of input events creation. We'll imitate the input of the show_profiler 1 console command as if it were an event from the keyboard.
#include "AppWorldLogic.h"
#include <UnigineInput.h>
using namespace Unigine;
enum
{
STATE_OPEN_CONSOLE = 0,
STATE_TYPING_COMMAND,
STATE_APPLY_COMMAND,
STATE_FINISH,
};
int state = STATE_OPEN_CONSOLE;
void emulate_key_input(Input::KEY key)
{
InputEventKeyboardPtr key_down = InputEventKeyboard::create();
key_down->setAction(InputEventKeyboard::ACTION_DOWN);
key_down->setKey(key);
InputEventKeyboardPtr key_repeat = InputEventKeyboard::create();
key_repeat->setAction(InputEventKeyboard::ACTION_REPEAT);
key_repeat->setKey(key);
InputEventKeyboardPtr key_up = InputEventKeyboard::create();
key_up->setAction(InputEventKeyboard::ACTION_UP);
key_up->setKey(key);
Input::sendEvent(key_down);
Input::sendEvent(key_repeat);
Input::sendEvent(key_up);
}
void emulate_text_input(const char *text)
{
int size = strlen(text);
for (int i = 0; i < size; i++)
{
InputEventTextPtr text_input = InputEventText::create();
text_input->setUnicode(text[i]);
Input::sendEvent(text_input);
}
}
int AppWorldLogic::update()
{
switch (state)
{
case STATE_OPEN_CONSOLE:
{
emulate_key_input(Input::KEY_BACK_QUOTE);
state = STATE_TYPING_COMMAND;
break;
}
case STATE_TYPING_COMMAND:
{
emulate_text_input("show_profiler 1");
state = STATE_APPLY_COMMAND;
break;
}
case STATE_APPLY_COMMAND:
{
emulate_key_input(Input::KEY_ENTER);
state = STATE_FINISH;
break;
}
default: break;
}
return 1;
}
The following code demonstrates how to obtain various button names using the getKeyName(), keyToUnicode(), and getKeyLocalName() methods:
#include "AppWorldLogic.h"
#include <UnigineInput.h>
#include <UnigineConsole.h>
using namespace Unigine;
int AppWorldLogic::init()
{
Console::setOnscreen(true);
return 1;
}
int AppWorldLogic::update()
{
auto print_info = [](const char* state, Input::KEY key)
{
unsigned int unicode = Input::keyToUnicode(key);
Console::message("%s: (key='%s', unicode='%s', local_name='%s') ",
state,
Input::getKeyName(key),
String::unicodeToUtf8(unicode).get(),
Input::getKeyLocalName(key));
};
print_info("Up", Input::KEY_W);
print_info("Jump", Input::KEY_SPACE);
print_info("Run", Input::KEY_RIGHT_SHIFT);
Console::message("\n");
return 1;
}
Input Class
Enums
MOUSE_HANDLE#
MOUSE_BUTTON#
MODIFIER#
KEY#
DEVICE#
GAMEPAD_BUTTON#
Buttons of the gamepad.GAMEPAD_AXIS#
JOYSTICK_POV#
POV (Point-of-View) switch or DPad states.VR_BUTTON#
Members
getNumJoysticks() const#
Return value
CurrentgetNumGamePads() const#
Return value
CurrentgetMouseWheelHorizontal() const#
Return value
CurrentgetMouseWheel() const#
Return value
CurrentgetMouseDeltaPosition() const#
Return value
Currentvoid setMousePosition ( ) #
Arguments
- position - The
getMousePosition() const#
Return value
Currentbool isEmptyClipboard() const#
Return value
true if if the clipboard is empty is enabled; otherwise false.Math::ivec2 getMouseDeltaRaw() const#
Return value
CurrentPtr<InputVRController> getVRControllerTreadmill() const#
Return value
CurrentPtr<InputVRController> getVRControllerRight() const#
Return value
CurrentPtr<InputVRController> getVRControllerLeft() const#
Return value
CurrentPtr<InputVRHead> getVRHead() const#
Return value
Currentint getNumVRDevices() const#
Return value
CurrentEvent<const Ptr<InputEvent> &> getEventImmediateInput() const#
Usage Example
// implement the ImmediateInput event handler
void immediateinput_event_handler(const Ptr<InputEvent> & event)
{
Log::message("\Handling ImmediateInput event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections immediateinput_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventImmediateInput().connect(immediateinput_event_connections, immediateinput_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventImmediateInput().connect(immediateinput_event_connections, [](const Ptr<InputEvent> & event) {
Log::message("\Handling ImmediateInput event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
immediateinput_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection immediateinput_event_connection;
// subscribe to the ImmediateInput event with a handler function keeping the connection
Input::getEventImmediateInput().connect(immediateinput_event_connection, immediateinput_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
immediateinput_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
immediateinput_event_connection.setEnabled(true);
// ...
// remove subscription to the ImmediateInput event via the connection
immediateinput_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A ImmediateInput event handler implemented as a class member
void event_handler(const Ptr<InputEvent> & event)
{
Log::message("\Handling ImmediateInput event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventImmediateInput().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the ImmediateInput event with a handler function
Input::getEventImmediateInput().connect(immediateinput_event_handler);
// remove subscription to the ImmediateInput event later by the handler function
Input::getEventImmediateInput().disconnect(immediateinput_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId immediateinput_handler_id;
// subscribe to the ImmediateInput event with a lambda handler function and keeping connection ID
immediateinput_handler_id = Input::getEventImmediateInput().connect([](const Ptr<InputEvent> & event) {
Log::message("\Handling ImmediateInput event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventImmediateInput().disconnect(immediateinput_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all ImmediateInput events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventImmediateInput().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventImmediateInput().setEnabled(true);
Return value
Event reference.Event<int, Input::JOYSTICK_POV> getEventJoyPovMotion() const#
Usage Example
// implement the JoyPovMotion event handler
void joypovmotion_event_handler(int joystick_id, Input::JOYSTICK_POV pov_index)
{
Log::message("\Handling JoyPovMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections joypovmotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventJoyPovMotion().connect(joypovmotion_event_connections, joypovmotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventJoyPovMotion().connect(joypovmotion_event_connections, [](int joystick_id, Input::JOYSTICK_POV pov_index) {
Log::message("\Handling JoyPovMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
joypovmotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection joypovmotion_event_connection;
// subscribe to the JoyPovMotion event with a handler function keeping the connection
Input::getEventJoyPovMotion().connect(joypovmotion_event_connection, joypovmotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
joypovmotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
joypovmotion_event_connection.setEnabled(true);
// ...
// remove subscription to the JoyPovMotion event via the connection
joypovmotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A JoyPovMotion event handler implemented as a class member
void event_handler(int joystick_id, Input::JOYSTICK_POV pov_index)
{
Log::message("\Handling JoyPovMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventJoyPovMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the JoyPovMotion event with a handler function
Input::getEventJoyPovMotion().connect(joypovmotion_event_handler);
// remove subscription to the JoyPovMotion event later by the handler function
Input::getEventJoyPovMotion().disconnect(joypovmotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId joypovmotion_handler_id;
// subscribe to the JoyPovMotion event with a lambda handler function and keeping connection ID
joypovmotion_handler_id = Input::getEventJoyPovMotion().connect([](int joystick_id, Input::JOYSTICK_POV pov_index) {
Log::message("\Handling JoyPovMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventJoyPovMotion().disconnect(joypovmotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all JoyPovMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventJoyPovMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventJoyPovMotion().setEnabled(true);
Return value
Event reference.Event<int, int> getEventJoyAxisMotion() const#
Usage Example
// implement the JoyAxisMotion event handler
void joyaxismotion_event_handler(joystick_id)
{
Log::message("\Handling JoyAxisMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections joyaxismotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventJoyAxisMotion().connect(joyaxismotion_event_connections, joyaxismotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventJoyAxisMotion().connect(joyaxismotion_event_connections, [](joystick_id) {
Log::message("\Handling JoyAxisMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
joyaxismotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection joyaxismotion_event_connection;
// subscribe to the JoyAxisMotion event with a handler function keeping the connection
Input::getEventJoyAxisMotion().connect(joyaxismotion_event_connection, joyaxismotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
joyaxismotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
joyaxismotion_event_connection.setEnabled(true);
// ...
// remove subscription to the JoyAxisMotion event via the connection
joyaxismotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A JoyAxisMotion event handler implemented as a class member
void event_handler(joystick_id)
{
Log::message("\Handling JoyAxisMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventJoyAxisMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the JoyAxisMotion event with a handler function
Input::getEventJoyAxisMotion().connect(joyaxismotion_event_handler);
// remove subscription to the JoyAxisMotion event later by the handler function
Input::getEventJoyAxisMotion().disconnect(joyaxismotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId joyaxismotion_handler_id;
// subscribe to the JoyAxisMotion event with a lambda handler function and keeping connection ID
joyaxismotion_handler_id = Input::getEventJoyAxisMotion().connect([](joystick_id) {
Log::message("\Handling JoyAxisMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventJoyAxisMotion().disconnect(joyaxismotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all JoyAxisMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventJoyAxisMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventJoyAxisMotion().setEnabled(true);
Return value
Event reference.Event<int, int> getEventJoyButtonUp() const#
Usage Example
// implement the JoyButtonUp event handler
void joybuttonup_event_handler(joystick_id)
{
Log::message("\Handling JoyButtonUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections joybuttonup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventJoyButtonUp().connect(joybuttonup_event_connections, joybuttonup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventJoyButtonUp().connect(joybuttonup_event_connections, [](joystick_id) {
Log::message("\Handling JoyButtonUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
joybuttonup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection joybuttonup_event_connection;
// subscribe to the JoyButtonUp event with a handler function keeping the connection
Input::getEventJoyButtonUp().connect(joybuttonup_event_connection, joybuttonup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
joybuttonup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
joybuttonup_event_connection.setEnabled(true);
// ...
// remove subscription to the JoyButtonUp event via the connection
joybuttonup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A JoyButtonUp event handler implemented as a class member
void event_handler(joystick_id)
{
Log::message("\Handling JoyButtonUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventJoyButtonUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the JoyButtonUp event with a handler function
Input::getEventJoyButtonUp().connect(joybuttonup_event_handler);
// remove subscription to the JoyButtonUp event later by the handler function
Input::getEventJoyButtonUp().disconnect(joybuttonup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId joybuttonup_handler_id;
// subscribe to the JoyButtonUp event with a lambda handler function and keeping connection ID
joybuttonup_handler_id = Input::getEventJoyButtonUp().connect([](joystick_id) {
Log::message("\Handling JoyButtonUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventJoyButtonUp().disconnect(joybuttonup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all JoyButtonUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventJoyButtonUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventJoyButtonUp().setEnabled(true);
Return value
Event reference.Event<int, int> getEventJoyButtonDown() const#
Usage Example
// implement the JoyButtonDown event handler
void joybuttondown_event_handler(joystick_id)
{
Log::message("\Handling JoyButtonDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections joybuttondown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventJoyButtonDown().connect(joybuttondown_event_connections, joybuttondown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventJoyButtonDown().connect(joybuttondown_event_connections, [](joystick_id) {
Log::message("\Handling JoyButtonDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
joybuttondown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection joybuttondown_event_connection;
// subscribe to the JoyButtonDown event with a handler function keeping the connection
Input::getEventJoyButtonDown().connect(joybuttondown_event_connection, joybuttondown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
joybuttondown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
joybuttondown_event_connection.setEnabled(true);
// ...
// remove subscription to the JoyButtonDown event via the connection
joybuttondown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A JoyButtonDown event handler implemented as a class member
void event_handler(joystick_id)
{
Log::message("\Handling JoyButtonDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventJoyButtonDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the JoyButtonDown event with a handler function
Input::getEventJoyButtonDown().connect(joybuttondown_event_handler);
// remove subscription to the JoyButtonDown event later by the handler function
Input::getEventJoyButtonDown().disconnect(joybuttondown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId joybuttondown_handler_id;
// subscribe to the JoyButtonDown event with a lambda handler function and keeping connection ID
joybuttondown_handler_id = Input::getEventJoyButtonDown().connect([](joystick_id) {
Log::message("\Handling JoyButtonDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventJoyButtonDown().disconnect(joybuttondown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all JoyButtonDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventJoyButtonDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventJoyButtonDown().setEnabled(true);
Return value
Event reference.Event<int> getEventJoyDisconnected() const#
Usage Example
// implement the JoyDisconnected event handler
void joydisconnected_event_handler(joystick_id)
{
Log::message("\Handling JoyDisconnected event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections joydisconnected_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventJoyDisconnected().connect(joydisconnected_event_connections, joydisconnected_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventJoyDisconnected().connect(joydisconnected_event_connections, [](joystick_id) {
Log::message("\Handling JoyDisconnected event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
joydisconnected_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection joydisconnected_event_connection;
// subscribe to the JoyDisconnected event with a handler function keeping the connection
Input::getEventJoyDisconnected().connect(joydisconnected_event_connection, joydisconnected_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
joydisconnected_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
joydisconnected_event_connection.setEnabled(true);
// ...
// remove subscription to the JoyDisconnected event via the connection
joydisconnected_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A JoyDisconnected event handler implemented as a class member
void event_handler(joystick_id)
{
Log::message("\Handling JoyDisconnected event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventJoyDisconnected().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the JoyDisconnected event with a handler function
Input::getEventJoyDisconnected().connect(joydisconnected_event_handler);
// remove subscription to the JoyDisconnected event later by the handler function
Input::getEventJoyDisconnected().disconnect(joydisconnected_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId joydisconnected_handler_id;
// subscribe to the JoyDisconnected event with a lambda handler function and keeping connection ID
joydisconnected_handler_id = Input::getEventJoyDisconnected().connect([](joystick_id) {
Log::message("\Handling JoyDisconnected event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventJoyDisconnected().disconnect(joydisconnected_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all JoyDisconnected events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventJoyDisconnected().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventJoyDisconnected().setEnabled(true);
Return value
Event reference.Event<int> getEventJoyConnected() const#
Usage Example
// implement the JoyConnected event handler
void joyconnected_event_handler(joystick_id)
{
Log::message("\Handling JoyConnected event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections joyconnected_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventJoyConnected().connect(joyconnected_event_connections, joyconnected_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventJoyConnected().connect(joyconnected_event_connections, [](joystick_id) {
Log::message("\Handling JoyConnected event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
joyconnected_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection joyconnected_event_connection;
// subscribe to the JoyConnected event with a handler function keeping the connection
Input::getEventJoyConnected().connect(joyconnected_event_connection, joyconnected_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
joyconnected_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
joyconnected_event_connection.setEnabled(true);
// ...
// remove subscription to the JoyConnected event via the connection
joyconnected_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A JoyConnected event handler implemented as a class member
void event_handler(joystick_id)
{
Log::message("\Handling JoyConnected event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventJoyConnected().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the JoyConnected event with a handler function
Input::getEventJoyConnected().connect(joyconnected_event_handler);
// remove subscription to the JoyConnected event later by the handler function
Input::getEventJoyConnected().disconnect(joyconnected_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId joyconnected_handler_id;
// subscribe to the JoyConnected event with a lambda handler function and keeping connection ID
joyconnected_handler_id = Input::getEventJoyConnected().connect([](joystick_id) {
Log::message("\Handling JoyConnected event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventJoyConnected().disconnect(joyconnected_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all JoyConnected events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventJoyConnected().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventJoyConnected().setEnabled(true);
Return value
Event reference.Event<int, int> getEventVrDeviceAxisMotion() const#
Usage Example
// implement the VrDeviceAxisMotion event handler
void vrdeviceaxismotion_event_handler(device_id)
{
Log::message("\Handling VrDeviceAxisMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdeviceaxismotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceAxisMotion().connect(vrdeviceaxismotion_event_connections, vrdeviceaxismotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceAxisMotion().connect(vrdeviceaxismotion_event_connections, [](device_id) {
Log::message("\Handling VrDeviceAxisMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdeviceaxismotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdeviceaxismotion_event_connection;
// subscribe to the VrDeviceAxisMotion event with a handler function keeping the connection
Input::getEventVrDeviceAxisMotion().connect(vrdeviceaxismotion_event_connection, vrdeviceaxismotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdeviceaxismotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdeviceaxismotion_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceAxisMotion event via the connection
vrdeviceaxismotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceAxisMotion event handler implemented as a class member
void event_handler(device_id)
{
Log::message("\Handling VrDeviceAxisMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceAxisMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceAxisMotion event with a handler function
Input::getEventVrDeviceAxisMotion().connect(vrdeviceaxismotion_event_handler);
// remove subscription to the VrDeviceAxisMotion event later by the handler function
Input::getEventVrDeviceAxisMotion().disconnect(vrdeviceaxismotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdeviceaxismotion_handler_id;
// subscribe to the VrDeviceAxisMotion event with a lambda handler function and keeping connection ID
vrdeviceaxismotion_handler_id = Input::getEventVrDeviceAxisMotion().connect([](device_id) {
Log::message("\Handling VrDeviceAxisMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceAxisMotion().disconnect(vrdeviceaxismotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceAxisMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceAxisMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceAxisMotion().setEnabled(true);
Return value
Event reference.Event<int, Input::VR_BUTTON> getEventVrDeviceButtonTouchUp() const#
Usage Example
// implement the VrDeviceButtonTouchUp event handler
void vrdevicebuttontouchup_event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonTouchUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdevicebuttontouchup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceButtonTouchUp().connect(vrdevicebuttontouchup_event_connections, vrdevicebuttontouchup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceButtonTouchUp().connect(vrdevicebuttontouchup_event_connections, [](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonTouchUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdevicebuttontouchup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdevicebuttontouchup_event_connection;
// subscribe to the VrDeviceButtonTouchUp event with a handler function keeping the connection
Input::getEventVrDeviceButtonTouchUp().connect(vrdevicebuttontouchup_event_connection, vrdevicebuttontouchup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdevicebuttontouchup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdevicebuttontouchup_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceButtonTouchUp event via the connection
vrdevicebuttontouchup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceButtonTouchUp event handler implemented as a class member
void event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonTouchUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceButtonTouchUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceButtonTouchUp event with a handler function
Input::getEventVrDeviceButtonTouchUp().connect(vrdevicebuttontouchup_event_handler);
// remove subscription to the VrDeviceButtonTouchUp event later by the handler function
Input::getEventVrDeviceButtonTouchUp().disconnect(vrdevicebuttontouchup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdevicebuttontouchup_handler_id;
// subscribe to the VrDeviceButtonTouchUp event with a lambda handler function and keeping connection ID
vrdevicebuttontouchup_handler_id = Input::getEventVrDeviceButtonTouchUp().connect([](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonTouchUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceButtonTouchUp().disconnect(vrdevicebuttontouchup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceButtonTouchUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceButtonTouchUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceButtonTouchUp().setEnabled(true);
Return value
Event reference.Event<int, Input::VR_BUTTON> getEventVrDeviceButtonTouchDown() const#
Usage Example
// implement the VrDeviceButtonTouchDown event handler
void vrdevicebuttontouchdown_event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonTouchDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdevicebuttontouchdown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceButtonTouchDown().connect(vrdevicebuttontouchdown_event_connections, vrdevicebuttontouchdown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceButtonTouchDown().connect(vrdevicebuttontouchdown_event_connections, [](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonTouchDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdevicebuttontouchdown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdevicebuttontouchdown_event_connection;
// subscribe to the VrDeviceButtonTouchDown event with a handler function keeping the connection
Input::getEventVrDeviceButtonTouchDown().connect(vrdevicebuttontouchdown_event_connection, vrdevicebuttontouchdown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdevicebuttontouchdown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdevicebuttontouchdown_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceButtonTouchDown event via the connection
vrdevicebuttontouchdown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceButtonTouchDown event handler implemented as a class member
void event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonTouchDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceButtonTouchDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceButtonTouchDown event with a handler function
Input::getEventVrDeviceButtonTouchDown().connect(vrdevicebuttontouchdown_event_handler);
// remove subscription to the VrDeviceButtonTouchDown event later by the handler function
Input::getEventVrDeviceButtonTouchDown().disconnect(vrdevicebuttontouchdown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdevicebuttontouchdown_handler_id;
// subscribe to the VrDeviceButtonTouchDown event with a lambda handler function and keeping connection ID
vrdevicebuttontouchdown_handler_id = Input::getEventVrDeviceButtonTouchDown().connect([](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonTouchDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceButtonTouchDown().disconnect(vrdevicebuttontouchdown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceButtonTouchDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceButtonTouchDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceButtonTouchDown().setEnabled(true);
Return value
Event reference.Event<int, Input::VR_BUTTON> getEventVrDeviceButtonUp() const#
Usage Example
// implement the VrDeviceButtonUp event handler
void vrdevicebuttonup_event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdevicebuttonup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceButtonUp().connect(vrdevicebuttonup_event_connections, vrdevicebuttonup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceButtonUp().connect(vrdevicebuttonup_event_connections, [](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdevicebuttonup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdevicebuttonup_event_connection;
// subscribe to the VrDeviceButtonUp event with a handler function keeping the connection
Input::getEventVrDeviceButtonUp().connect(vrdevicebuttonup_event_connection, vrdevicebuttonup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdevicebuttonup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdevicebuttonup_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceButtonUp event via the connection
vrdevicebuttonup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceButtonUp event handler implemented as a class member
void event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceButtonUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceButtonUp event with a handler function
Input::getEventVrDeviceButtonUp().connect(vrdevicebuttonup_event_handler);
// remove subscription to the VrDeviceButtonUp event later by the handler function
Input::getEventVrDeviceButtonUp().disconnect(vrdevicebuttonup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdevicebuttonup_handler_id;
// subscribe to the VrDeviceButtonUp event with a lambda handler function and keeping connection ID
vrdevicebuttonup_handler_id = Input::getEventVrDeviceButtonUp().connect([](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceButtonUp().disconnect(vrdevicebuttonup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceButtonUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceButtonUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceButtonUp().setEnabled(true);
Return value
Event reference.Event<int, Input::VR_BUTTON> getEventVrDeviceButtonDown() const#
Usage Example
// implement the VrDeviceButtonDown event handler
void vrdevicebuttondown_event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdevicebuttondown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceButtonDown().connect(vrdevicebuttondown_event_connections, vrdevicebuttondown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceButtonDown().connect(vrdevicebuttondown_event_connections, [](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdevicebuttondown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdevicebuttondown_event_connection;
// subscribe to the VrDeviceButtonDown event with a handler function keeping the connection
Input::getEventVrDeviceButtonDown().connect(vrdevicebuttondown_event_connection, vrdevicebuttondown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdevicebuttondown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdevicebuttondown_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceButtonDown event via the connection
vrdevicebuttondown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceButtonDown event handler implemented as a class member
void event_handler(int device_id, Input::VR_BUTTON button)
{
Log::message("\Handling VrDeviceButtonDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceButtonDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceButtonDown event with a handler function
Input::getEventVrDeviceButtonDown().connect(vrdevicebuttondown_event_handler);
// remove subscription to the VrDeviceButtonDown event later by the handler function
Input::getEventVrDeviceButtonDown().disconnect(vrdevicebuttondown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdevicebuttondown_handler_id;
// subscribe to the VrDeviceButtonDown event with a lambda handler function and keeping connection ID
vrdevicebuttondown_handler_id = Input::getEventVrDeviceButtonDown().connect([](int device_id, Input::VR_BUTTON button) {
Log::message("\Handling VrDeviceButtonDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceButtonDown().disconnect(vrdevicebuttondown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceButtonDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceButtonDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceButtonDown().setEnabled(true);
Return value
Event reference.Event<int> getEventVrDeviceDisconnected() const#
Usage Example
// implement the VrDeviceDisconnected event handler
void vrdevicedisconnected_event_handler(device_id)
{
Log::message("\Handling VrDeviceDisconnected event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdevicedisconnected_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceDisconnected().connect(vrdevicedisconnected_event_connections, vrdevicedisconnected_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceDisconnected().connect(vrdevicedisconnected_event_connections, [](device_id) {
Log::message("\Handling VrDeviceDisconnected event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdevicedisconnected_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdevicedisconnected_event_connection;
// subscribe to the VrDeviceDisconnected event with a handler function keeping the connection
Input::getEventVrDeviceDisconnected().connect(vrdevicedisconnected_event_connection, vrdevicedisconnected_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdevicedisconnected_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdevicedisconnected_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceDisconnected event via the connection
vrdevicedisconnected_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceDisconnected event handler implemented as a class member
void event_handler(device_id)
{
Log::message("\Handling VrDeviceDisconnected event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceDisconnected().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceDisconnected event with a handler function
Input::getEventVrDeviceDisconnected().connect(vrdevicedisconnected_event_handler);
// remove subscription to the VrDeviceDisconnected event later by the handler function
Input::getEventVrDeviceDisconnected().disconnect(vrdevicedisconnected_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdevicedisconnected_handler_id;
// subscribe to the VrDeviceDisconnected event with a lambda handler function and keeping connection ID
vrdevicedisconnected_handler_id = Input::getEventVrDeviceDisconnected().connect([](device_id) {
Log::message("\Handling VrDeviceDisconnected event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceDisconnected().disconnect(vrdevicedisconnected_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceDisconnected events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceDisconnected().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceDisconnected().setEnabled(true);
Return value
Event reference.Event<int> getEventVrDeviceConnected() const#
Usage Example
// implement the VrDeviceConnected event handler
void vrdeviceconnected_event_handler(device_id)
{
Log::message("\Handling VrDeviceConnected event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections vrdeviceconnected_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventVrDeviceConnected().connect(vrdeviceconnected_event_connections, vrdeviceconnected_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventVrDeviceConnected().connect(vrdeviceconnected_event_connections, [](device_id) {
Log::message("\Handling VrDeviceConnected event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
vrdeviceconnected_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection vrdeviceconnected_event_connection;
// subscribe to the VrDeviceConnected event with a handler function keeping the connection
Input::getEventVrDeviceConnected().connect(vrdeviceconnected_event_connection, vrdeviceconnected_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
vrdeviceconnected_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
vrdeviceconnected_event_connection.setEnabled(true);
// ...
// remove subscription to the VrDeviceConnected event via the connection
vrdeviceconnected_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A VrDeviceConnected event handler implemented as a class member
void event_handler(device_id)
{
Log::message("\Handling VrDeviceConnected event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventVrDeviceConnected().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the VrDeviceConnected event with a handler function
Input::getEventVrDeviceConnected().connect(vrdeviceconnected_event_handler);
// remove subscription to the VrDeviceConnected event later by the handler function
Input::getEventVrDeviceConnected().disconnect(vrdeviceconnected_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId vrdeviceconnected_handler_id;
// subscribe to the VrDeviceConnected event with a lambda handler function and keeping connection ID
vrdeviceconnected_handler_id = Input::getEventVrDeviceConnected().connect([](device_id) {
Log::message("\Handling VrDeviceConnected event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventVrDeviceConnected().disconnect(vrdeviceconnected_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all VrDeviceConnected events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventVrDeviceConnected().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventVrDeviceConnected().setEnabled(true);
Return value
Event reference.Event<int, int, int> getEventGamepadTouchMotion() const#
Usage Example
// implement the GamepadTouchMotion event handler
void gamepadtouchmotion_event_handler(gamepad_id)
{
Log::message("\Handling GamepadTouchMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadtouchmotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadTouchMotion().connect(gamepadtouchmotion_event_connections, gamepadtouchmotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadTouchMotion().connect(gamepadtouchmotion_event_connections, [](gamepad_id) {
Log::message("\Handling GamepadTouchMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadtouchmotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadtouchmotion_event_connection;
// subscribe to the GamepadTouchMotion event with a handler function keeping the connection
Input::getEventGamepadTouchMotion().connect(gamepadtouchmotion_event_connection, gamepadtouchmotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadtouchmotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadtouchmotion_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadTouchMotion event via the connection
gamepadtouchmotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadTouchMotion event handler implemented as a class member
void event_handler(gamepad_id)
{
Log::message("\Handling GamepadTouchMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadTouchMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadTouchMotion event with a handler function
Input::getEventGamepadTouchMotion().connect(gamepadtouchmotion_event_handler);
// remove subscription to the GamepadTouchMotion event later by the handler function
Input::getEventGamepadTouchMotion().disconnect(gamepadtouchmotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadtouchmotion_handler_id;
// subscribe to the GamepadTouchMotion event with a lambda handler function and keeping connection ID
gamepadtouchmotion_handler_id = Input::getEventGamepadTouchMotion().connect([](gamepad_id) {
Log::message("\Handling GamepadTouchMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadTouchMotion().disconnect(gamepadtouchmotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadTouchMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadTouchMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadTouchMotion().setEnabled(true);
Return value
Event reference.Event<int, int, int> getEventGamepadTouchUp() const#
Usage Example
// implement the GamepadTouchUp event handler
void gamepadtouchup_event_handler(gamepad_id)
{
Log::message("\Handling GamepadTouchUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadtouchup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadTouchUp().connect(gamepadtouchup_event_connections, gamepadtouchup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadTouchUp().connect(gamepadtouchup_event_connections, [](gamepad_id) {
Log::message("\Handling GamepadTouchUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadtouchup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadtouchup_event_connection;
// subscribe to the GamepadTouchUp event with a handler function keeping the connection
Input::getEventGamepadTouchUp().connect(gamepadtouchup_event_connection, gamepadtouchup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadtouchup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadtouchup_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadTouchUp event via the connection
gamepadtouchup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadTouchUp event handler implemented as a class member
void event_handler(gamepad_id)
{
Log::message("\Handling GamepadTouchUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadTouchUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadTouchUp event with a handler function
Input::getEventGamepadTouchUp().connect(gamepadtouchup_event_handler);
// remove subscription to the GamepadTouchUp event later by the handler function
Input::getEventGamepadTouchUp().disconnect(gamepadtouchup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadtouchup_handler_id;
// subscribe to the GamepadTouchUp event with a lambda handler function and keeping connection ID
gamepadtouchup_handler_id = Input::getEventGamepadTouchUp().connect([](gamepad_id) {
Log::message("\Handling GamepadTouchUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadTouchUp().disconnect(gamepadtouchup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadTouchUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadTouchUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadTouchUp().setEnabled(true);
Return value
Event reference.Event<int, int, int> getEventGamepadTouchDown() const#
Usage Example
// implement the GamepadTouchDown event handler
void gamepadtouchdown_event_handler(gamepad_id)
{
Log::message("\Handling GamepadTouchDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadtouchdown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadTouchDown().connect(gamepadtouchdown_event_connections, gamepadtouchdown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadTouchDown().connect(gamepadtouchdown_event_connections, [](gamepad_id) {
Log::message("\Handling GamepadTouchDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadtouchdown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadtouchdown_event_connection;
// subscribe to the GamepadTouchDown event with a handler function keeping the connection
Input::getEventGamepadTouchDown().connect(gamepadtouchdown_event_connection, gamepadtouchdown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadtouchdown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadtouchdown_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadTouchDown event via the connection
gamepadtouchdown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadTouchDown event handler implemented as a class member
void event_handler(gamepad_id)
{
Log::message("\Handling GamepadTouchDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadTouchDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadTouchDown event with a handler function
Input::getEventGamepadTouchDown().connect(gamepadtouchdown_event_handler);
// remove subscription to the GamepadTouchDown event later by the handler function
Input::getEventGamepadTouchDown().disconnect(gamepadtouchdown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadtouchdown_handler_id;
// subscribe to the GamepadTouchDown event with a lambda handler function and keeping connection ID
gamepadtouchdown_handler_id = Input::getEventGamepadTouchDown().connect([](gamepad_id) {
Log::message("\Handling GamepadTouchDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadTouchDown().disconnect(gamepadtouchdown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadTouchDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadTouchDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadTouchDown().setEnabled(true);
Return value
Event reference.Event<int, Input::GAMEPAD_AXIS> getEventGamepadAxisMotion() const#
Usage Example
// implement the GamepadAxisMotion event handler
void gamepadaxismotion_event_handler(int gamepad_id, Input::GAMEPAD_AXIS axis)
{
Log::message("\Handling GamepadAxisMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadaxismotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadAxisMotion().connect(gamepadaxismotion_event_connections, gamepadaxismotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadAxisMotion().connect(gamepadaxismotion_event_connections, [](int gamepad_id, Input::GAMEPAD_AXIS axis) {
Log::message("\Handling GamepadAxisMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadaxismotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadaxismotion_event_connection;
// subscribe to the GamepadAxisMotion event with a handler function keeping the connection
Input::getEventGamepadAxisMotion().connect(gamepadaxismotion_event_connection, gamepadaxismotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadaxismotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadaxismotion_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadAxisMotion event via the connection
gamepadaxismotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadAxisMotion event handler implemented as a class member
void event_handler(int gamepad_id, Input::GAMEPAD_AXIS axis)
{
Log::message("\Handling GamepadAxisMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadAxisMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadAxisMotion event with a handler function
Input::getEventGamepadAxisMotion().connect(gamepadaxismotion_event_handler);
// remove subscription to the GamepadAxisMotion event later by the handler function
Input::getEventGamepadAxisMotion().disconnect(gamepadaxismotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadaxismotion_handler_id;
// subscribe to the GamepadAxisMotion event with a lambda handler function and keeping connection ID
gamepadaxismotion_handler_id = Input::getEventGamepadAxisMotion().connect([](int gamepad_id, Input::GAMEPAD_AXIS axis) {
Log::message("\Handling GamepadAxisMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadAxisMotion().disconnect(gamepadaxismotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadAxisMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadAxisMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadAxisMotion().setEnabled(true);
Return value
Event reference.Event<int, Input::GAMEPAD_BUTTON> getEventGamepadButtonUp() const#
Usage Example
// implement the GamepadButtonUp event handler
void gamepadbuttonup_event_handler(int gamepad_id, Input::GAMEPAD_BUTTON button)
{
Log::message("\Handling GamepadButtonUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadbuttonup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadButtonUp().connect(gamepadbuttonup_event_connections, gamepadbuttonup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadButtonUp().connect(gamepadbuttonup_event_connections, [](int gamepad_id, Input::GAMEPAD_BUTTON button) {
Log::message("\Handling GamepadButtonUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadbuttonup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadbuttonup_event_connection;
// subscribe to the GamepadButtonUp event with a handler function keeping the connection
Input::getEventGamepadButtonUp().connect(gamepadbuttonup_event_connection, gamepadbuttonup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadbuttonup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadbuttonup_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadButtonUp event via the connection
gamepadbuttonup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadButtonUp event handler implemented as a class member
void event_handler(int gamepad_id, Input::GAMEPAD_BUTTON button)
{
Log::message("\Handling GamepadButtonUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadButtonUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadButtonUp event with a handler function
Input::getEventGamepadButtonUp().connect(gamepadbuttonup_event_handler);
// remove subscription to the GamepadButtonUp event later by the handler function
Input::getEventGamepadButtonUp().disconnect(gamepadbuttonup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadbuttonup_handler_id;
// subscribe to the GamepadButtonUp event with a lambda handler function and keeping connection ID
gamepadbuttonup_handler_id = Input::getEventGamepadButtonUp().connect([](int gamepad_id, Input::GAMEPAD_BUTTON button) {
Log::message("\Handling GamepadButtonUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadButtonUp().disconnect(gamepadbuttonup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadButtonUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadButtonUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadButtonUp().setEnabled(true);
Return value
Event reference.Event<int, Input::GAMEPAD_BUTTON> getEventGamepadButtonDown() const#
Usage Example
// implement the GamepadButtonDown event handler
void gamepadbuttondown_event_handler(int gamepad_id, Input::GAMEPAD_BUTTON button)
{
Log::message("\Handling GamepadButtonDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadbuttondown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadButtonDown().connect(gamepadbuttondown_event_connections, gamepadbuttondown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadButtonDown().connect(gamepadbuttondown_event_connections, [](int gamepad_id, Input::GAMEPAD_BUTTON button) {
Log::message("\Handling GamepadButtonDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadbuttondown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadbuttondown_event_connection;
// subscribe to the GamepadButtonDown event with a handler function keeping the connection
Input::getEventGamepadButtonDown().connect(gamepadbuttondown_event_connection, gamepadbuttondown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadbuttondown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadbuttondown_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadButtonDown event via the connection
gamepadbuttondown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadButtonDown event handler implemented as a class member
void event_handler(int gamepad_id, Input::GAMEPAD_BUTTON button)
{
Log::message("\Handling GamepadButtonDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadButtonDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadButtonDown event with a handler function
Input::getEventGamepadButtonDown().connect(gamepadbuttondown_event_handler);
// remove subscription to the GamepadButtonDown event later by the handler function
Input::getEventGamepadButtonDown().disconnect(gamepadbuttondown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadbuttondown_handler_id;
// subscribe to the GamepadButtonDown event with a lambda handler function and keeping connection ID
gamepadbuttondown_handler_id = Input::getEventGamepadButtonDown().connect([](int gamepad_id, Input::GAMEPAD_BUTTON button) {
Log::message("\Handling GamepadButtonDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadButtonDown().disconnect(gamepadbuttondown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadButtonDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadButtonDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadButtonDown().setEnabled(true);
Return value
Event reference.Event<int> getEventGamepadDisconnected() const#
Usage Example
// implement the GamepadDisconnected event handler
void gamepaddisconnected_event_handler(gamepad_id)
{
Log::message("\Handling GamepadDisconnected event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepaddisconnected_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadDisconnected().connect(gamepaddisconnected_event_connections, gamepaddisconnected_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadDisconnected().connect(gamepaddisconnected_event_connections, [](gamepad_id) {
Log::message("\Handling GamepadDisconnected event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepaddisconnected_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepaddisconnected_event_connection;
// subscribe to the GamepadDisconnected event with a handler function keeping the connection
Input::getEventGamepadDisconnected().connect(gamepaddisconnected_event_connection, gamepaddisconnected_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepaddisconnected_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepaddisconnected_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadDisconnected event via the connection
gamepaddisconnected_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadDisconnected event handler implemented as a class member
void event_handler(gamepad_id)
{
Log::message("\Handling GamepadDisconnected event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadDisconnected().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadDisconnected event with a handler function
Input::getEventGamepadDisconnected().connect(gamepaddisconnected_event_handler);
// remove subscription to the GamepadDisconnected event later by the handler function
Input::getEventGamepadDisconnected().disconnect(gamepaddisconnected_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepaddisconnected_handler_id;
// subscribe to the GamepadDisconnected event with a lambda handler function and keeping connection ID
gamepaddisconnected_handler_id = Input::getEventGamepadDisconnected().connect([](gamepad_id) {
Log::message("\Handling GamepadDisconnected event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadDisconnected().disconnect(gamepaddisconnected_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadDisconnected events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadDisconnected().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadDisconnected().setEnabled(true);
Return value
Event reference.Event<int> getEventGamepadConnected() const#
Usage Example
// implement the GamepadConnected event handler
void gamepadconnected_event_handler(gamepad_id)
{
Log::message("\Handling GamepadConnected event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections gamepadconnected_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventGamepadConnected().connect(gamepadconnected_event_connections, gamepadconnected_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventGamepadConnected().connect(gamepadconnected_event_connections, [](gamepad_id) {
Log::message("\Handling GamepadConnected event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
gamepadconnected_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection gamepadconnected_event_connection;
// subscribe to the GamepadConnected event with a handler function keeping the connection
Input::getEventGamepadConnected().connect(gamepadconnected_event_connection, gamepadconnected_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
gamepadconnected_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
gamepadconnected_event_connection.setEnabled(true);
// ...
// remove subscription to the GamepadConnected event via the connection
gamepadconnected_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A GamepadConnected event handler implemented as a class member
void event_handler(gamepad_id)
{
Log::message("\Handling GamepadConnected event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventGamepadConnected().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the GamepadConnected event with a handler function
Input::getEventGamepadConnected().connect(gamepadconnected_event_handler);
// remove subscription to the GamepadConnected event later by the handler function
Input::getEventGamepadConnected().disconnect(gamepadconnected_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId gamepadconnected_handler_id;
// subscribe to the GamepadConnected event with a lambda handler function and keeping connection ID
gamepadconnected_handler_id = Input::getEventGamepadConnected().connect([](gamepad_id) {
Log::message("\Handling GamepadConnected event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventGamepadConnected().disconnect(gamepadconnected_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all GamepadConnected events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventGamepadConnected().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventGamepadConnected().setEnabled(true);
Return value
Event reference.Event<int> getEventTouchMotion() const#
Usage Example
// implement the TouchMotion event handler
void touchmotion_event_handler(touch_id)
{
Log::message("\Handling TouchMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections touchmotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventTouchMotion().connect(touchmotion_event_connections, touchmotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventTouchMotion().connect(touchmotion_event_connections, [](touch_id) {
Log::message("\Handling TouchMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
touchmotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection touchmotion_event_connection;
// subscribe to the TouchMotion event with a handler function keeping the connection
Input::getEventTouchMotion().connect(touchmotion_event_connection, touchmotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
touchmotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
touchmotion_event_connection.setEnabled(true);
// ...
// remove subscription to the TouchMotion event via the connection
touchmotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A TouchMotion event handler implemented as a class member
void event_handler(touch_id)
{
Log::message("\Handling TouchMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventTouchMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the TouchMotion event with a handler function
Input::getEventTouchMotion().connect(touchmotion_event_handler);
// remove subscription to the TouchMotion event later by the handler function
Input::getEventTouchMotion().disconnect(touchmotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId touchmotion_handler_id;
// subscribe to the TouchMotion event with a lambda handler function and keeping connection ID
touchmotion_handler_id = Input::getEventTouchMotion().connect([](touch_id) {
Log::message("\Handling TouchMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventTouchMotion().disconnect(touchmotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all TouchMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventTouchMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventTouchMotion().setEnabled(true);
Return value
Event reference.Event<int> getEventTouchUp() const#
Usage Example
// implement the TouchUp event handler
void touchup_event_handler(touch_id)
{
Log::message("\Handling TouchUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections touchup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventTouchUp().connect(touchup_event_connections, touchup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventTouchUp().connect(touchup_event_connections, [](touch_id) {
Log::message("\Handling TouchUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
touchup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection touchup_event_connection;
// subscribe to the TouchUp event with a handler function keeping the connection
Input::getEventTouchUp().connect(touchup_event_connection, touchup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
touchup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
touchup_event_connection.setEnabled(true);
// ...
// remove subscription to the TouchUp event via the connection
touchup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A TouchUp event handler implemented as a class member
void event_handler(touch_id)
{
Log::message("\Handling TouchUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventTouchUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the TouchUp event with a handler function
Input::getEventTouchUp().connect(touchup_event_handler);
// remove subscription to the TouchUp event later by the handler function
Input::getEventTouchUp().disconnect(touchup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId touchup_handler_id;
// subscribe to the TouchUp event with a lambda handler function and keeping connection ID
touchup_handler_id = Input::getEventTouchUp().connect([](touch_id) {
Log::message("\Handling TouchUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventTouchUp().disconnect(touchup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all TouchUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventTouchUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventTouchUp().setEnabled(true);
Return value
Event reference.Event<int> getEventTouchDown() const#
Usage Example
// implement the TouchDown event handler
void touchdown_event_handler(touch_id)
{
Log::message("\Handling TouchDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections touchdown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventTouchDown().connect(touchdown_event_connections, touchdown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventTouchDown().connect(touchdown_event_connections, [](touch_id) {
Log::message("\Handling TouchDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
touchdown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection touchdown_event_connection;
// subscribe to the TouchDown event with a handler function keeping the connection
Input::getEventTouchDown().connect(touchdown_event_connection, touchdown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
touchdown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
touchdown_event_connection.setEnabled(true);
// ...
// remove subscription to the TouchDown event via the connection
touchdown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A TouchDown event handler implemented as a class member
void event_handler(touch_id)
{
Log::message("\Handling TouchDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventTouchDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the TouchDown event with a handler function
Input::getEventTouchDown().connect(touchdown_event_handler);
// remove subscription to the TouchDown event later by the handler function
Input::getEventTouchDown().disconnect(touchdown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId touchdown_handler_id;
// subscribe to the TouchDown event with a lambda handler function and keeping connection ID
touchdown_handler_id = Input::getEventTouchDown().connect([](touch_id) {
Log::message("\Handling TouchDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventTouchDown().disconnect(touchdown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all TouchDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventTouchDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventTouchDown().setEnabled(true);
Return value
Event reference.Event<unsigned int> getEventTextPress() const#
Usage Example
// implement the TextPress event handler
void textpress_event_handler(unsigned int unicode)
{
Log::message("\Handling TextPress event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections textpress_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventTextPress().connect(textpress_event_connections, textpress_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventTextPress().connect(textpress_event_connections, [](unsigned int unicode) {
Log::message("\Handling TextPress event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
textpress_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection textpress_event_connection;
// subscribe to the TextPress event with a handler function keeping the connection
Input::getEventTextPress().connect(textpress_event_connection, textpress_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
textpress_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
textpress_event_connection.setEnabled(true);
// ...
// remove subscription to the TextPress event via the connection
textpress_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A TextPress event handler implemented as a class member
void event_handler(unsigned int unicode)
{
Log::message("\Handling TextPress event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventTextPress().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the TextPress event with a handler function
Input::getEventTextPress().connect(textpress_event_handler);
// remove subscription to the TextPress event later by the handler function
Input::getEventTextPress().disconnect(textpress_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId textpress_handler_id;
// subscribe to the TextPress event with a lambda handler function and keeping connection ID
textpress_handler_id = Input::getEventTextPress().connect([](unsigned int unicode) {
Log::message("\Handling TextPress event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventTextPress().disconnect(textpress_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all TextPress events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventTextPress().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventTextPress().setEnabled(true);
Return value
Event reference.Event<unsigned int> getEventKeyRepeat() const#
Usage Example
// implement the KeyRepeat event handler
void keyrepeat_event_handler(unsigned int unicode)
{
Log::message("\Handling KeyRepeat event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections keyrepeat_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventKeyRepeat().connect(keyrepeat_event_connections, keyrepeat_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventKeyRepeat().connect(keyrepeat_event_connections, [](unsigned int unicode) {
Log::message("\Handling KeyRepeat event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
keyrepeat_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection keyrepeat_event_connection;
// subscribe to the KeyRepeat event with a handler function keeping the connection
Input::getEventKeyRepeat().connect(keyrepeat_event_connection, keyrepeat_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
keyrepeat_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
keyrepeat_event_connection.setEnabled(true);
// ...
// remove subscription to the KeyRepeat event via the connection
keyrepeat_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A KeyRepeat event handler implemented as a class member
void event_handler(unsigned int unicode)
{
Log::message("\Handling KeyRepeat event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventKeyRepeat().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the KeyRepeat event with a handler function
Input::getEventKeyRepeat().connect(keyrepeat_event_handler);
// remove subscription to the KeyRepeat event later by the handler function
Input::getEventKeyRepeat().disconnect(keyrepeat_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId keyrepeat_handler_id;
// subscribe to the KeyRepeat event with a lambda handler function and keeping connection ID
keyrepeat_handler_id = Input::getEventKeyRepeat().connect([](unsigned int unicode) {
Log::message("\Handling KeyRepeat event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventKeyRepeat().disconnect(keyrepeat_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all KeyRepeat events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventKeyRepeat().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventKeyRepeat().setEnabled(true);
Return value
Event reference.Event<Input::KEY> getEventKeyUp() const#
Usage Example
// implement the KeyUp event handler
void keyup_event_handler(Input::KEY key)
{
Log::message("\Handling KeyUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections keyup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventKeyUp().connect(keyup_event_connections, keyup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventKeyUp().connect(keyup_event_connections, [](Input::KEY key) {
Log::message("\Handling KeyUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
keyup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection keyup_event_connection;
// subscribe to the KeyUp event with a handler function keeping the connection
Input::getEventKeyUp().connect(keyup_event_connection, keyup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
keyup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
keyup_event_connection.setEnabled(true);
// ...
// remove subscription to the KeyUp event via the connection
keyup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A KeyUp event handler implemented as a class member
void event_handler(Input::KEY key)
{
Log::message("\Handling KeyUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventKeyUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the KeyUp event with a handler function
Input::getEventKeyUp().connect(keyup_event_handler);
// remove subscription to the KeyUp event later by the handler function
Input::getEventKeyUp().disconnect(keyup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId keyup_handler_id;
// subscribe to the KeyUp event with a lambda handler function and keeping connection ID
keyup_handler_id = Input::getEventKeyUp().connect([](Input::KEY key) {
Log::message("\Handling KeyUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventKeyUp().disconnect(keyup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all KeyUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventKeyUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventKeyUp().setEnabled(true);
Return value
Event reference.Event<Input::KEY> getEventKeyDown() const#
Usage Example
// implement the KeyDown event handler
void keydown_event_handler(Input::KEY key)
{
Log::message("\Handling KeyDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections keydown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventKeyDown().connect(keydown_event_connections, keydown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventKeyDown().connect(keydown_event_connections, [](Input::KEY key) {
Log::message("\Handling KeyDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
keydown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection keydown_event_connection;
// subscribe to the KeyDown event with a handler function keeping the connection
Input::getEventKeyDown().connect(keydown_event_connection, keydown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
keydown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
keydown_event_connection.setEnabled(true);
// ...
// remove subscription to the KeyDown event via the connection
keydown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A KeyDown event handler implemented as a class member
void event_handler(Input::KEY key)
{
Log::message("\Handling KeyDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventKeyDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the KeyDown event with a handler function
Input::getEventKeyDown().connect(keydown_event_handler);
// remove subscription to the KeyDown event later by the handler function
Input::getEventKeyDown().disconnect(keydown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId keydown_handler_id;
// subscribe to the KeyDown event with a lambda handler function and keeping connection ID
keydown_handler_id = Input::getEventKeyDown().connect([](Input::KEY key) {
Log::message("\Handling KeyDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventKeyDown().disconnect(keydown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all KeyDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventKeyDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventKeyDown().setEnabled(true);
Return value
Event reference.Event<int, int> getEventMouseMotion() const#
Usage Example
// implement the MouseMotion event handler
void mousemotion_event_handler(coord_x)
{
Log::message("\Handling MouseMotion event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mousemotion_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventMouseMotion().connect(mousemotion_event_connections, mousemotion_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventMouseMotion().connect(mousemotion_event_connections, [](coord_x) {
Log::message("\Handling MouseMotion event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mousemotion_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mousemotion_event_connection;
// subscribe to the MouseMotion event with a handler function keeping the connection
Input::getEventMouseMotion().connect(mousemotion_event_connection, mousemotion_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mousemotion_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mousemotion_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseMotion event via the connection
mousemotion_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseMotion event handler implemented as a class member
void event_handler(coord_x)
{
Log::message("\Handling MouseMotion event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventMouseMotion().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the MouseMotion event with a handler function
Input::getEventMouseMotion().connect(mousemotion_event_handler);
// remove subscription to the MouseMotion event later by the handler function
Input::getEventMouseMotion().disconnect(mousemotion_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId mousemotion_handler_id;
// subscribe to the MouseMotion event with a lambda handler function and keeping connection ID
mousemotion_handler_id = Input::getEventMouseMotion().connect([](coord_x) {
Log::message("\Handling MouseMotion event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventMouseMotion().disconnect(mousemotion_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all MouseMotion events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventMouseMotion().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventMouseMotion().setEnabled(true);
Return value
Event reference.Event<int> getEventMouseWheelHorizontal() const#
Usage Example
// implement the MouseWheelHorizontal event handler
void mousewheelhorizontal_event_handler(delta_horizontal)
{
Log::message("\Handling MouseWheelHorizontal event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mousewheelhorizontal_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventMouseWheelHorizontal().connect(mousewheelhorizontal_event_connections, mousewheelhorizontal_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventMouseWheelHorizontal().connect(mousewheelhorizontal_event_connections, [](delta_horizontal) {
Log::message("\Handling MouseWheelHorizontal event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mousewheelhorizontal_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mousewheelhorizontal_event_connection;
// subscribe to the MouseWheelHorizontal event with a handler function keeping the connection
Input::getEventMouseWheelHorizontal().connect(mousewheelhorizontal_event_connection, mousewheelhorizontal_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mousewheelhorizontal_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mousewheelhorizontal_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseWheelHorizontal event via the connection
mousewheelhorizontal_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseWheelHorizontal event handler implemented as a class member
void event_handler(delta_horizontal)
{
Log::message("\Handling MouseWheelHorizontal event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventMouseWheelHorizontal().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the MouseWheelHorizontal event with a handler function
Input::getEventMouseWheelHorizontal().connect(mousewheelhorizontal_event_handler);
// remove subscription to the MouseWheelHorizontal event later by the handler function
Input::getEventMouseWheelHorizontal().disconnect(mousewheelhorizontal_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId mousewheelhorizontal_handler_id;
// subscribe to the MouseWheelHorizontal event with a lambda handler function and keeping connection ID
mousewheelhorizontal_handler_id = Input::getEventMouseWheelHorizontal().connect([](delta_horizontal) {
Log::message("\Handling MouseWheelHorizontal event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventMouseWheelHorizontal().disconnect(mousewheelhorizontal_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all MouseWheelHorizontal events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventMouseWheelHorizontal().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventMouseWheelHorizontal().setEnabled(true);
Return value
Event reference.Event<int> getEventMouseWheel() const#
Usage Example
// implement the MouseWheel event handler
void mousewheel_event_handler(delta_vertical)
{
Log::message("\Handling MouseWheel event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mousewheel_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventMouseWheel().connect(mousewheel_event_connections, mousewheel_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventMouseWheel().connect(mousewheel_event_connections, [](delta_vertical) {
Log::message("\Handling MouseWheel event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mousewheel_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mousewheel_event_connection;
// subscribe to the MouseWheel event with a handler function keeping the connection
Input::getEventMouseWheel().connect(mousewheel_event_connection, mousewheel_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mousewheel_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mousewheel_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseWheel event via the connection
mousewheel_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseWheel event handler implemented as a class member
void event_handler(delta_vertical)
{
Log::message("\Handling MouseWheel event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventMouseWheel().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the MouseWheel event with a handler function
Input::getEventMouseWheel().connect(mousewheel_event_handler);
// remove subscription to the MouseWheel event later by the handler function
Input::getEventMouseWheel().disconnect(mousewheel_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId mousewheel_handler_id;
// subscribe to the MouseWheel event with a lambda handler function and keeping connection ID
mousewheel_handler_id = Input::getEventMouseWheel().connect([](delta_vertical) {
Log::message("\Handling MouseWheel event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventMouseWheel().disconnect(mousewheel_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all MouseWheel events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventMouseWheel().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventMouseWheel().setEnabled(true);
Return value
Event reference.Event<Input::MOUSE_BUTTON> getEventMouseUp() const#
Usage Example
// implement the MouseUp event handler
void mouseup_event_handler(Input::MOUSE_BUTTON button)
{
Log::message("\Handling MouseUp event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mouseup_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventMouseUp().connect(mouseup_event_connections, mouseup_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventMouseUp().connect(mouseup_event_connections, [](Input::MOUSE_BUTTON button) {
Log::message("\Handling MouseUp event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mouseup_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mouseup_event_connection;
// subscribe to the MouseUp event with a handler function keeping the connection
Input::getEventMouseUp().connect(mouseup_event_connection, mouseup_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mouseup_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mouseup_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseUp event via the connection
mouseup_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseUp event handler implemented as a class member
void event_handler(Input::MOUSE_BUTTON button)
{
Log::message("\Handling MouseUp event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventMouseUp().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the MouseUp event with a handler function
Input::getEventMouseUp().connect(mouseup_event_handler);
// remove subscription to the MouseUp event later by the handler function
Input::getEventMouseUp().disconnect(mouseup_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId mouseup_handler_id;
// subscribe to the MouseUp event with a lambda handler function and keeping connection ID
mouseup_handler_id = Input::getEventMouseUp().connect([](Input::MOUSE_BUTTON button) {
Log::message("\Handling MouseUp event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventMouseUp().disconnect(mouseup_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all MouseUp events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventMouseUp().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventMouseUp().setEnabled(true);
Return value
Event reference.Event<Input::MOUSE_BUTTON> getEventMouseDown() const#
Usage Example
// implement the MouseDown event handler
void mousedown_event_handler(Input::MOUSE_BUTTON button)
{
Log::message("\Handling MouseDown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mousedown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
Input::getEventMouseDown().connect(mousedown_event_connections, mousedown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Input::getEventMouseDown().connect(mousedown_event_connections, [](Input::MOUSE_BUTTON button) {
Log::message("\Handling MouseDown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mousedown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mousedown_event_connection;
// subscribe to the MouseDown event with a handler function keeping the connection
Input::getEventMouseDown().connect(mousedown_event_connection, mousedown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mousedown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mousedown_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseDown event via the connection
mousedown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseDown event handler implemented as a class member
void event_handler(Input::MOUSE_BUTTON button)
{
Log::message("\Handling MouseDown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
Input::getEventMouseDown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the MouseDown event with a handler function
Input::getEventMouseDown().connect(mousedown_event_handler);
// remove subscription to the MouseDown event later by the handler function
Input::getEventMouseDown().disconnect(mousedown_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// define a connection ID to be used to unsubscribe later
EventConnectionId mousedown_handler_id;
// subscribe to the MouseDown event with a lambda handler function and keeping connection ID
mousedown_handler_id = Input::getEventMouseDown().connect([](Input::MOUSE_BUTTON button) {
Log::message("\Handling MouseDown event (lambda).\n");
}
);
// remove the subscription later using the ID
Input::getEventMouseDown().disconnect(mousedown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 6. Ignoring all MouseDown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Input::getEventMouseDown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
Input::getEventMouseDown().setEnabled(true);
Return value
Event reference.Math::ivec2 getMousePosition ( ) const#
Returns a vector containing the global coordinates of the mouse cursor. In case of a mouse button event, the cursor position at the moment of the processed event is returned. In case of no such event, the mouse position at the beginning of the frame is returned. To get the cursor position during another type of event, get this event (for example getKeyEvent()) and get the cursor position stored inside it.Return value
Global coordinates of the cursor.Math::ivec2 getMouseDeltaPosition ( ) const#
Returns a vector containing screen position change of the mouse pointer along the X and Y axes — the difference between the values in the previous and the current frames.Return value
Float mouse pointer position delta.int getMouseWheel ( ) const#
Returns the current mouse scroll value. Negative values correspond to scrolling downwards; positive values correspond to scrolling upwards; the value is zero when the mouse wheel is not scrolled.Return value
Mouse scroll value in the [-1;1] range.int getMouseWheelHorizontal ( ) const#
Returns the current horizontal mouse scroll value.Return value
Horizontal mouse scroll value in the [-1;1] range.void setMouseGrab ( bool grab ) #
Sets the value indicating if the mouse pointer is bound to the application window.Arguments
- bool grab - 1 if the mouse cannot leave the application window; otherwise, 0.
bool isMouseGrab ( ) const#
Returns the value indicating if the mouse pointer is bound to the application window.Return value
true if the mouse cannot leave the application window; otherwise, false.int getNumGamePads ( ) const#
Returns the total number of all gamepads.Return value
Number of all gamepads.Ptr<InputGamePad> getGamePad ( int num ) const#
Returns a gamepad of the given index.Arguments
- int num - Gamepad index.
Return value
InputGamepad object.int getNumJoysticks ( ) const#
Returns the total number of all joysticks.Return value
Number of all joysticks.Ptr<InputJoystick> getJoystick ( int num ) const#
Returns a joystick with the given index.Arguments
- int num - Joystick index.
Return value
InputJoystick object.bool isKeyPressed ( Input::KEY key ) const#
Returns a value indicating if the given key is pressed. Check this value to perform continuous actions.if (Input::isKeyPressed(Input::KEY_ENTER)) {
Log::message("the Enter key is held down\n");
}
Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
true if the key is pressed; otherwise, false.bool isKeyDown ( Input::KEY key ) const#
Returns a value indicating if the given key was pressed during the current frame. Check this value to perform one-time actions on pressing a key.if (Input::isKeyDown(Input::KEY_SPACE)) {
Log::message("the Space key was pressed\n");
}
Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
1 during the first frame when the key was pressed, 0 for the following ones until it is released and pressed again.bool isKeyUp ( Input::KEY key ) const#
Returns a value indicating if the given key was released during the current frame. Check this value to perform one-time actions on releasing a key.if (Input::isKeyUp(Input::KEY_F)) {
Log::message("the F key was released\n");
}
Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
true during the first frame when the key was released; otherwise, false.bool isMouseButtonPressed ( Input::MOUSE_BUTTON button ) const#
Returns a value indicating if the given mouse button is pressed. Check this value to perform continuous actions.if (Input::isMouseButtonPressed(Input::MOUSE_BUTTON_LEFT)) {
Log::message("the left mouse button is held down\n");
}
Arguments
- Input::MOUSE_BUTTON button - One of the preset MOUSE_BUTTON_ codes.
Return value
1 if the mouse button is pressed; otherwise, 0.bool isMouseButtonDown ( Input::MOUSE_BUTTON button ) const#
Returns a value indicating if the given mouse button was pressed during the current frame. Check this value to perform one-time actions on pressing a mouse button.if (Input::isMouseButtonDown(Input::MOUSE_BUTTON_LEFT)) {
Log::message("the left mouse button was pressed\n");
}
Arguments
- Input::MOUSE_BUTTON button - One of the preset MOUSE_BUTTON_ codes.
Return value
1 during the first frame when the mouse button was released; otherwise, 0.bool isMouseButtonUp ( Input::MOUSE_BUTTON button ) const#
Returns a value indicating if the given mouse button was released during the current frame. Check this value to perform one-time actions on releasing a mouse button.if (Input::isMouseButtonUp(Input::MOUSE_BUTTON_LEFT)) {
Log::message("the left mouse button was released\n");
}
Arguments
- Input::MOUSE_BUTTON button - One of the preset MOUSE_BUTTON_ codes.
Return value
1 during the first frame when the mouse button was released; otherwise, 0.void setMouseHandle ( Input::MOUSE_HANDLE handle ) #
Sets the mouse behavior mode.Arguments
- Input::MOUSE_HANDLE handle - Mouse behavior mode, one of the MOUSE_HANDLE_* values.
Input::MOUSE_HANDLE getMouseHandle ( ) const#
Returns the mouse behavior mode.Return value
Mouse behavior mode, one of the MOUSE_HANDLE_* values.bool isTouchPressed ( int index ) const#
Returns a value indicating if the touchscreen is pressed by the finger.Arguments
- int index - Touch input index.
Return value
true if the touchscreen is pressed; otherwise, false.bool isTouchDown ( int index ) const#
Returns a value indicating if the given touch was pressed during the current frame.Arguments
- int index - Touch input index.
Return value
true if the touchscreen is pressed during the current frame; otherwise, false.bool isTouchUp ( int index ) const#
Returns a value indicating if the given touch was released.Arguments
- int index - Touch input index.
Return value
true during the first frame when the touch was released; otherwise, false.Math::ivec2 getTouchPosition ( int index ) const#
Returns a vector containing integer values of touch position.Arguments
- int index - Touch input index.
Return value
The touch position.Math::ivec2 getTouchDelta ( int index ) const#
Returns a vector containing screen position change of the touch along the X and Y axes — the difference between the values in the previous and the current frames.Arguments
- int index - Touch input index.
Return value
The touch position delta.Ptr<InputEventTouch> getTouchEvent ( int index ) #
Returns the action cast to the touch event.Arguments
- int index - Touch input index.
Return value
Touch input event.int getTouchEvents ( int index, Vector<Ptr<InputEventTouch>> & OUT_events ) #
Returns the actions cast to the touch event.Arguments
- int index - Touch input index.
- Vector<Ptr<InputEventTouch>> & OUT_events - The buffer with touch input events.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
Number of touch input events.Ptr<InputEventKeyboard> getKeyEvent ( Input::KEY key ) #
Returns the currently processed keyboard input event.Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
Keyboard input event, or nullptr if there are no events for the specified key in the current frame.int getKeyEvents ( Input::KEY key, Vector<Ptr<InputEventKeyboard>> & OUT_events ) #
Returns the buffer with events for the specified key.Arguments
- Input::KEY key - One of the preset KEY_ codes.
- Vector<Ptr<InputEventKeyboard>> & OUT_events - The buffer with input events.This output buffer is to be filled by the Engine as a result of executing the method.
const char * getKeyName ( Input::KEY key ) const#
Returns the specified key name.Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
Key name.Input::KEY getKeyByName ( const char * name ) const#
Returns the key by its name.Arguments
- const char * name - Key name.
Return value
One of the preset KEY_ codes.Ptr<InputEventMouseButton> getMouseButtonEvent ( Input::MOUSE_BUTTON button ) #
Returns the mouse motion input event for the specified button.Arguments
- Input::MOUSE_BUTTON button - One of the preset MOUSE_BUTTON_ codes.
Return value
Mouse motion input event.const char * getMouseButtonName ( Input::MOUSE_BUTTON button ) const#
Returns the mouse button name.Arguments
- Input::MOUSE_BUTTON button - One of the preset MOUSE_BUTTON_ codes.
Return value
Mouse button name.Input::MOUSE_BUTTON getMouseButtonByName ( const char * name ) const#
Returns the mouse button by its name.Arguments
- const char * name - Mouse button name.
Return value
One of the preset MOUSE_BUTTON_ codes.int getEventsBuffer ( int frame, Vector<Ptr<InputEvent>> & OUT_events ) const#
Returns the buffer with the input events for the specified frame.Arguments
- int frame - Number of frame for which the buffer of input events is to be obtained. Input events are stored for the last 60 frames. 0 is the current frame, 1 is the previous frame, etc.
- Vector<Ptr<InputEvent>> & OUT_events - The buffer with input events.This output buffer is to be filled by the Engine as a result of executing the method.
void sendEvent ( const Ptr<InputEvent> & e ) #
Creates a user event and dispatches it to the Engine.Arguments
- const Ptr<InputEvent> & e - Input event.
void setEventsFilter ( int (*)(const Ptr<InputEvent> &) func ) #
Sets a callback function to be executed on receiving input events. This input event filter enables you to reject certain input events for the Engine and get necessary information on all input events.Arguments
- int (*)(const Ptr<InputEvent> &) func - Input event callback.
bool isModifierEnabled ( Input::MODIFIER modifier ) const#
Returns the value indicating if the specified modifier is enabled.Arguments
- Input::MODIFIER modifier - One of the preset MODIFIER_ codes.
Return value
true if the modifier is enabled; otherwise, false.unsigned int keyToUnicode ( Input::KEY key ) const#
Returns the specified key transformed to unicode.Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
Unicode symbol.Input::KEY unicodeToKey ( unsigned int unicode ) const#
Returns the specified key transformed to unicode.Arguments
- unsigned int unicode - Unicode symbol.
Return value
One of the preset KEY_ codes.Math::ivec2 getMouseDeltaRaw ( ) const#
Returns the physical change in the absolute mouse position (not the screen cursor).Return value
The change in the absolute mouse position, dots per inch.bool isEmptyClipboard ( ) const#
Returns a value indicating if the clipboard is empty.Return value
true if the clipboard is empty; otherwise, false.void setClipboard ( const char * clipboard ) #
Updates the contents of the system clipboard.Arguments
- const char * clipboard - Contents to set.
const char * getClipboard ( ) const#
Retrieves the contents of the system clipboard.Return value
Contents of the system clipboard.void setMouseCursorHide ( bool hide ) #
Sets a value indicating if the mouse cursor should be hidden. Can be used, for example, to hide mouse cursor for a certain element.Arguments
- bool hide - true to hide the mouse cursor for a single frame, false - to show it.
bool isMouseCursorHide ( ) const#
Returns a value indicating if the mouse cursor is hidden in the current frame.Return value
true if mouse cursor is hidden in the current frame, false - to show it.void setMouseCursorSystem ( bool system ) #
Sets a value indicating if the OS mouse pointer should be displayed.Arguments
- bool system - true to display the OS mouse pointer; otherwise, false.
bool isMouseCursorSystem ( ) const#
Returns a value indicating if the OS mouse pointer is displayed.Return value
true if the OS mouse pointer is displayed; otherwise, false.void setMouseCursorNeedUpdate ( bool update ) #
Sets a value indicating that some changes were made to the cursor (e.g., it was shown, hidden, changed to system, etc.) and it has to be updated. Suppose the cursor was modified, for example, by the Interface plugin. After closing the plugin's window the cursor shall not return to its previous state because SDL doesn't even know about the changes. You can use this flag to signalize, that mouse cursor must be updated.Arguments
- bool update - true to signalize that the mouse cursor has to be updated; otherwise, false.
bool isMouseCursorNeedUpdate ( ) const#
Returns a value indicating that changes were made to the cursor (e.g., it was shown, hidden, changed to system, etc.) and it has to be updated. Suppose the cursor was modified, for example, by the Interface plugin. After closing the plugin's window the cursor shall not return to its previous state because SDL doesn't even know about the changes. You can use this flag to signalize, that mouse cursor must be updated.Return value
true if the mouse cursor has to be updated; otherwise, false.void setMouseCursorSkinCustom ( const Ptr<Image> & image ) #
Sets a custom image to be used for the mouse cursor.Arguments
- const Ptr<Image> & image - Image containing pointer shapes to be set for the mouse cursor (e.g., select, move, resize, etc.).
void setMouseCursorSkinSystem ( ) #
Sets the current OS cursor skin (pointer shapes like select, move, resize, etc.).void setMouseCursorSkinDefault ( ) #
Sets the default Engine cursor skin (pointer shapes like select, move, resize, etc.).void setMouseCursorCustom ( const Ptr<Image> & image, int x = 0, int y = 0 ) #
Sets a custom image for the OS mouse cursor. The image must be of the square size and RGBA8 format.// create an instance of the Image class
ImagePtr cursor = Image::create("textures/my_cursor.png");
// set the image as the mouse cursor
Input::setMouseCursorCustom(cursor);
// show the OS mouse pointer
Input::setMouseCursorSystem(1);
Arguments
- const Ptr<Image> & image - Cursor image to be set.
- int x - X coordinate of the cursor's hot spot.
- int y - Y coordinate of the cursor's hot spot.
void clearMouseCursorCustom ( ) #
Clears the custom mouse cursor set via the setMouseCursorCustom() method.void updateMouseCursor ( ) #
Updates the mouse cursor. This method should be called after making changes to the mouse cursor to apply them all together. After calling this method the cursor shall be updated in the next frame.const char * getKeyLocalName ( Input::KEY key ) const#
Returns the name for the specified key taken from the currently selected keyboard layout.Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
Localized name for the specified key.int getMouseButtonEvents ( Input::MOUSE_BUTTON button, Vector<Ptr<InputEventMouseButton>> & OUT_events ) #
Returns the number of input events for the specified mouse button and puts the events to the specified output buffer.Arguments
- Input::MOUSE_BUTTON button - One of the preset MOUSE_BUTTON_ codes.
- Vector<Ptr<InputEventMouseButton>> & OUT_events - Buffer with input events.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
Number of input events for the specified mouse button.Math::ivec2 getForceMousePosition ( ) #
Returns the absolute mouse position obtained from the OS.Return value
The absolute mouse position.bool isKeyText ( Input::KEY key ) const#
Returns a value indicating if the given key has a corresponding printable symbol (current Num Lock state is taken into account). For example, pressing 2 on the numpad with Num Lock enabled produces "2", while with disabled Num Lock the same key acts as a down arrow. Keys like Esc, PrintScreen, BackSpace do not produce any printable symbol at all.Arguments
- Input::KEY key - One of the preset KEY_ codes.
Return value
true if the key value is a symbol; otherwise, false.const char * getModifierName ( Input::MODIFIER modifier ) const#
Returns the name of the key modifier by its scancode.Arguments
- Input::MODIFIER modifier - Scancode of the modifier.
Return value
Key name of the modifier.Input::MODIFIER getModifierByName ( const char * name ) const#
Returns the scancode of the key modifier by its name.Arguments
- const char * name - Key name of the modifier.
Return value
Scancode of the modifier.int getNumVRDevices ( ) const#
Returns the total number of all VR devices.Return value
Number of all VR devices.Ptr<InputVRDevice> getVRDevice ( int num ) const#
Returns the VR device by its number.Arguments
- int num - Number of the VR device.