2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2005-01-23 01:36:29 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2005-01-23 01:36:29 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-01-23 01:36:29 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2005-01-23 01:36:29 +00:00
|
|
|
*/
|
2011-02-25 13:32:11 +00:00
|
|
|
|
|
|
|
/** \file gameengine/GameLogic/SCA_JoystickManager.cpp
|
|
|
|
* \ingroup gamelogic
|
|
|
|
*/
|
|
|
|
|
2005-01-23 01:36:29 +00:00
|
|
|
#include "SCA_JoystickSensor.h"
|
|
|
|
#include "SCA_JoystickManager.h"
|
|
|
|
#include "SCA_LogicManager.h"
|
2005-03-25 10:33:39 +00:00
|
|
|
//#include <vector>
|
2005-01-23 01:36:29 +00:00
|
|
|
#include "SCA_ISensor.h"
|
|
|
|
|
2005-03-25 10:33:39 +00:00
|
|
|
//using namespace std;
|
2005-01-23 01:36:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr)
|
2009-09-25 16:30:15 +00:00
|
|
|
: SCA_EventManager(logicmgr, JOY_EVENTMGR)
|
2005-01-23 01:36:29 +00:00
|
|
|
{
|
2008-08-31 18:42:58 +00:00
|
|
|
int i;
|
|
|
|
for (i=0; i<JOYINDEX_MAX; i++) {
|
|
|
|
m_joystick[i] = SCA_Joystick::GetInstance( i );
|
|
|
|
}
|
2005-01-23 01:36:29 +00:00
|
|
|
}
|
2005-03-25 10:33:39 +00:00
|
|
|
|
|
|
|
|
2005-01-23 01:36:29 +00:00
|
|
|
SCA_JoystickManager::~SCA_JoystickManager()
|
|
|
|
{
|
2008-08-31 18:42:58 +00:00
|
|
|
int i;
|
|
|
|
for (i=0; i<JOYINDEX_MAX; i++) {
|
2008-10-11 00:56:49 +00:00
|
|
|
if(m_joystick[i])
|
|
|
|
m_joystick[i]->ReleaseInstance();
|
2008-08-31 18:42:58 +00:00
|
|
|
}
|
2005-01-23 01:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCA_JoystickManager::NextFrame(double curtime,double deltatime)
|
|
|
|
{
|
2009-05-10 20:53:58 +00:00
|
|
|
if (m_sensors.Empty()) {
|
2008-09-02 06:12:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2009-05-10 20:53:58 +00:00
|
|
|
;
|
2011-10-20 00:19:21 +00:00
|
|
|
#ifdef WITH_SDL
|
2008-09-02 06:12:19 +00:00
|
|
|
SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */
|
2008-09-21 05:38:28 +00:00
|
|
|
#endif
|
2009-05-10 20:53:58 +00:00
|
|
|
SG_DList::iterator<SCA_JoystickSensor> it(m_sensors);
|
|
|
|
for (it.begin();!it.end();++it)
|
2005-01-23 01:36:29 +00:00
|
|
|
{
|
2009-05-10 20:53:58 +00:00
|
|
|
SCA_JoystickSensor* joysensor = *it;
|
2008-09-02 06:12:19 +00:00
|
|
|
if(!joysensor->IsSuspended())
|
|
|
|
{
|
2009-05-10 20:53:58 +00:00
|
|
|
joysensor->Activate(m_logicmgr);
|
2008-09-02 06:12:19 +00:00
|
|
|
}
|
2005-01-23 01:36:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-31 18:42:58 +00:00
|
|
|
SCA_Joystick *SCA_JoystickManager::GetJoystickDevice( short int joyindex)
|
2005-01-23 01:36:29 +00:00
|
|
|
{
|
2011-09-25 12:31:21 +00:00
|
|
|
/*
|
|
|
|
*Return the instance of SCA_Joystick for use
|
|
|
|
*/
|
2008-08-31 18:42:58 +00:00
|
|
|
return m_joystick[joyindex];
|
2005-01-23 01:36:29 +00:00
|
|
|
}
|