• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 The zlib/libpng License
3 
4 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
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 "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 
30 using namespace OIS;
31 
32 const std::string SDLInputManager::iName = "SDL Input Wrapper";
33 
34 //--------------------------------------------------------------------------------//
SDLInputManager()35 SDLInputManager::SDLInputManager() : mGrabbed(false)
36 {
37 }
38 
39 //--------------------------------------------------------------------------------//
~SDLInputManager()40 SDLInputManager::~SDLInputManager()
41 {
42 }
43 
44 //--------------------------------------------------------------------------------//
_initialize(ParamList & paramList)45 void SDLInputManager::_initialize( ParamList &paramList )
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 //--------------------------------------------------------------------------------//
_parseConfigSettings(ParamList & paramList)57 void SDLInputManager::_parseConfigSettings( ParamList &paramList )
58 {
59 }
60 
61 //--------------------------------------------------------------------------------//
_enumerateDevices()62 void SDLInputManager::_enumerateDevices()
63 {
64 }
65 
66 //--------------------------------------------------------------------------------//
numJoySticks()67 int SDLInputManager::numJoySticks()
68 {
69 	return 0;
70 }
71 
72 //--------------------------------------------------------------------------------//
numMice()73 int SDLInputManager::numMice()
74 {
75 	return 1;
76 }
77 
78 //--------------------------------------------------------------------------------//
numKeyboards()79 int SDLInputManager::numKeyboards()
80 {
81 	return 1;
82 }
83 
84 //----------------------------------------------------------------------------//
createInputObject(Type iType,bool bufferMode)85 Object* 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 //----------------------------------------------------------------------------//
destroyInputObject(Object * obj)109 void SDLInputManager::destroyInputObject( Object* obj )
110 {
111 	if( obj == 0 ) return;
112 
113 	delete obj;
114 }
115