From e63698aa43fa0df3833d08e13514bf3dcc327073 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 17 Dec 2006 03:18:26 +0000 Subject: [PATCH] add LightsDriver_Export --- stepmania/src/Makefile.am | 1 + .../src/arch/Lights/LightsDriver_Export.cpp | 50 +++++++++++++++++++ .../src/arch/Lights/LightsDriver_Export.h | 49 ++++++++++++++++++ stepmania/src/arch/arch.cpp | 3 ++ stepmania/src/arch/arch_default.h | 1 + 5 files changed, 104 insertions(+) create mode 100644 stepmania/src/arch/Lights/LightsDriver_Export.cpp create mode 100644 stepmania/src/arch/Lights/LightsDriver_Export.h diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 4cc93e0482..5bde8fc544 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -196,6 +196,7 @@ MovieTexture += arch/MovieTexture/MovieTexture_FFMpeg.cpp arch/MovieTexture/Movi endif Lights = arch/Lights/LightsDriver.h \ + arch/Lights/LightsDriver_Export.cpp arch/Lights/LightsDriver_Export.h \ arch/Lights/LightsDriver_SystemMessage.cpp arch/Lights/LightsDriver_SystemMessage.h MemoryCard = arch/MemoryCard/MemoryCardDriver.cpp arch/MemoryCard/MemoryCardDriver.h diff --git a/stepmania/src/arch/Lights/LightsDriver_Export.cpp b/stepmania/src/arch/Lights/LightsDriver_Export.cpp new file mode 100644 index 0000000000..51ea2dc69c --- /dev/null +++ b/stepmania/src/arch/Lights/LightsDriver_Export.cpp @@ -0,0 +1,50 @@ +#include "global.h" +#include "LightsDriver_Export.h" + +RageMutex LightsDriver_Export::m_Lock( "LightsDriver_Export"); +LightsState LightsDriver_Export::m_State; + +LightsDriver_Export::LightsDriver_Export() +{ + memset( &m_State, 0, sizeof(m_State) ); +} + +void LightsDriver_Export::Set( const LightsState *ls ) +{ + m_Lock.Lock(); + m_State = *ls; + m_Lock.Unlock(); +} + +LightsState LightsDriver_Export::GetState() +{ + m_Lock.Lock(); + LightsState ret( m_State ); + m_Lock.Unlock(); + return ret; +} + +/* + * (c) 2006 Glenn Maynard + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/arch/Lights/LightsDriver_Export.h b/stepmania/src/arch/Lights/LightsDriver_Export.h new file mode 100644 index 0000000000..e7a44e30ca --- /dev/null +++ b/stepmania/src/arch/Lights/LightsDriver_Export.h @@ -0,0 +1,49 @@ +/* LightsDriver_Export - Export lights data for other devices that supply lights as a secondary service. */ + +#ifndef LIGHTS_DRIVER_EXPORT_H +#define LIGHTS_DRIVER_EXPORT_H + +#include "LightsDriver.h" +#include "RageThreads.h" + +class LightsDriver_Export: public LightsDriver +{ +public: + LightsDriver_Export(); + virtual void Set( const LightsState *ls ); + + /* Get the current lights state. This can be called from a thread. */ + static LightsState GetState(); + +private: + static RageMutex m_Lock; + static LightsState m_State; +}; +#define USE_LIGHTS_DRIVER_EXPORT + +#endif + +/* + * (c) 2006 Glenn Maynard + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/arch/arch.cpp b/stepmania/src/arch/arch.cpp index 4525f59af7..b2ae43abc6 100644 --- a/stepmania/src/arch/arch.cpp +++ b/stepmania/src/arch/arch.cpp @@ -27,6 +27,9 @@ void MakeLightsDrivers( const RString &driver, vector &Add ) #ifdef USE_LIGHTS_DRIVER_WIN32_PARALLEL if( !driver.CompareNoCase("Parallel") ) ret = new LightsDriver_Win32Parallel; #endif +#ifdef USE_LIGHTS_DRIVER_EXPORT + if( !driver.CompareNoCase("Export") ) ret = new LightsDriver_Export; +#endif if( ret == NULL && driver.CompareNoCase("Null") ) LOG->Trace( "Unknown lights driver name: %s", driver.c_str() ); diff --git a/stepmania/src/arch/arch_default.h b/stepmania/src/arch/arch_default.h index e59ffe9210..1a7d5822c0 100644 --- a/stepmania/src/arch/arch_default.h +++ b/stepmania/src/arch/arch_default.h @@ -61,6 +61,7 @@ #endif /* All use these. */ +#include "Lights/LightsDriver_Export.h" #include "Lights/LightsDriver_SystemMessage.h" #include "Lights/LightsDriver_Null.h" #include "LoadingWindow/LoadingWindow_Null.h"