Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/menue/src/external/ois/OISInputManager.h @ 8923

Last change on this file since 8923 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
1/*
2The zlib/libpng License
3
4Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
12
13    1. The origin of this software must not be misrepresented; you must not claim that
14                you wrote the original software. If you use this software in a product,
15                an acknowledgment in the product documentation would be appreciated but is
16                not required.
17
18    2. Altered source versions must be plainly marked as such, and must not be
19                misrepresented as being the original software.
20
21    3. This notice may not be removed or altered from any source distribution.
22*/
23#ifndef OIS_InputManager_H
24#define OIS_InputManager_H
25
26#include "OISPrereqs.h"
27
28namespace OIS
29{
30        //Forward declare a couple of classes we might use later
31        class LIRCFactoryCreator;
32        class WiiMoteFactoryCreator;
33
34        /**
35                Base Manager class. No longer a Singleton; so feel free to create as many InputManager's as you have
36                windows.
37        */
38        class _OISExport InputManager
39        {
40        public:
41                /**
42                @remarks
43                        Returns version number (useful in DLL/SO libs)
44                @returns
45                        Bits: 1-8 Patch number, 9-16 Minor version, 17-32 Major version
46                */
47                static unsigned int getVersionNumber();
48
49                /**
50                @remarks
51                        Returns version string (useful in DLL/SO libs)
52                @returns
53                        Version name
54                */
55                const std::string &getVersionName();
56
57                /**
58                @remarks
59                        Creates appropriate input system dependent on platform.
60                @param winHandle
61                        Contains OS specific window handle (such as HWND or X11 Window)
62                @returns
63                        A pointer to the created manager, or raises Exception
64                */
65                static InputManager* createInputSystem( std::size_t winHandle );
66
67                /**
68                @remarks
69                        Creates appropriate input system dependent on platform.
70                @param paramList
71                        ParamList contains OS specific info (such as HWND and HINSTANCE for window apps),
72                        and access mode.
73                @returns
74                        A pointer to the created manager, or raises Exception
75                */
76                static InputManager* createInputSystem( ParamList &paramList );
77
78                /**
79                @remarks
80                        Destroys the InputManager
81                @param manager
82                        Manager to destroy
83                */
84                static void destroyInputSystem(InputManager* manager);
85
86                /**
87                @remarks Gets the name of the current platform input system
88                */
89                const std::string& inputSystemName();
90
91                /**
92                @remarks
93                        Returns the number of the specified OIS::Type devices discovered by OIS
94                @param iType
95                        Type that you are interested in
96                */
97                int getNumberOfDevices( Type iType );
98
99                /**
100                @remarks
101                        Lists all unused devices
102                @returns
103                        DeviceList which contains Type and vendor of device
104                */
105                DeviceList listFreeDevices();
106
107                /**
108                @remarks
109                        Tries to create an object with the specified vendor. If you have no
110                        preference of vendor, leave vender as default (""). Raises exception on failure
111                */
112                Object* createInputObject( Type iType, bool bufferMode, const std::string &vendor = "");
113
114                /**
115                @remarks Destroys Input Object
116                */
117                void destroyInputObject( Object* obj );
118
119                /**
120                @remarks
121                        Add a custom object factory to allow for user controls.
122                @param factory
123                        Factory instance to add
124                @notes
125                        Make sure you do not delete the factory before devices created from
126                        the factory are destroyed (either by calling RemoveFactoryCreator, or shutting down
127                        the input system). Order should be something like the following:
128                                * Create Input System
129                                * Create Factory Instance
130                                * AddFactoryCreator(factory)
131                                * Create a device from the InputManager (device created by factory)
132                                * One of the follwoing:
133                                        * removeFactoryCreator(factory)
134                                        * inputManager->destroyInputObject(obj)
135                                * destroyInputSystem(inputManager)
136                                * destroy Factory Instance
137                        You can safely delete the factory instance once you have removed it or shut down the
138                        input manager.
139                */
140                void addFactoryCreator( FactoryCreator* factory );
141
142                /**
143                @remarks
144                        Remove a previously added object factory
145                @param factory
146                        Factory object to remove.
147                @notes
148                        Removing a factory will automatically destroy any Objects created from the factory
149                */
150                void removeFactoryCreator( FactoryCreator* factory );
151
152                //! All generic devices OIS supports internally (if they are compiled in)
153                enum AddOnFactories
154                {
155                        AddOn_All = 0,          //All Devices
156                        AddOn_LIRC = 1,         //PC Linux Infrared Remote Control
157                        AddOn_WiiMote = 2       //PC WiiMote Support
158                };
159
160                /**
161                @remarks
162                        Enable an addon FactoryCreator extension. By default, none are activated.
163                        If the desired support was not compiled in, this has no effect. Calling
164                        multiple times has no effect. Once activated, there is no way to deactivate -
165                        simply destroy and recreate input manager.
166                */
167                void enableAddOnFactory(AddOnFactories factory);
168
169        protected:
170                /**
171                @remarks
172                        Called from createInputSystem, gives derived input class a chance to setup after it is created
173                */
174                virtual void _initialize(ParamList &paramList) = 0;
175
176                /**
177                @remarks
178                        Derived classes must provide input system name
179                */
180                InputManager(const std::string& name);
181
182                /**
183                @remarks
184                        Virtual Destructor - this base class will clean up all devices still opened in mFactoryObjects list
185                */
186                virtual ~InputManager();
187
188                //! OIS Version name
189                const std::string m_VersionName;
190
191                //! FactoryCreator list
192                FactoryList mFactories;
193
194                //! Factory created objects - useful so we can find creator to send destruction request to
195                FactoryCreatedObject mFactoryObjects;
196
197                //! Name of the input system
198                const std::string mInputSystemName;
199
200                //! Extra factory (not enabled by default)
201                LIRCFactoryCreator *m_lircSupport;
202                WiiMoteFactoryCreator *m_wiiMoteSupport;
203        };
204}
205#endif
Note: See TracBrowser for help on using the repository browser.