Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weaponupdateHS14/src/external/ois/mac/MacInputManager.cpp @ 10240

Last change on this file since 10240 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1/*
2 The zlib/libpng License
3 
4 Copyright (c) 2006 Chris Snyder
5 
6 This software is provided 'as-is', without any express or implied warranty. In no event will
7 the authors be held liable for any damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any purpose, including commercial
10 applications, and to alter it and redistribute it freely, subject to the following
11 restrictions:
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#include "mac/MacInputManager.h"
24#include "mac/MacKeyboard.h"
25#include "mac/MacMouse.h"
26#include "mac/MacHIDManager.h"
27#include "OISException.h"
28
29#include <Carbon/Carbon.h>
30
31#include <iostream>
32using namespace std;
33
34using namespace OIS;
35
36//--------------------------------------------------------------------------------//
37MacInputManager::MacInputManager() : InputManager("Mac OSX Input Manager")
38{
39    mHideMouse = true;
40    mUseRepeat = false;
41    mEventTargetRef = NULL;
42        mWindow = NULL;
43
44        keyboardUsed = mouseUsed = false;
45
46        //Setup our internal factories
47        mFactories.push_back(this);
48
49        mHIDManager = new MacHIDManager();
50        mFactories.push_back(mHIDManager);
51}
52
53//--------------------------------------------------------------------------------//
54MacInputManager::~MacInputManager()
55{
56        delete mHIDManager;
57}
58
59//--------------------------------------------------------------------------------//
60void MacInputManager::_initialize( ParamList &paramList )
61{
62        _parseConfigSettings( paramList );
63   
64        //Enumerate all devices attached
65        _enumerateDevices();
66       
67        mHIDManager->initialize();
68}
69
70//--------------------------------------------------------------------------------//
71void MacInputManager::_parseConfigSettings( ParamList &paramList )
72{
73    // Some carbon apps are running in a window, however full screen apps
74        // do not have a window, so we need to account for that too.
75        ParamList::iterator i = paramList.find("WINDOW");
76        if(i != paramList.end())
77        {
78                mWindow = (WindowRef)strtoul(i->second.c_str(), 0, 10);
79                if(mWindow == 0)
80                {
81                        mWindow = NULL;
82                        mEventTargetRef = GetApplicationEventTarget();
83                }
84                else
85                {
86                        //mEventTargetRef = GetWindowEventTarget(mWindow);
87                        mEventTargetRef = GetApplicationEventTarget();
88                }
89    }
90        else
91        {
92                // else get the main active window.. user might not have access to it through some
93                // graphics libraries, if that fails then try at the application level.
94                mWindow = ActiveNonFloatingWindow();
95                if(mWindow == NULL)
96                {
97                        mEventTargetRef = GetApplicationEventTarget();
98                }
99                else
100                {
101                        //mEventTargetRef = GetWindowEventTarget(mWindow);
102                        mEventTargetRef = GetApplicationEventTarget();
103                }
104        }
105       
106        if(mEventTargetRef == NULL)
107                OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" );
108   
109    // Keyboard
110    if(paramList.find("MacAutoRepeatOn") != paramList.end())
111        {
112        if(paramList.find("MacAutoRepeatOn")->second == "true")
113                {
114            mUseRepeat = true;
115        }
116    }
117}
118
119//--------------------------------------------------------------------------------//
120void MacInputManager::_enumerateDevices()
121{
122}
123
124//--------------------------------------------------------------------------------//
125DeviceList MacInputManager::freeDeviceList()
126{
127        DeviceList ret;
128
129        if( keyboardUsed == false )
130                ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
131
132        if( mouseUsed == false )
133                ret.insert(std::make_pair(OISMouse, mInputSystemName));
134
135        return ret;
136}
137
138//--------------------------------------------------------------------------------//
139int MacInputManager::totalDevices(Type iType)
140{
141        switch(iType)
142        {
143        case OISKeyboard: return 1;
144        case OISMouse: return 1;
145        default: return 0;
146        }
147}
148
149//--------------------------------------------------------------------------------//
150int MacInputManager::freeDevices(Type iType)
151{
152        switch(iType)
153        {
154        case OISKeyboard: return keyboardUsed ? 0 : 1;
155        case OISMouse: return mouseUsed ? 0 : 1;
156        default: return 0;
157        }
158}
159
160//--------------------------------------------------------------------------------//
161bool MacInputManager::vendorExist(Type iType, const std::string & vendor)
162{
163        if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
164                return true;
165
166        return false;
167}
168
169//--------------------------------------------------------------------------------//
170Object* MacInputManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
171                                                                          const std::string & vendor)
172{
173        Object *obj = 0;
174
175        switch(iType)
176        {
177        case OISKeyboard: 
178        {
179                if( keyboardUsed == false )
180                        obj = new MacKeyboard(this, bufferMode, mUseRepeat);
181                break;
182        }
183        case OISMouse:
184        {
185                if( mouseUsed == false )
186                        obj = new MacMouse(this, bufferMode);
187                break;
188        }
189        default:
190        {
191                obj = mHIDManager->createObject(creator, iType, bufferMode, vendor);
192                break;
193        }
194        }
195
196        if( obj == 0 )
197                OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
198
199        return obj;
200}
201
202//--------------------------------------------------------------------------------//
203void MacInputManager::destroyObject(Object* obj)
204{
205        delete obj;
206}
Note: See TracBrowser for help on using the repository browser.