/src/ois/src/SDL/SDLInputManager.cpp
C++ | 114 lines | 64 code | 17 blank | 33 comment | 4 complexity | f60714088ddf48070730d7cc066207b8 MD5 | raw file
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 "SDL/SDLInputManager.h" 24#include "SDL/SDLKeyboard.h" 25#include "SDL/SDLMouse.h" 26#include "SDL/SDLJoyStick.h" 27#include "OISException.h" 28#include "OISObject.h" 29 30using namespace OIS; 31 32const std::string SDLInputManager::iName = "SDL Input Wrapper"; 33 34//--------------------------------------------------------------------------------// 35SDLInputManager::SDLInputManager() : mGrabbed(false) 36{ 37} 38 39//--------------------------------------------------------------------------------// 40SDLInputManager::~SDLInputManager() 41{ 42} 43 44//--------------------------------------------------------------------------------// 45void SDLInputManager::_initialize( ParamList ¶mList ) 46{ 47 Uint32 flags = SDL_WasInit(0); 48 if( flags == 0 ) 49 OIS_EXCEPT( E_General, "SDLInputManager::SDLInputManager >> SDL Not Initialized already!"); 50 51 //Ok, now we have DirectInput, parse whatever extra settings were sent to us 52 _parseConfigSettings( paramList ); 53 _enumerateDevices(); 54} 55 56//--------------------------------------------------------------------------------// 57void SDLInputManager::_parseConfigSettings( ParamList ¶mList ) 58{ 59} 60 61//--------------------------------------------------------------------------------// 62void SDLInputManager::_enumerateDevices() 63{ 64} 65 66//--------------------------------------------------------------------------------// 67int SDLInputManager::numJoySticks() 68{ 69 return 0; 70} 71 72//--------------------------------------------------------------------------------// 73int SDLInputManager::numMice() 74{ 75 return 1; 76} 77 78//--------------------------------------------------------------------------------// 79int SDLInputManager::numKeyboards() 80{ 81 return 1; 82} 83 84//----------------------------------------------------------------------------// 85Object* SDLInputManager::createInputObject( Type iType, bool bufferMode ) 86{ 87 Object* obj = 0; 88 89 switch( iType ) 90 { 91 case OISKeyboard: obj = new SDLKeyboard( bufferMode ); break; 92 case OISMouse: obj = new SDLMouse( bufferMode ); break; 93 case OISJoyStick: 94 default: OIS_EXCEPT( E_InputDeviceNotSupported, "Type not implemented"); 95 } 96 97 try { 98 obj->_initialize(); 99 } 100 catch(...) { 101 delete obj; 102 throw; //rethrow 103 } 104 105 return obj; 106} 107 108//----------------------------------------------------------------------------// 109void SDLInputManager::destroyInputObject( Object* obj ) 110{ 111 if( obj == 0 ) return; 112 113 delete obj; 114}