From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/di__event__emitter_8h-source.html | 250 +++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 docs/doxygen/nel/di__event__emitter_8h-source.html (limited to 'docs/doxygen/nel/di__event__emitter_8h-source.html') diff --git a/docs/doxygen/nel/di__event__emitter_8h-source.html b/docs/doxygen/nel/di__event__emitter_8h-source.html new file mode 100644 index 00000000..dee6884b --- /dev/null +++ b/docs/doxygen/nel/di__event__emitter_8h-source.html @@ -0,0 +1,250 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

di_event_emitter.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000-2002 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_DI_EVENT_EMITTER_H
+00027 #define NL_DI_EVENT_EMITTER_H
+00028 
+00029 
+00030 
+00031 #include "nel/misc/types_nl.h"
+00032 
+00033 
+00034 #ifdef NL_OS_WINDOWS
+00035 
+00036 
+00037 #define DIRECTINPUT_VERSION 0x0800
+00038 
+00039 #include "nel/misc/input_device_server.h"
+00040 #include "nel/misc/input_device_manager.h"
+00041 #include "nel/misc/event_emitter.h"
+00042 #include "nel/misc/smart_ptr.h"
+00043 #include "nel/misc/events.h"
+00044 #include "nel/misc/rect.h"
+00045 #include "nel/misc/game_device.h"
+00046 #include <windows.h>
+00047 #include <dinput.h>
+00048 
+00049 
+00050 
+00051 namespace NLMISC
+00052 {
+00053 
+00054 
+00055 class CWinEventEmitter;
+00056 class CDIKeyboard;
+00057 class CDIMouse;
+00058 struct IMouseDevice;
+00059 struct IKeyboardDevice;
+00060 
+00061 //
+00062 struct EDirectInput : public EInputDevice
+00063 {
+00064         EDirectInput(const char *reason) : EInputDevice(reason) {}
+00065 };
+00066 //
+00067 struct EDirectInputLibNotFound : public  EDirectInput
+00068 {
+00069         EDirectInputLibNotFound() : EDirectInput("can't found the direct input dll") {}
+00070 };
+00071 //
+00072 struct EDirectInputInitFailed : public  EDirectInput
+00073 {
+00074         EDirectInputInitFailed() : EDirectInput("Direct input initialization failed") {}
+00075 };
+00076 //
+00077 struct EDirectInputCooperativeLevelFailed : public  EDirectInput
+00078 {
+00079         EDirectInputCooperativeLevelFailed() : EDirectInput("Direct Input Device Cooperative level couldn't be set") {}
+00080 };
+00081 
+00082 
+00083 // Class to represent Direct Inputs events
+00084 struct CDIEvent : public IInputDeviceEvent
+00085 {
+00086         // TODO : redefine operator new ?
+00087         virtual bool    operator < (const IInputDeviceEvent &ide) const
+00088         {
+00089                 // just compare the dates
+00090                 return Datas.dwTimeStamp < (safe_cast<const CDIEvent *>(&ide))->Datas.dwTimeStamp;
+00091         }
+00092         DIDEVICEOBJECTDATA      Datas;
+00093 };
+00094 
+00103 class CDIEventEmitter : public IEventEmitter, public IInputDeviceManager
+00104 {       
+00105 public:
+00113         static CDIEventEmitter *create(HINSTANCE hinst, HWND hwnd, CWinEventEmitter *we);
+00114         ~CDIEventEmitter();
+00115 public:
+00116 
+00118         void                                    poll(CEventServer *server = NULL);
+00119 
+00121 
+00122 
+00125                 virtual IMouseDevice    *getMouseDevice() throw(EInputDevice);
+00127                 virtual void    releaseMouse();
+00132                 virtual IKeyboardDevice *getKeyboardDevice() throw(EInputDevice);
+00134                 virtual void    releaseKeyboard();
+00135                 // Enumerates current game devices (gamepads, joystick etc.). The result is stored in the given vector
+00136                 virtual void    enumerateGameDevice(TDeviceDescVect &descs) throw(EInputDevice);
+00137                 // Create the given game device from its instance name. It also means that it will begin to sends inputs
+00138                 virtual IGameDevice     *createGameDevice(const std::string &instanceName) throw(EInputDevice);
+00139                 // Release the given game device
+00140                 virtual void             releaseGameDevice(IGameDevice  *);
+00142 
+00144         virtual void                    submitEvents(CEventServer &server);     
+00145 
+00146         // Build a TMouseButton value from the current buttons state
+00147         TMouseButton    buildButtonsFlags() const;
+00148         // Build a TMouseButton value (but with no mouse values)
+00149         TMouseButton    buildKeyboardButtonFlags() const
+00150         {
+00151                 return (TMouseButton) (buildButtonsFlags() & (ctrlButton|shiftButton|altButton));
+00152         }       
+00153 
+00154 //================================================================
+00155 //================================================================
+00156 //================================================================
+00157 private:
+00158         typedef HRESULT (WINAPI * TPDirectInput8Create) (HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter);
+00159         // Private internal server message, used to stored all messages internally before to dispatch them, when no server is supplied to poll(...
+00160         class CDIEventServer : CEventServer
+00161         {
+00162                 friend class CDIEventEmitter;
+00163         public:
+00164                 void setServer (CEventServer *server)
+00165                 {
+00166                         _Server = server;
+00167                 }
+00168         private:
+00169                 bool pumpEvent(CEvent *event)
+00170                 {
+00171                         CEventServer::pumpEvent(event);
+00172                         _Server->postEvent (event);
+00173                         return false;
+00174                 }
+00175         private:
+00176                 CEventServer *_Server;
+00177         };              
+00178 private:
+00179         HWND                                                            _hWnd;
+00180         TMouseButton                                            _ButtonsFlags;
+00181         NLMISC::CRefPtr<CWinEventEmitter>       _WE;
+00182         static HMODULE                          _DirectInputLibHandle;
+00183         static TPDirectInput8Create _PDirectInput8Create;
+00184         static uint                                     _NumCreatedInterfaces;
+00185 private:
+00186         static bool loadLib();
+00187         static void unloadLib();
+00188 //====
+00189 private:
+00190         CDIEventServer                                                  _InternalServer;
+00191         CInputDeviceServer                                              _DeviceServer;
+00192         IDirectInput8                                                   *_DInput8;
+00193         CDIMouse                                                                *_Mouse;        
+00194         CDIKeyboard                                                             *_Keyboard;     
+00195 private:
+00196         CDIEventEmitter(HWND hwnd, CWinEventEmitter *we);       
+00197 };
+00198 
+00199 
+00200 
+00201 } // NLMISC
+00202 
+00203 #endif // NL_WINDOWS
+00204 
+00205 
+00206 #endif // NL_DX_EVENT_EMITTER_H
+00207 
+00208 /* End of dx_event_emitter.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1