Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/release2012/src/external/ois/linux/LinuxInputManager.cpp @ 10656

Last change on this file since 10656 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.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#include "linux/LinuxInputManager.h"
24#include "linux/LinuxKeyboard.h"
25#include "linux/LinuxJoyStickEvents.h"
26#include "linux/LinuxMouse.h"
27#include "OISException.h"
28#include <cstdlib>
29
30using namespace OIS;
31
32//--------------------------------------------------------------------------------//
33LinuxInputManager::LinuxInputManager() : InputManager("X11InputManager")
34{
35        window = 0;
36
37        //Default settings
38        grabMouse = true;
39        grabKeyboard = true;
40        hideMouse = true;
41        mGrabs = true;
42        keyboardUsed = mouseUsed = false;
43
44        //Setup our internal factories
45        mFactories.push_back(this);
46}
47
48//--------------------------------------------------------------------------------//
49LinuxInputManager::~LinuxInputManager()
50{
51        //Close all joysticks
52        LinuxJoyStick::_clearJoys(unusedJoyStickList);
53}
54
55//--------------------------------------------------------------------------------//
56void LinuxInputManager::_initialize( ParamList &paramList )
57{
58        _parseConfigSettings( paramList );
59
60        //Enumerate all devices attached
61        _enumerateDevices();
62}
63
64//--------------------------------------------------------------------------------//
65void LinuxInputManager::_parseConfigSettings( ParamList &paramList )
66{
67        ParamList::iterator i = paramList.find("WINDOW");
68        if( i == paramList.end() ) 
69                OIS_EXCEPT( E_InvalidParam, "LinuxInputManager >> No WINDOW!" );
70
71        //TODO 64 bit proof this little conversion xxx wip
72        window  = strtoul(i->second.c_str(), 0, 10);
73
74        //--------- Keyboard Settings ------------//
75        i = paramList.find("x11_keyboard_grab");
76        if( i != paramList.end() )
77                if( i->second == "false" )
78                        grabKeyboard = false;
79
80        //--------- Mouse Settings ------------//
81        i = paramList.find("x11_mouse_grab");
82        if( i != paramList.end() )
83                if( i->second == "false" )
84                        grabMouse = false;
85
86        i = paramList.find("x11_mouse_hide");
87        if( i != paramList.end() )
88                if( i->second == "false" )
89                        hideMouse = false;
90}
91
92//--------------------------------------------------------------------------------//
93void LinuxInputManager::_enumerateDevices()
94{
95        //Enumerate all attached devices
96        unusedJoyStickList = LinuxJoyStick::_scanJoys();
97        joySticks = unusedJoyStickList.size();
98}
99
100//----------------------------------------------------------------------------//
101DeviceList LinuxInputManager::freeDeviceList()
102{
103        DeviceList ret;
104
105        if( keyboardUsed == false )
106                ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
107
108        if( mouseUsed == false )
109                ret.insert(std::make_pair(OISMouse, mInputSystemName));
110
111        for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
112                ret.insert(std::make_pair(OISJoyStick, i->vendor));
113
114        return ret;
115}
116
117//----------------------------------------------------------------------------//
118int LinuxInputManager::totalDevices(Type iType)
119{
120        switch(iType)
121        {
122        case OISKeyboard: return 1;
123        case OISMouse: return 1;
124        case OISJoyStick: return joySticks;
125        default: return 0;
126        }
127}
128
129//----------------------------------------------------------------------------//
130int LinuxInputManager::freeDevices(Type iType)
131{
132        switch(iType)
133        {
134        case OISKeyboard: return keyboardUsed ? 0 : 1;
135        case OISMouse: return mouseUsed ? 0 : 1;
136        case OISJoyStick: return (int)unusedJoyStickList.size();
137        default: return 0;
138        }
139}
140
141//----------------------------------------------------------------------------//
142bool LinuxInputManager::vendorExist(Type iType, const std::string & vendor)
143{
144        if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
145        {
146                return true;
147        }
148        else if( iType == OISJoyStick )
149        {
150                for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
151                        if(i->vendor == vendor)
152                                return true;
153        }
154
155        return false;
156}
157
158//----------------------------------------------------------------------------//
159Object* LinuxInputManager::createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor)
160{
161        Object *obj = 0;
162
163        switch(iType)
164        {
165        case OISKeyboard:
166        {
167                if( keyboardUsed == false )
168                        obj = new LinuxKeyboard(this, bufferMode, grabKeyboard);
169                break;
170        }
171        case OISMouse:
172        {
173                if( mouseUsed == false )
174                        obj = new LinuxMouse(this, bufferMode, grabMouse, hideMouse);
175                break;
176        }
177        case OISJoyStick:
178        {
179                for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
180                {
181                        if(vendor == "" || i->vendor == vendor)
182                        {
183                                obj = new LinuxJoyStick(this, bufferMode, *i);
184                                unusedJoyStickList.erase(i);
185                                break;
186                        }
187                }
188                break;
189        }
190        default:
191                break;
192        }
193
194        if( obj == 0 )
195                OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
196
197        return obj;
198}
199
200//----------------------------------------------------------------------------//
201void LinuxInputManager::destroyObject( Object* obj )
202{
203        if( obj )
204        {
205                if( obj->type() == OISJoyStick )
206                {
207                        unusedJoyStickList.push_back( ((LinuxJoyStick*)obj)->_getJoyInfo() );
208                }
209
210                delete obj;
211        }
212}
Note: See TracBrowser for help on using the repository browser.