1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef NL_INPUT_HANDLER_MANAGER_H
24 #define NL_INPUT_HANDLER_MANAGER_H
26 #include "nel/misc/event_server.h"
30 #include "nel/gui/event_descriptor.h"
31 #include "nel/gui/input_handler.h"
32 #include "nel/gui/group_editbox.h"
34 // Forward declarations for libxml2
35 typedef struct _xmlNode xmlNode
;
36 typedef xmlNode
*xmlNodePtr
;
40 * CInputManager. Class used to manage Input Handlers. its purpose is to manage all input handler
41 * CInputManager get hardware events from input handlers, when they call CInputManager::ProcessEvent
42 * CInputMangager convert the incoming events into actions and call the appropriate control's callback
44 * This conversion is made through the reading of a config file describing the association between events and actions
45 * \author Nicolas Brigand
46 * \author Nevrax France
51 class CInputHandlerManager
: public NLMISC::IEventListener
, public CGroupEditBox::IComboKeyHandler
54 /// The EventServer Filled with Filtered Messages the InterfaceManager didn't catch
55 NLMISC::CEventServer FilteredEventServer
;
59 * getInstance because this class is a singleton
61 static CInputHandlerManager
* getInstance()
63 if (_Instance
== NULL
)
64 _Instance
= new CInputHandlerManager();
69 static void releaseInstance();
72 * set the input server
73 * \param server : the input event server
75 void addToServer(NLMISC::CEventServer
* server
);
79 * release all data members
85 * callback operator called when a low-level hardware event is received
87 * \param event : the event received
89 void operator ()(const NLMISC::CEvent
& event
);
93 * read the input config file.
94 * \param fileName : name of the config file
95 * \return true if no error occurred
97 bool readInputConfigFile(const std::string
& fileName
);
100 /** Return true if the event is handled by Text Edition in the interface Manager
101 * All Events are stored in the xml input config file.
102 * Basics events such as KeyA, KeyB etc.. should be in this config file.
103 * Combo Keys like Ctrl+A (select all) should be in this config file too.
105 bool isComboKeyChat(const NLGUI::CEventDescriptorKey
&edk
) const;
108 /** Pump The Events of The setuped EventServer (ie Driver->EventServer).
109 * Then pump the filtered ones
113 /** Same as pumpEvents() but the messages are not processed by the InterfaceManager, but directly
114 * posted to FilteredEventServer
116 void pumpEventsNoIM();
118 /** Reset the position of the mouse
120 void resetPos (sint x
, sint y
);
123 bool hasFocus() const { return _Focus
; }
128 * private constructor for singleton
130 CInputHandlerManager();
133 ~CInputHandlerManager();
135 ///the singleton's instance
136 static CInputHandlerManager
* _Instance
;
138 ///pointer to an event server
139 NLMISC::CEventServer
* _EventServer
;
142 NLMISC::TMouseButton _MouseButtonsState
;
144 sint32 _MouseX
, _MouseY
;
145 sint32 _MouseLastX
, _MouseLastY
;
149 bool _SkipInterfaceManager
;
150 bool _RecoverFocusLost
;
172 void init(const NLGUI::CEventDescriptorKey
&rDK
);
173 bool operator<(const CComboKey
&c
) const;
176 // List of key used in Text edition
177 std::set
<CComboKey
> _ComboKeyChat
;
181 void parseComboKeyChat(xmlNodePtr cur
);
182 void parseKey(xmlNodePtr cur
, std::vector
<CComboKey
> &out
);
184 // return true if handled
185 bool updateMousePos(NLMISC::CEventMouse
&event
);
187 NLGUI::CInputHandler inputHandler
;
191 #endif // NL_INPUT_HANDLER_MANAGER_H
193 /* End of input_handler_manager.h */