forked from bartvdbraak/blender
game engine now compiles with SDL disabled. CDROM and Joystick wont function in this case
This commit is contained in:
parent
2064f5542a
commit
e11cd5a962
@ -14,4 +14,7 @@ if env['WITH_BF_OPENAL']:
|
|||||||
else:
|
else:
|
||||||
defs = 'NO_SOUND'
|
defs = 'NO_SOUND'
|
||||||
|
|
||||||
|
if not env['WITH_BF_SDL']:
|
||||||
|
defs += ' DISABLE_SDL'
|
||||||
|
|
||||||
env.BlenderLib ('bf_soundsystem', sources, Split(incs), Split(defs), libtype=['core','player'], priority = [20,140] )
|
env.BlenderLib ('bf_soundsystem', sources, Split(incs), Split(defs), libtype=['core','player'], priority = [20,140] )
|
||||||
|
@ -55,6 +55,10 @@ SND_SDLCDDevice::SND_SDLCDDevice() :
|
|||||||
|
|
||||||
void SND_SDLCDDevice::init()
|
void SND_SDLCDDevice::init()
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
fprintf(stderr, "Blender compiled without SDL, no CDROM support\n");
|
||||||
|
return;
|
||||||
|
#else
|
||||||
if (SDL_InitSubSystem(SDL_INIT_CDROM))
|
if (SDL_InitSubSystem(SDL_INIT_CDROM))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error initializing CDROM\n");
|
fprintf(stderr, "Error initializing CDROM\n");
|
||||||
@ -75,19 +79,23 @@ void SND_SDLCDDevice::init()
|
|||||||
/* Did if open? Check if cdrom is NULL */
|
/* Did if open? Check if cdrom is NULL */
|
||||||
if(!m_cdrom)
|
if(!m_cdrom)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Couldn't open drive: %s", SDL_GetError());
|
fprintf(stderr, "Couldn't open drive: %s\n", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SND_SDLCDDevice::~SND_SDLCDDevice()
|
SND_SDLCDDevice::~SND_SDLCDDevice()
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
StopCD();
|
StopCD();
|
||||||
SDL_CDClose(m_cdrom);
|
SDL_CDClose(m_cdrom);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SND_SDLCDDevice::NextFrame()
|
void SND_SDLCDDevice::NextFrame()
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
m_frame++;
|
m_frame++;
|
||||||
m_frame &= 127;
|
m_frame &= 127;
|
||||||
|
|
||||||
@ -111,20 +119,24 @@ void SND_SDLCDDevice::NextFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SND_SDLCDDevice::PlayCD(int track)
|
void SND_SDLCDDevice::PlayCD(int track)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
if ( m_cdrom && CD_INDRIVE(SDL_CDStatus(m_cdrom)) ) {
|
if ( m_cdrom && CD_INDRIVE(SDL_CDStatus(m_cdrom)) ) {
|
||||||
SDL_CDPlayTracks(m_cdrom, track-1, 0, track, 0);
|
SDL_CDPlayTracks(m_cdrom, track-1, 0, track, 0);
|
||||||
m_cdplaying = true;
|
m_cdplaying = true;
|
||||||
m_cdtrack = track;
|
m_cdtrack = track;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SND_SDLCDDevice::PauseCD(bool pause)
|
void SND_SDLCDDevice::PauseCD(bool pause)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
if (!m_cdrom)
|
if (!m_cdrom)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -132,13 +144,16 @@ void SND_SDLCDDevice::PauseCD(bool pause)
|
|||||||
SDL_CDPause(m_cdrom);
|
SDL_CDPause(m_cdrom);
|
||||||
else
|
else
|
||||||
SDL_CDResume(m_cdrom);
|
SDL_CDResume(m_cdrom);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SND_SDLCDDevice::StopCD()
|
void SND_SDLCDDevice::StopCD()
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
if (m_cdrom)
|
if (m_cdrom)
|
||||||
SDL_CDStop(m_cdrom);
|
SDL_CDStop(m_cdrom);
|
||||||
m_cdplaying = false;
|
m_cdplaying = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SND_SDLCDDevice::SetCDPlaymode(int playmode)
|
void SND_SDLCDDevice::SetCDPlaymode(int playmode)
|
||||||
|
@ -42,14 +42,18 @@ SCA_Joystick::SCA_Joystick(short int index)
|
|||||||
m_isinit(0),
|
m_isinit(0),
|
||||||
m_istrig(0)
|
m_istrig(0)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
m_private = new PrivateData();
|
m_private = new PrivateData();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SCA_Joystick::~SCA_Joystick()
|
SCA_Joystick::~SCA_Joystick()
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
delete m_private;
|
delete m_private;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX];
|
SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX];
|
||||||
@ -57,6 +61,9 @@ int SCA_Joystick::m_refCount = 0;
|
|||||||
|
|
||||||
SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
|
SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
if (joyindex < 0 || joyindex >= JOYINDEX_MAX) {
|
if (joyindex < 0 || joyindex >= JOYINDEX_MAX) {
|
||||||
echo("Error-invalid joystick index: " << joyindex);
|
echo("Error-invalid joystick index: " << joyindex);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -81,12 +88,14 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
|
|||||||
m_refCount++;
|
m_refCount++;
|
||||||
}
|
}
|
||||||
return m_instance[joyindex];
|
return m_instance[joyindex];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCA_Joystick::ReleaseInstance()
|
void SCA_Joystick::ReleaseInstance()
|
||||||
{
|
{
|
||||||
if (--m_refCount == 0)
|
if (--m_refCount == 0)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<JOYINDEX_MAX; i++) {
|
for (i=0; i<JOYINDEX_MAX; i++) {
|
||||||
if (m_instance[i]) {
|
if (m_instance[i]) {
|
||||||
@ -95,7 +104,9 @@ void SCA_Joystick::ReleaseInstance()
|
|||||||
}
|
}
|
||||||
m_instance[i]= NULL;
|
m_instance[i]= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO );
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,19 +158,27 @@ bool SCA_Joystick::aDownAxisIsPositive(int axis)
|
|||||||
|
|
||||||
bool SCA_Joystick::aButtonPressIsPositive(int button)
|
bool SCA_Joystick::aButtonPressIsPositive(int button)
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
bool result;
|
bool result;
|
||||||
SDL_JoystickGetButton(m_private->m_joystick, button)? result = true:result = false;
|
SDL_JoystickGetButton(m_private->m_joystick, button)? result = true:result = false;
|
||||||
m_istrig = result;
|
m_istrig = result;
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCA_Joystick::aButtonReleaseIsPositive(int button)
|
bool SCA_Joystick::aButtonReleaseIsPositive(int button)
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
bool result;
|
bool result;
|
||||||
SDL_JoystickGetButton(m_private->m_joystick, button)? result = false : result = true;
|
SDL_JoystickGetButton(m_private->m_joystick, button)? result = false : result = true;
|
||||||
m_istrig = result;
|
m_istrig = result;
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -199,6 +218,9 @@ int SCA_Joystick::pGetHat(int direction)
|
|||||||
|
|
||||||
int SCA_Joystick::GetNumberOfAxes()
|
int SCA_Joystick::GetNumberOfAxes()
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
int number;
|
int number;
|
||||||
if(m_isinit){
|
if(m_isinit){
|
||||||
if(m_private->m_joystick){
|
if(m_private->m_joystick){
|
||||||
@ -207,11 +229,15 @@ int SCA_Joystick::GetNumberOfAxes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCA_Joystick::GetNumberOfButtons()
|
int SCA_Joystick::GetNumberOfButtons()
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
int number;
|
int number;
|
||||||
if(m_isinit){
|
if(m_isinit){
|
||||||
if(m_private->m_joystick){
|
if(m_private->m_joystick){
|
||||||
@ -220,11 +246,15 @@ int SCA_Joystick::GetNumberOfButtons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCA_Joystick::GetNumberOfHats()
|
int SCA_Joystick::GetNumberOfHats()
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
int number;
|
int number;
|
||||||
if(m_isinit){
|
if(m_isinit){
|
||||||
if(m_private->m_joystick){
|
if(m_private->m_joystick){
|
||||||
@ -233,10 +263,14 @@ int SCA_Joystick::GetNumberOfHats()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCA_Joystick::CreateJoystickDevice(void)
|
bool SCA_Joystick::CreateJoystickDevice(void)
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_SDL
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
if(m_isinit == false){
|
if(m_isinit == false){
|
||||||
if (m_joyindex>=SDL_NumJoysticks()) {
|
if (m_joyindex>=SDL_NumJoysticks()) {
|
||||||
// don't print a message, because this is done anyway
|
// don't print a message, because this is done anyway
|
||||||
@ -251,11 +285,13 @@ bool SCA_Joystick::CreateJoystickDevice(void)
|
|||||||
m_isinit = true;
|
m_isinit = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCA_Joystick::DestroyJoystickDevice(void)
|
void SCA_Joystick::DestroyJoystickDevice(void)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
if (m_isinit){
|
if (m_isinit){
|
||||||
if(SDL_JoystickOpened(m_joyindex)){
|
if(SDL_JoystickOpened(m_joyindex)){
|
||||||
echo("Closing-joystick " << m_joyindex);
|
echo("Closing-joystick " << m_joyindex);
|
||||||
@ -263,21 +299,21 @@ void SCA_Joystick::DestroyJoystickDevice(void)
|
|||||||
}
|
}
|
||||||
m_isinit = false;
|
m_isinit = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SCA_Joystick::Connected(void)
|
int SCA_Joystick::Connected(void)
|
||||||
{
|
{
|
||||||
if (m_isinit){
|
#ifndef DISABLE_SDL
|
||||||
if(SDL_JoystickOpened(m_joyindex)){
|
if (m_isinit && SDL_JoystickOpened(m_joyindex))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCA_Joystick::pFillAxes()
|
void SCA_Joystick::pFillAxes()
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
if(GetNumberOfAxes() == 1){
|
if(GetNumberOfAxes() == 1){
|
||||||
m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0);
|
m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0);
|
||||||
m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1);
|
m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1);
|
||||||
@ -287,18 +323,20 @@ void SCA_Joystick::pFillAxes()
|
|||||||
m_axis20 = SDL_JoystickGetAxis(m_private->m_joystick, 2);
|
m_axis20 = SDL_JoystickGetAxis(m_private->m_joystick, 2);
|
||||||
m_axis21 = SDL_JoystickGetAxis(m_private->m_joystick, 3);
|
m_axis21 = SDL_JoystickGetAxis(m_private->m_joystick, 3);
|
||||||
}else{
|
}else{
|
||||||
m_axis10 = 0;m_axis11 = 0;
|
m_axis10 = m_axis11 = m_axis20 = m_axis21 = 0;
|
||||||
m_axis20 = 0;m_axis21 = 0;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCA_Joystick::pGetAxis(int axisnum, int udlr)
|
int SCA_Joystick::pGetAxis(int axisnum, int udlr)
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
if(axisnum == 1 && udlr == 1)return m_axis10; //u/d
|
if(axisnum == 1 && udlr == 1)return m_axis10; //u/d
|
||||||
if(axisnum == 1 && udlr == 0)return m_axis11; //l/r
|
if(axisnum == 1 && udlr == 0)return m_axis11; //l/r
|
||||||
if(axisnum == 2 && udlr == 0)return m_axis20; //...
|
if(axisnum == 2 && udlr == 0)return m_axis20; //...
|
||||||
if(axisnum == 2 && udlr == 1)return m_axis21;
|
if(axisnum == 2 && udlr == 1)return m_axis21;
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ class SCA_Joystick
|
|||||||
static int m_refCount;
|
static int m_refCount;
|
||||||
|
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
PrivateData *m_private;
|
PrivateData *m_private;
|
||||||
|
#endif
|
||||||
int m_joyindex;
|
int m_joyindex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -104,6 +104,7 @@ class SCA_Joystick
|
|||||||
/* is triggered */
|
/* is triggered */
|
||||||
bool m_istrig;
|
bool m_istrig;
|
||||||
|
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
/*
|
/*
|
||||||
* event callbacks
|
* event callbacks
|
||||||
*/
|
*/
|
||||||
@ -113,7 +114,7 @@ class SCA_Joystick
|
|||||||
void OnButtonDown(SDL_Event *sdl_event);
|
void OnButtonDown(SDL_Event *sdl_event);
|
||||||
void OnNothing(SDL_Event *sdl_event);
|
void OnNothing(SDL_Event *sdl_event);
|
||||||
void OnBallMotion(SDL_Event *sdl_event){}
|
void OnBallMotion(SDL_Event *sdl_event){}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Open the joystick
|
* Open the joystick
|
||||||
*/
|
*/
|
||||||
@ -226,8 +227,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
int Connected(void);
|
int Connected(void);
|
||||||
};
|
};
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
void Joystick_HandleEvents( void );
|
void Joystick_HandleEvents( void );
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "SCA_JoystickPrivate.h"
|
#include "SCA_JoystickPrivate.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
|
void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
|
||||||
{
|
{
|
||||||
pFillAxes();
|
pFillAxes();
|
||||||
@ -102,3 +102,4 @@ void SCA_Joystick::HandleEvents(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define __SCA_JOYSTICKPRIVATE_H__
|
#define __SCA_JOYSTICKPRIVATE_H__
|
||||||
#include "SCA_Joystick.h"
|
#include "SCA_Joystick.h"
|
||||||
|
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
class SCA_Joystick::PrivateData
|
class SCA_Joystick::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -43,3 +44,5 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -63,9 +63,9 @@ void SCA_JoystickManager::NextFrame(double curtime,double deltatime)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
set<SCA_ISensor*>::iterator it;
|
set<SCA_ISensor*>::iterator it;
|
||||||
|
#ifndef DISABLE_SDL
|
||||||
SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */
|
SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */
|
||||||
|
#endif
|
||||||
for (it = m_sensors.begin(); it != m_sensors.end(); it++)
|
for (it = m_sensors.begin(); it != m_sensors.end(); it++)
|
||||||
{
|
{
|
||||||
SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it);
|
SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it);
|
||||||
|
@ -10,4 +10,9 @@ incs += ' #/source/gameengine/Rasterizer'
|
|||||||
incs += ' ' + env['BF_PYTHON_INC']
|
incs += ' ' + env['BF_PYTHON_INC']
|
||||||
incs += ' ' + env['BF_SDL_INC']
|
incs += ' ' + env['BF_SDL_INC']
|
||||||
|
|
||||||
env.BlenderLib ( 'bf_logic', sources, Split(incs), [], libtype=['game','player'], priority=[30, 110] )
|
defs = ''
|
||||||
|
|
||||||
|
if not env['WITH_BF_SDL']:
|
||||||
|
defs += ' DISABLE_SDL'
|
||||||
|
|
||||||
|
env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[30, 110] )
|
||||||
|
Loading…
Reference in New Issue
Block a user