GL Studio C++ Runtime API
standard_input_handler.h
Go to the documentation of this file.
1/// \file standard_input_handler.h
2/// \brief Standard implementation of InputHandler
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2026 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef INCLUDED_STANDARD_INPUT_HANDLER_H
40#define INCLUDED_STANDARD_INPUT_HANDLER_H
41
42#include "gls_include.h"
43#include "input_handler.h"
44
45#include <vector>
46
47namespace disti
48{
49class DisplayFrame;
50
51/// Standard implementation of InputHandler that provides:
52/// - Global keyboard and mouse handler registration
53/// - Default event handling via DisplayFrame::HandleDisplayEvent
55{
56public:
57 /// Constructor
58 /// \param displayFrame The DisplayFrame this handler is attached to
59 GLS_EXPORT explicit StandardInputHandler( DisplayFrame* displayFrame );
60
61 /// Destructor
63
64 /// Handle the event
65 /// \param ev The event to handle
66 /// \return The object that handled the event, or NULL if no object handled the event
68
69 /// Register a global keyboard handler
70 /// \param callback The callback to call when a keyboard event occurs (ownership transferred)
71 /// \return Unique ID for unregistering
73
74 /// Register a global mouse handler
75 /// \param callback The callback to call when a mouse event occurs (ownership transferred)
76 /// \return Unique ID for unregistering
78
79 /// Unregister a global keyboard handler
80 /// \param id The unique identifier returned from RegisterGlobalKeyboardHandler
82
83 /// Unregister a global mouse handler
84 /// \param id The unique identifier returned from RegisterGlobalMouseHandler
86
87protected:
88 typedef std::vector<std::pair<ID, KeyboardCallbackBase*>> KeyboardHandlerList; ///< Registered keyboard callbacks paired with their unique IDs.
89 typedef std::vector<std::pair<ID, MouseCallbackBase*>> MouseHandlerList; ///< Registered mouse callbacks paired with their unique IDs.
90
91 DisplayFrame* _displayFrame; ///< The display frame that events are routed through.
92 ID _nextID; ///< The ID that will be handed out to the next registered handler.
93 KeyboardHandlerList _globalKeyboardHandlers; ///< The registered global keyboard handlers.
94 MouseHandlerList _globalMouseHandlers; ///< The registered global mouse handlers.
95};
96
97} // namespace disti
98
99#endif
Definition: events.h:111
Definition: display_frame.h:86
Definition: display.h:95
Definition: input_handler.h:185
unsigned int ID
Type for unique identifiers.
Definition: input_handler.h:188
Definition: input_handler.h:55
Definition: input_handler.h:120
Definition: standard_input_handler.h:55
MouseHandlerList _globalMouseHandlers
The registered global mouse handlers.
Definition: standard_input_handler.h:94
std::vector< std::pair< ID, KeyboardCallbackBase * > > KeyboardHandlerList
Registered keyboard callbacks paired with their unique IDs.
Definition: standard_input_handler.h:88
virtual ~StandardInputHandler()
Destructor.
KeyboardHandlerList _globalKeyboardHandlers
The registered global keyboard handlers.
Definition: standard_input_handler.h:93
std::vector< std::pair< ID, MouseCallbackBase * > > MouseHandlerList
Registered mouse callbacks paired with their unique IDs.
Definition: standard_input_handler.h:89
DisplayObject * HandleInput(DisplayEvent *ev) override
DisplayFrame * _displayFrame
The display frame that events are routed through.
Definition: standard_input_handler.h:91
ID _nextID
The ID that will be handed out to the next registered handler.
Definition: standard_input_handler.h:92
void UnregisterGlobalMouseHandler(ID id) override
void UnregisterGlobalKeyboardHandler(ID id) override
ID RegisterGlobalKeyboardHandler(KeyboardCallbackBase *callback) override
StandardInputHandler(DisplayFrame *displayFrame)
ID RegisterGlobalMouseHandler(MouseCallbackBase *callback) override
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
The input handler interface.
Definition: bmpimage.h:46