From d732c0763f411b098850f6434610cefc67049f13 Mon Sep 17 00:00:00 2001 From: Lee Morgan Date: Fri, 3 Jul 2015 15:38:23 +0100 Subject: [PATCH] Removed feedback controller Boost dependency Change-Id: I665d99ea19cd0b93910b06683f217cefa2fab4e2 --- adaptors/common/adaptor-impl.cpp | 15 - ...ic-player-impl.cpp => feedback-player-impl.cpp} | 62 ++- adaptors/common/feedback-player-impl.h | 145 +++++ .../common/feedback/default-feedback-theme.json | 20 - adaptors/common/feedback/feedback-controller.cpp | 588 --------------------- adaptors/common/feedback/feedback-controller.h | 182 ------- adaptors/common/feedback/feedback-ids.h | 105 ---- adaptors/common/file.list | 3 +- adaptors/common/haptic-player-impl.h | 125 ----- .../adaptor-framework/feedback-player.cpp | 80 +++ .../{haptic-player.h => feedback-player.h} | 56 +- .../devel-api/adaptor-framework/haptic-player.cpp | 60 --- adaptors/devel-api/file.list | 4 +- build/tizen/adaptor/Makefile.am | 9 - 14 files changed, 317 insertions(+), 1137 deletions(-) rename adaptors/common/{haptic-player-impl.cpp => feedback-player-impl.cpp} (52%) create mode 100644 adaptors/common/feedback-player-impl.h delete mode 100644 adaptors/common/feedback/default-feedback-theme.json delete mode 100644 adaptors/common/feedback/feedback-controller.cpp delete mode 100644 adaptors/common/feedback/feedback-controller.h delete mode 100644 adaptors/common/feedback/feedback-ids.h delete mode 100644 adaptors/common/haptic-player-impl.h create mode 100644 adaptors/devel-api/adaptor-framework/feedback-player.cpp rename adaptors/devel-api/adaptor-framework/{haptic-player.h => feedback-player.h} (52%) delete mode 100644 adaptors/devel-api/adaptor-framework/haptic-player.cpp diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index 70c829d..9feac44 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -40,8 +40,6 @@ #include #include #include -#include -#include #include #include #include @@ -152,8 +150,6 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mUpdateRenderController = new UpdateRenderController( *this, *mEnvironmentOptions ); - mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME ); - // Should be called after Core creation if( mEnvironmentOptions->GetPanGestureLoggingLevel() ) { @@ -209,9 +205,6 @@ Adaptor::~Adaptor() delete mCore; delete mEglFactory; - // Delete feedback controller before feedback plugin & style monitor dependencies - delete mFeedbackController; - delete mDaliFeedbackPlugin; delete mGLES; delete mGestureManager; delete mPlatformAbstraction; @@ -271,12 +264,6 @@ void Adaptor::Start() ProcessCoreEvents(); // Ensure any startup messages are processed. - if ( !mFeedbackController ) - { - // Start sound & haptic feedback - mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin ); - } - for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) { (*iter)->OnStart(); @@ -785,8 +772,6 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac mNotificationOnIdleInstalled( false ), mNotificationTrigger(NULL), mGestureManager(NULL), - mDaliFeedbackPlugin(NULL), - mFeedbackController(NULL), mObservers(), mDragAndDropDetector(), mDeferredRotationObserver(NULL), diff --git a/adaptors/common/haptic-player-impl.cpp b/adaptors/common/feedback-player-impl.cpp similarity index 52% rename from adaptors/common/haptic-player-impl.cpp rename to adaptors/common/feedback-player-impl.cpp index 9df0ded..29a9a86 100644 --- a/adaptors/common/haptic-player-impl.cpp +++ b/adaptors/common/feedback-player-impl.cpp @@ -16,9 +16,10 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES +#include #include // INTERNAL INCLUDES @@ -39,36 +40,36 @@ namespace // unnamed namespace // Type Registration Dali::BaseHandle Create() { - return HapticPlayer::Get(); + return FeedbackPlayer::Get(); } -Dali::TypeRegistration HAPTIC_PLAYER_TYPE( typeid(Dali::HapticPlayer), typeid(Dali::BaseHandle), Create ); +Dali::TypeRegistration FEEDBACK_PLAYER_TYPE( typeid(Dali::FeedbackPlayer), typeid(Dali::BaseHandle), Create ); } // unnamed namespace -Dali::HapticPlayer HapticPlayer::New() +Dali::FeedbackPlayer FeedbackPlayer::New() { - Dali::HapticPlayer player = Dali::HapticPlayer( new HapticPlayer() ); + Dali::FeedbackPlayer player = Dali::FeedbackPlayer( new FeedbackPlayer() ); return player; } -Dali::HapticPlayer HapticPlayer::Get() +Dali::FeedbackPlayer FeedbackPlayer::Get() { - Dali::HapticPlayer player; + Dali::FeedbackPlayer player; Dali::SingletonService service( SingletonService::Get() ); if ( service ) { // Check whether the singleton is already created - Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::HapticPlayer ) ); + Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::FeedbackPlayer ) ); if ( handle ) { // If so, downcast the handle - player = Dali::HapticPlayer( dynamic_cast< HapticPlayer* >( handle.GetObjectPtr() ) ); + player = Dali::FeedbackPlayer( dynamic_cast< FeedbackPlayer* >( handle.GetObjectPtr() ) ); } else { - player = Dali::HapticPlayer( New() ); + player = Dali::FeedbackPlayer( New() ); service.Register( typeid( player ), player ); } } @@ -76,27 +77,58 @@ Dali::HapticPlayer HapticPlayer::Get() return player; } -void HapticPlayer::PlayMonotone( unsigned int duration ) +void FeedbackPlayer::PlayMonotone( unsigned int duration ) { mPlugin.PlayHapticMonotone( duration ); } -void HapticPlayer::PlayFile( const std::string& filePath ) +void FeedbackPlayer::PlayFile( const std::string& filePath ) { mPlugin.PlayHaptic( filePath ); } -void HapticPlayer::Stop() +void FeedbackPlayer::Stop() { mPlugin.StopHaptic(); } -HapticPlayer::HapticPlayer() +int FeedbackPlayer::PlaySound( const std::string& filename ) +{ + return mPlugin.PlaySound(filename); +} + +void FeedbackPlayer::StopSound( int handle ) +{ + mPlugin.StopSound(handle); +} + +void FeedbackPlayer::PlayFeedbackPattern( int type, int pattern ) +{ + mPlugin.PlayFeedbackPattern(type, pattern); +} + +bool FeedbackPlayer::LoadFile(const std::string& filename, std::string& data) +{ + bool loaded = false; + + std::ifstream stream(filename.c_str()); + + if( stream.is_open() ) + { + data.assign((std::istreambuf_iterator(stream)), + std::istreambuf_iterator()); + loaded = true; + } + + return loaded; +} + +FeedbackPlayer::FeedbackPlayer() : mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME ) { } -HapticPlayer::~HapticPlayer() +FeedbackPlayer::~FeedbackPlayer() { } diff --git a/adaptors/common/feedback-player-impl.h b/adaptors/common/feedback-player-impl.h new file mode 100644 index 0000000..937a36a --- /dev/null +++ b/adaptors/common/feedback-player-impl.h @@ -0,0 +1,145 @@ +#ifndef __DALI_INTERNAL_FEEDBACK_PLAYER_H__ +#define __DALI_INTERNAL_FEEDBACK_PLAYER_H__ + +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +class FeedbackPluginProxy; + +/** + * Plays haptic effects. + */ +class FeedbackPlayer : public Dali::BaseObject +{ + +public: + + /** + * Create a FeedbackPlayer. + * This should only be called once by the Adaptor class. + * @return A newly created FeedbackPlayer. + */ + static Dali::FeedbackPlayer New(); + + /** + * Retrieve a handle to the FeedbackPlayer. This creates an instance if none has been created. + * @return A handle to the FeedbackPlayer. + */ + static Dali::FeedbackPlayer Get(); + + /** + * @copydoc Dali::FeedbackPlayer::PlayMonotone() + */ + void PlayMonotone(unsigned int duration); + + /** + * @copydoc Dali::FeedbackPlayer::PlayFile() + */ + void PlayFile( const std::string& filePath ); + + /** + * @copydoc Dali::FeedbackPlayer::Stop() + */ + void Stop(); + + /** + * @copydoc Dali::FeedbackPlayer::PlaySound() + */ + int PlaySound( const std::string& fileName ); + + /** + * @copydoc Dali::FeedbackPlayer::StopSound() + */ + void StopSound( int handle ); + + /** + * @copydoc Dali::FeedbackPlayer::PlayFeedbackPattern() + */ + void PlayFeedbackPattern( int type, int pattern ); + + /** + * @copydoc Dali::FeedbackPlayer::LoadFile() + */ + bool LoadFile(const std::string& filename, std::string& data); + +private: + + /** + * Private Constructor; see also FeedbackPlayer::New() + */ + FeedbackPlayer(); + + /** + * Virtual Destructor + */ + virtual ~FeedbackPlayer(); + + // Undefined + FeedbackPlayer(const FeedbackPlayer&); + + // Undefined + FeedbackPlayer& operator=(FeedbackPlayer&); + +private: + + FeedbackPluginProxy mPlugin; +}; + +} // namespace Adaptor + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Internal::Adaptor::FeedbackPlayer& GetImplementation(Dali::FeedbackPlayer& player) +{ + DALI_ASSERT_ALWAYS( player && "FeedbackPlayer handle is empty" ); + + BaseObject& handle = player.GetBaseObject(); + + return static_cast(handle); +} + +inline const Internal::Adaptor::FeedbackPlayer& GetImplementation(const Dali::FeedbackPlayer& player) +{ + DALI_ASSERT_ALWAYS( player && "FeedbackPlayer handle is empty" ); + + const BaseObject& handle = player.GetBaseObject(); + + return static_cast(handle); +} + +} // namespace Dali + +#endif // __DALI_INTERNAL_FEEDBACK_PLAYER_H__ diff --git a/adaptors/common/feedback/default-feedback-theme.json b/adaptors/common/feedback/default-feedback-theme.json deleted file mode 100644 index 25b0c7d..0000000 --- a/adaptors/common/feedback/default-feedback-theme.json +++ /dev/null @@ -1,20 +0,0 @@ -//****************************************************************************** -// -// Default feedback theme for dali-toolkit -// -//****************************************************************************** -{ - "style": - { - "PushButton": - { - "signals": - [ - { - "type": "clicked", - "sound-feedback-pattern": "FEEDBACK_PATTERN_TAP" - } - ] - } - } -} diff --git a/adaptors/common/feedback/feedback-controller.cpp b/adaptors/common/feedback/feedback-controller.cpp deleted file mode 100644 index dfbd168..0000000 --- a/adaptors/common/feedback/feedback-controller.cpp +++ /dev/null @@ -1,588 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include - -using std::string; -using boost::property_tree::ptree; - -namespace // unnamed namespace -{ - -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New(Debug::General, false, "LOG_FEEDBACK_CONTROLLER"); -#endif - -const char* DEFAULT_FEEDBACK_THEME_PATH = DALI_FEEDBACK_THEME_DIR"default-feedback-theme.json"; - -string LoadFile(const string& filename) -{ - DALI_ASSERT_DEBUG( 0 != filename.length()); - - string contents; - - std::filebuf buf; - buf.open(filename.c_str(), std::ios::in); - if( buf.is_open() ) - { - std::istream stream(&buf); - - // determine data length - stream.seekg(0, std::ios_base::end); - unsigned int length = static_cast( stream.tellg() ); - stream.seekg(0, std::ios_base::beg); - - // allocate a buffer - contents.resize(length); - // read data into buffer - stream.read(&contents[0], length); - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceLoader::LoadFile(%s) - loaded %d bytes\n", filename.c_str(), length ); - } - else - { - DALI_LOG_ERROR("ResourceLoader::LoadFile(%s) - failed to load\n", filename.c_str()); - } - - return contents; -} - -static string FindFilename( const ptree& child ) -{ - boost::optional filename = child.get_optional( "filename" ); - DALI_ASSERT_ALWAYS( filename && "Filename definiton must have 'filename'" ); - - struct stat buf; - - if( 0 == stat( (*filename).c_str(), &buf) ) - { - return *filename; - } - - // else not found - return ""; -} - -} // unnamed namespace - -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ - -struct SignalFeedbackInfo -{ - /** - * Default constructor. - */ - SignalFeedbackInfo() - :mHasHapticFeedbackInfo(false), - mHasSoundFeedbackInfo(false) - { - } - - string mSignalName; - bool mHasHapticFeedbackInfo; - bool mHasSoundFeedbackInfo; - string mHapticFeedbackPattern; - string mSoundFeedbackPattern; - string mHapticFeedbackFile; - string mSoundFeedbackFile; -}; - -typedef std::vector SignalFeedbackInfoContainer; -typedef SignalFeedbackInfoContainer::const_iterator SignalFeedbackInfoConstIter; - -struct FeedbackStyleInfo -{ - /** - * Default constructor. - */ - FeedbackStyleInfo() - { - } - - string mTypeName; - std::vector mSignalFeedbackInfoList; -}; - -static const FeedbackStyleInfo DEFAULT_FEEDBACK_STYLE_INFO; - -FeedbackController::FeedbackController( FeedbackPluginProxy& plugin ) -: mPlugin( plugin ), - mConnections( this ) -{ - string defaultTheme = LoadFile( DEFAULT_FEEDBACK_THEME_PATH ); - LoadTheme( defaultTheme ); - - Dali::ObjectRegistry registry = Dali::Stage::GetCurrent().GetObjectRegistry(); - - registry.ObjectCreatedSignal().Connect( mConnections, &FeedbackController::ObjectCreatedCallback ); - - Dali::StyleMonitor styleMonitor( Dali::StyleMonitor::Get() ); - DALI_ASSERT_DEBUG( styleMonitor && "StyleMonitor not available" ); - styleMonitor.StyleChangeSignal().Connect( mConnections, &FeedbackController::StyleChangedCallback ); -} - -FeedbackController::~FeedbackController() -{ -} - -struct PlayFeedbackFromSignal -{ - PlayFeedbackFromSignal( FeedbackController& controller, const string& typeName, const string& signalName ) - : mController( controller ), - mTypeName( typeName ), - mSignalName( signalName ) - { - } - - void operator()() - { - mController.PlayFeedback( mTypeName, mSignalName ); - } - - FeedbackController& mController; - string mTypeName; - string mSignalName; -}; - -void FeedbackController::ObjectCreatedCallback( BaseHandle handle ) -{ - if( handle ) - { - string type = handle.GetTypeName(); - - const FeedbackStyleInfo styleInfo = GetStyleInfo( type ); - - for( SignalFeedbackInfoConstIter iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter ) - { - const SignalFeedbackInfo& info = *iter; - - if( info.mHasHapticFeedbackInfo || info.mHasSoundFeedbackInfo ) - { - if( !info.mHapticFeedbackPattern.empty() || !info.mHapticFeedbackFile.empty() || - !info.mSoundFeedbackPattern.empty() || !info.mSoundFeedbackFile.empty() ) - { - handle.ConnectSignal( this, - info.mSignalName, - PlayFeedbackFromSignal( *this, type, info.mSignalName ) ); - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::ObjectCreatedCallback found Haptic pattern %s for Object type: %s, Signal Type: %s\n", - info.mHapticFeedbackPattern.c_str(), type.c_str(), info.mSignalName.c_str() ); - } - else - { - DALI_LOG_ERROR("FeedbackController::ObjectCreatedCallback() Warning Inconsistent data in theme file!\n"); - } - } - } - } -} - -const FeedbackStyleInfo& FeedbackController::GetStyleInfo( const string& type ) const -{ - std::map::const_iterator iter( mStyleInfoLut.find( type ) ); - if( iter != mStyleInfoLut.end() ) - { - return iter->second; - } - else - { - return DEFAULT_FEEDBACK_STYLE_INFO; - } -} - -void FeedbackController::StyleChangedCallback( Dali::StyleMonitor styleMonitor, Dali::StyleChange::Type styleChange ) -{ - if( StyleChange::THEME_CHANGE ) - { - const string& userDefinedThemePath = styleMonitor.GetTheme(); - const string& userDefinedTheme = LoadFile( userDefinedThemePath ); - - if( !LoadTheme( userDefinedTheme ) ) - { - DALI_LOG_ERROR("FeedbackController::StyleChangedCallback() User defined theme failed to load! \n"); - - //If there is any problem is using the user defined theme, then fall back to default theme - if( !LoadTheme( DEFAULT_FEEDBACK_THEME_PATH ) ) - { - //If the default theme fails, Then No luck! - DALI_LOG_ERROR("FeedbackController::StyleChangedCallback() Default theme failed to load! \n"); - } - } - } -} - -bool FeedbackController::LoadTheme( const string& data ) -{ - bool result = false; - - try - { - LoadFromString( data ); - - result = true; - } - catch(...) - { - //Problem in user set theme, So fallback to use default theme. - DALI_LOG_ERROR( "FeedbackController::LoadTheme() Failed to load theme\n" ); - } - - return result; -} - -void FeedbackController::LoadFromString( const string& data ) -{ - std::stringstream jsonData( data ); - - ptree node; - - try - { - // tree root is cleared each read_json - boost::property_tree::json_parser::read_json( jsonData, node ); - } - catch( boost::property_tree::json_parser::json_parser_error& error ) - { - DALI_LOG_WARNING( "JSON Parse Error:'%s'\n", error.message().c_str() ); - DALI_LOG_WARNING( "JSON Parse File :'%s'\n", error.filename().c_str() ); - DALI_LOG_WARNING( "JSON Parse Line :'%d'\n", error.line() ); - throw; - } - catch(...) - { - throw; - } - - // Clear previously loaded style - - mSoundFilesLut.clear(); - mHapticFilesLut.clear(); - mStyleInfoLut.clear(); - - // Parse filenames - - if ( node.get_child_optional("sounds") ) - { - const ptree& soundsNode = node.get_child( "sounds" ); - const ptree::const_iterator endSoundsIter = soundsNode.end(); - for( ptree::const_iterator iter = soundsNode.begin(); endSoundsIter != iter; ++iter ) - { - const ptree::value_type& keyChild = *iter; - - string key( keyChild.first ); - - boost::optional name( keyChild.second.get_optional("filename") ); - if( name ) - { - string fileName( FindFilename( keyChild.second ) ); - - mSoundFilesLut.insert( std::pair(key, fileName) ); - } - else - { - DALI_LOG_WARNING("Invalid sound file\n"); - } - } - } - - if ( node.get_child_optional("haptic") ) - { - const ptree& hapticNode = node.get_child( "haptic" ); - const ptree::const_iterator endHapticIter = hapticNode.end(); - for( ptree::const_iterator iter = hapticNode.begin(); endHapticIter != iter; ++iter ) - { - const ptree::value_type& keyChild = *iter; - - string key( keyChild.first ); - - boost::optional name( keyChild.second.get_optional("filename") ); - if( name ) - { - string fileName( FindFilename( keyChild.second ) ); - - mHapticFilesLut.insert( std::pair(key, fileName) ); - } - else - { - DALI_LOG_WARNING("Invalid haptic file\n"); - } - } - } - - // Parse style - - const ptree& styleNode = node.get_child( "style" ); - const ptree::const_iterator endIter = styleNode.end(); - for( ptree::const_iterator iter = styleNode.begin(); endIter != iter; ++iter ) - { - const ptree::value_type& keyChild = *iter; - - string key( keyChild.first ); - FeedbackStyleInfo themeInfo; - themeInfo.mTypeName = key; - - const ptree& signalsNode = keyChild.second.get_child( "signals" ); - const ptree::const_iterator endIter = signalsNode.end(); - for( ptree::const_iterator iter = signalsNode.begin(); endIter != iter; ++iter ) - { - const ptree::value_type& signal_child = *iter; - - SignalFeedbackInfo signalFeedbackInfo; - - boost::optional type( signal_child.second.get_optional( "type" ) ); - DALI_ASSERT_ALWAYS( type && "Signal must have a type" ); - - signalFeedbackInfo.mSignalName = *type; - - boost::optional hapticFeedbackPattern( signal_child.second.get_optional( "haptic-feedback-pattern" ) ); - if( hapticFeedbackPattern ) - { - signalFeedbackInfo.mHasHapticFeedbackInfo = true; - signalFeedbackInfo.mHapticFeedbackPattern = *hapticFeedbackPattern; - } - - boost::optional hapticFeedbackFile( signal_child.second.get_optional( "haptic-feedback-file" ) ); - if( hapticFeedbackFile ) - { - signalFeedbackInfo.mHasHapticFeedbackInfo = true; - signalFeedbackInfo.mHapticFeedbackFile = GetHapticPath( *hapticFeedbackFile ); - } - - boost::optional soundFeedbackPattern( signal_child.second.get_optional( "sound-feedback-pattern" ) ); - if( soundFeedbackPattern ) - { - signalFeedbackInfo.mHasSoundFeedbackInfo = true; - signalFeedbackInfo.mSoundFeedbackPattern = *soundFeedbackPattern; - } - - boost::optional soundFeedbackFile( signal_child.second.get_optional( "sound-feedback-file" ) ); - if( soundFeedbackFile ) - { - signalFeedbackInfo.mHasSoundFeedbackInfo = true; - signalFeedbackInfo.mSoundFeedbackFile = GetSoundPath( *soundFeedbackFile ); - } - - if( signalFeedbackInfo.mHasHapticFeedbackInfo || signalFeedbackInfo.mHasSoundFeedbackInfo ) - { - AddSignalInfo( themeInfo, signalFeedbackInfo ); - } - } - - mStyleInfoLut[key] = themeInfo; - } -} - -void FeedbackController::AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo ) -{ - bool updated = false; - std::vector::iterator iter; - - // If info exists for the signal then update it, else add new - for( iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter ) - { - if( (*iter).mSignalName == signalInfo.mSignalName ) - { - (*iter).mHasHapticFeedbackInfo = signalInfo.mHasHapticFeedbackInfo; - (*iter).mHapticFeedbackPattern = signalInfo.mHapticFeedbackPattern; - (*iter).mHapticFeedbackFile = signalInfo.mHapticFeedbackFile; - (*iter).mHasSoundFeedbackInfo = signalInfo.mHasSoundFeedbackInfo; - (*iter).mSoundFeedbackPattern = signalInfo.mSoundFeedbackPattern; - (*iter).mSoundFeedbackFile = signalInfo.mSoundFeedbackFile; - - updated = true; - break; - } - } - - if( !updated ) - { - styleInfo.mSignalFeedbackInfoList.push_back( signalInfo ); - } -} - -string FeedbackController::GetSoundPath( const string& key ) const -{ - std::map::const_iterator iter( mSoundFilesLut.find( key ) ); - string path; - if( iter != mSoundFilesLut.end() ) - { - path = iter->second; - } - else - { - DALI_LOG_WARNING( "Request for sound file '%s' failed\n", key.c_str() ); - DALI_ASSERT_ALWAYS( !"Sound file does not exist" ); - } - return path; -} - -string FeedbackController::GetHapticPath( const string& key ) const -{ - std::map::const_iterator iter( mHapticFilesLut.find( key ) ); - string path; - if( iter != mHapticFilesLut.end() ) - { - path = iter->second; - } - else - { - DALI_LOG_WARNING( "Request for haptic file '%s' failed\n", key.c_str() ); - DALI_ASSERT_ALWAYS( !"Haptic file does not exist" ); - } - return path; -} - -void FeedbackController::PlayFeedback(const string& type, const string& signalName) -{ - const FeedbackStyleInfo styleInfo = GetStyleInfo(type); - SignalFeedbackInfoConstIter iter; - - for(iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter) - { - const SignalFeedbackInfo& info = *iter; - - if(info.mSignalName == signalName) - { - if(info.mHasHapticFeedbackInfo) - { - if(!info.mHapticFeedbackPattern.empty()) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::PlayFeedback Playing Haptic effect: Object type: %s, Signal type: %s, pattern type: %s\n", - type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str()); - - mPlugin.PlayFeedbackPattern( FEEDBACK_TYPE_VIBRATION, GetFeedbackPattern(info.mHapticFeedbackPattern) ); - } - else if(!info.mHapticFeedbackFile.empty()) - { - mPlugin.PlayHaptic( info.mHapticFeedbackFile ); - } - } - - if(info.mHasSoundFeedbackInfo) - { - if(!info.mSoundFeedbackPattern.empty()) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::PlayFeedback Playing Sound effect: Object type: %s, Signal type: %s, pattern type: %s\n", - type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str()); - - mPlugin.PlayFeedbackPattern( FEEDBACK_TYPE_SOUND, GetFeedbackPattern(info.mSoundFeedbackPattern) ); - } - else if(!info.mSoundFeedbackFile.empty()) - { - mPlugin.PlaySound( info.mSoundFeedbackFile ); - } - } - - break; - } - } -} - -FeedbackPattern FeedbackController::GetFeedbackPattern( const string &pattern ) -{ - if( 0 == mFeedbackPatternLut.size() ) - { - mFeedbackPatternLut["FEEDBACK_PATTERN_NONE"] = Dali::FEEDBACK_PATTERN_NONE; - mFeedbackPatternLut["FEEDBACK_PATTERN_TAP"] = Dali::FEEDBACK_PATTERN_TAP; - mFeedbackPatternLut["FEEDBACK_PATTERN_SIP"] = Dali::FEEDBACK_PATTERN_SIP; - mFeedbackPatternLut["FEEDBACK_PATTERN_SIP_BACKSPACE"] = Dali::FEEDBACK_PATTERN_SIP_BACKSPACE; - mFeedbackPatternLut["FEEDBACK_PATTERN_MAX_CHARACTER"] = Dali::FEEDBACK_PATTERN_MAX_CHARACTER; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY0"] = Dali::FEEDBACK_PATTERN_KEY0; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY1"] = Dali::FEEDBACK_PATTERN_KEY1; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY2"] = Dali::FEEDBACK_PATTERN_KEY2; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY3"] = Dali::FEEDBACK_PATTERN_KEY3; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY4"] = Dali::FEEDBACK_PATTERN_KEY4; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY5"] = Dali::FEEDBACK_PATTERN_KEY5; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY6"] = Dali::FEEDBACK_PATTERN_KEY6; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY7"] = Dali::FEEDBACK_PATTERN_KEY7; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY8"] = Dali::FEEDBACK_PATTERN_KEY8; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY9"] = Dali::FEEDBACK_PATTERN_KEY9; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_STAR"] = Dali::FEEDBACK_PATTERN_KEY_STAR; - mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_SHARP"] = Dali::FEEDBACK_PATTERN_KEY_SHARP; - mFeedbackPatternLut["FEEDBACK_PATTERN_HOLD"] = Dali::FEEDBACK_PATTERN_HOLD; - mFeedbackPatternLut["FEEDBACK_PATTERN_MULTI_TAP"] = Dali::FEEDBACK_PATTERN_MULTI_TAP; - mFeedbackPatternLut["FEEDBACK_PATTERN_HW_TAP"] = Dali::FEEDBACK_PATTERN_HW_TAP; - mFeedbackPatternLut["FEEDBACK_PATTERN_HW_HOLD"] = Dali::FEEDBACK_PATTERN_HW_HOLD; - mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE"] = Dali::FEEDBACK_PATTERN_MESSAGE; - mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE_ON_CALL"] = Dali::FEEDBACK_PATTERN_MESSAGE_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL"] = Dali::FEEDBACK_PATTERN_EMAIL; - mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL_ON_CALL"] = Dali::FEEDBACK_PATTERN_EMAIL_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP"] = Dali::FEEDBACK_PATTERN_WAKEUP; - mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP_ON_CALL"] = Dali::FEEDBACK_PATTERN_WAKEUP_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE"] = Dali::FEEDBACK_PATTERN_SCHEDULE; - mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE_ON_CALL"] = Dali::FEEDBACK_PATTERN_SCHEDULE_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER"] = Dali::FEEDBACK_PATTERN_TIMER; - mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER_ON_CALL"] = Dali::FEEDBACK_PATTERN_TIMER_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL"] = Dali::FEEDBACK_PATTERN_GENERAL; - mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL_ON_CALL"] = Dali::FEEDBACK_PATTERN_GENERAL_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_POWERON"] = Dali::FEEDBACK_PATTERN_POWERON; - mFeedbackPatternLut["FEEDBACK_PATTERN_POWEROFF"] = Dali::FEEDBACK_PATTERN_POWEROFF; - mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN"] = Dali::FEEDBACK_PATTERN_CHARGERCONN; - mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN_ON_CALL"] = Dali::FEEDBACK_PATTERN_CHARGERCONN_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED"] = Dali::FEEDBACK_PATTERN_FULLCHARGED; - mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED_ON_CALL"] = Dali::FEEDBACK_PATTERN_FULLCHARGED_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT"] = Dali::FEEDBACK_PATTERN_LOWBATT; - mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT_ON_CALL"] = Dali::FEEDBACK_PATTERN_LOWBATT_ON_CALL; - mFeedbackPatternLut["FEEDBACK_PATTERN_LOCK"] = Dali::FEEDBACK_PATTERN_LOCK; - mFeedbackPatternLut["FEEDBACK_PATTERN_UNLOCK"] = Dali::FEEDBACK_PATTERN_UNLOCK; - mFeedbackPatternLut["FEEDBACK_PATTERN_CALLCONNECT"] = Dali::FEEDBACK_PATTERN_CALLCONNECT; - mFeedbackPatternLut["FEEDBACK_PATTERN_DISCALLCONNECT"] = Dali::FEEDBACK_PATTERN_DISCALLCONNECT; - mFeedbackPatternLut["FEEDBACK_PATTERN_MINUTEMINDER"] = Dali::FEEDBACK_PATTERN_MINUTEMINDER; - mFeedbackPatternLut["FEEDBACK_PATTERN_VIBRATION"] = Dali::FEEDBACK_PATTERN_VIBRATION; - mFeedbackPatternLut["FEEDBACK_PATTERN_SHUTTER"] = Dali::FEEDBACK_PATTERN_SHUTTER; - mFeedbackPatternLut["FEEDBACK_PATTERN_LIST_REORDER"] = Dali::FEEDBACK_PATTERN_LIST_REORDER; - mFeedbackPatternLut["FEEDBACK_PATTERN_SLIDER_SWEEP"] = Dali::FEEDBACK_PATTERN_SLIDER_SWEEP; - } - - std::map::const_iterator iter( mFeedbackPatternLut.find( pattern ) ); - - if( iter != mFeedbackPatternLut.end() ) - { - return iter->second; - } - else - { - DALI_LOG_ERROR( "Unknown feedback pattern type: %s, So Defaulting to FEEDBACK_PATTERN_NONE!\n" ); - return Dali::FEEDBACK_PATTERN_NONE; - } -} - -} // namespace Adaptor - -} // namespace Internal - -} // namespace Dali diff --git a/adaptors/common/feedback/feedback-controller.h b/adaptors/common/feedback/feedback-controller.h deleted file mode 100644 index f3ef124..0000000 --- a/adaptors/common/feedback/feedback-controller.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__ -#define __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__ - -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ - -struct FeedbackStyleInfo; -struct SignalFeedbackInfo; - -class FeedbackPluginProxy; - -/** - * Plays feedback effects for Dali-Toolkit UI Controls. - */ -class FeedbackController : public ConnectionTracker -{ -public: - - /** - * Constructor. - */ - FeedbackController( FeedbackPluginProxy& plugin ); - - /** - * The destructor - */ - ~FeedbackController(); - - /** - * Called to start playing feedback effects. - */ - void Start(); - - /** - * Called to stop playing feedback effects. - */ - void Stop(); - - /** - * Callback function to play a feedback effect when a signal is emitted for an object - * Plays feedback effect. - * @param [in] type The Object type - * @param [in] signalName The name of the signal - */ - void PlayFeedback(const std::string& type, const std::string& signalName); - -private: - - /** - * UI string data format - */ - enum UIFormat - { - JSON, ///< String is JSON - }; - - /** - * Callback function for Dali::ObjectRegistry::SignalObjectCreated signal - * @param [in] object Handle to the newly created object - */ - void ObjectCreatedCallback( BaseHandle object ); - - /** - * Helper to retrieve styleInfo from mStyleInfoLut - * @param type A string described a type of object - * @return The style information for the given object - */ - const FeedbackStyleInfo& GetStyleInfo( const std::string& type) const; - - /** - * Callback function for Dali::ObjectRegistry::SignalObjectCreated signal - * @param [in] object Handle to the newly created object - */ - void StyleChangedCallback(Dali::StyleMonitor styleMonitor, StyleChange::Type styleChange); - - /** - * Callback function for Dali::Toolkit::PushButton::SignalPressed signal - * Plays feedback effect. - * @param [in] effect The feedback effect to play - */ - bool LoadTheme(const std::string& data); - - /** - * Loads a string representation the theme. - * @param [in] data A string represenation of the theme. - * @param [in] format The string representation format ie JSON. - */ - void LoadFromString( const std::string& data ); - - /** - * Helper to store signal information. - * @param [in] styleInfo The information will be stored here. - * @param [in] signalInfo The information to add. - */ - void AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo ); - - /** - * Helper to retrieve the path to a sound file. - * @param[in] key A string which identifies the path. - * @return The path. - */ - std::string GetSoundPath( const std::string& key ) const; - - /** - * Helper to retrieve the path to a haptic file. - * @param[in] key A string which identifies the path. - * @return The path. - */ - std::string GetHapticPath( const std::string& key ) const; - - /** - * Map a pattern string to feedback pattern ID. - * @param [in] pattern The pattern string. - * @return A feedback pattern ID. - */ - FeedbackPattern GetFeedbackPattern( const std::string& pattern ); - - /** - * Plays a feedback effect - * @param [in] type The feedback type haptic or sound - * @param [in] effect The feedback effect to play - */ - void PlayEffect(FeedbackType type, FeedbackPattern effect); - - /** - * Plays a haptic or sound effect file - * @param [in] type The feedback type haptic or sound - * @param [in] file The path to the file containing the effect - */ - void PlayFile(FeedbackType type, const std::string& file); - -private: - - FeedbackPluginProxy& mPlugin; - - std::map mFeedbackPatternLut; ///< Used to convert feedback pattern strings into enumerated values - std::map mSoundFilesLut; ///< Converts key strings into sound file paths - std::map mHapticFilesLut; ///< Converts key strings into haptic file paths - std::map mStyleInfoLut; ///< Converts key strings into style information - - SlotDelegate< FeedbackController > mConnections; ///< Maintains the connections to the Object registry. -}; - -} // namespace Adaptor - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__ diff --git a/adaptors/common/feedback/feedback-ids.h b/adaptors/common/feedback/feedback-ids.h deleted file mode 100644 index e61013d..0000000 --- a/adaptors/common/feedback/feedback-ids.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __DALI_FEEDBACK_IDS_H__ -#define __DALI_FEEDBACK_IDS_H__ - -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -namespace Dali -{ - -/** - * Enumerations for the types of feedback - * Note: These are based on feedback_type_e in libsvi - */ -enum FeedbackType -{ - FEEDBACK_TYPE_NONE, - - FEEDBACK_TYPE_SOUND, - FEEDBACK_TYPE_VIBRATION, - FEEDBACK_TYPE_LED, - - FEEDBACK_TYPE_END -}; - -/** - * The pattern list for feedback effects. - * Note: These are based on feedback_pattern_e in libsvi - */ -enum FeedbackPattern -{ - FEEDBACK_PATTERN_NONE = -1, - - FEEDBACK_PATTERN_TAP = 0, /**< feedback pattern when general touch */ - FEEDBACK_PATTERN_SIP, /**< feedback pattern when touch text key */ - FEEDBACK_PATTERN_SIP_BACKSPACE, /**< feedback pattern when touch backspace key */ - FEEDBACK_PATTERN_MAX_CHARACTER, /**< feedback pattern when max character */ - FEEDBACK_PATTERN_KEY0, /**< feedback pattern when touch numeric 0 key */ - FEEDBACK_PATTERN_KEY1, /**< feedback pattern when touch numeric 1 key */ - FEEDBACK_PATTERN_KEY2, /**< feedback pattern when touch numeric 2 key */ - FEEDBACK_PATTERN_KEY3, /**< feedback pattern when touch numeric 3 key */ - FEEDBACK_PATTERN_KEY4, /**< feedback pattern when touch numeric 4 key */ - FEEDBACK_PATTERN_KEY5, /**< feedback pattern when touch numeric 5 key */ - FEEDBACK_PATTERN_KEY6, /**< feedback pattern when touch numeric 6 key */ - FEEDBACK_PATTERN_KEY7, /**< feedback pattern when touch numeric 7 key */ - FEEDBACK_PATTERN_KEY8, /**< feedback pattern when touch numeric 8 key */ - FEEDBACK_PATTERN_KEY9, /**< feedback pattern when touch numeric 9 key */ - FEEDBACK_PATTERN_KEY_STAR, /**< feedback pattern when touch star key */ - FEEDBACK_PATTERN_KEY_SHARP, /**< feedback pattern when touch sharp key */ - FEEDBACK_PATTERN_HOLD, /**< feedback pattern when touch hold */ - FEEDBACK_PATTERN_MULTI_TAP, /**< feedback pattern when multi touch */ - FEEDBACK_PATTERN_HW_TAP, /**< feedback pattern when press hardware key */ - FEEDBACK_PATTERN_HW_HOLD, /**< feedback pattern when holding press hardware key */ - - FEEDBACK_PATTERN_MESSAGE, /**< feedback pattern when incoming a message */ - FEEDBACK_PATTERN_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */ - FEEDBACK_PATTERN_EMAIL, /**< feedback pattern when incoming an email */ - FEEDBACK_PATTERN_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */ - FEEDBACK_PATTERN_WAKEUP, /**< feedback pattern when alert wake up call */ - FEEDBACK_PATTERN_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */ - FEEDBACK_PATTERN_SCHEDULE, /**< feedback pattern when alert schedule alarm */ - FEEDBACK_PATTERN_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */ - FEEDBACK_PATTERN_TIMER, /**< feedback pattern when alert timer */ - FEEDBACK_PATTERN_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */ - FEEDBACK_PATTERN_GENERAL, /**< feedback pattern when alert general event */ - FEEDBACK_PATTERN_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */ - - FEEDBACK_PATTERN_POWERON, /**< feedback pattern when power on */ - FEEDBACK_PATTERN_POWEROFF, /**< feedback pattern when power off */ - FEEDBACK_PATTERN_CHARGERCONN, /**< feedback pattern when connecting charger */ - FEEDBACK_PATTERN_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */ - FEEDBACK_PATTERN_FULLCHARGED, /**< feedback pattern when full charged */ - FEEDBACK_PATTERN_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */ - FEEDBACK_PATTERN_LOWBATT, /**< feedback pattern when low battery */ - FEEDBACK_PATTERN_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */ - FEEDBACK_PATTERN_LOCK, /**< feedback pattern when lock */ - FEEDBACK_PATTERN_UNLOCK, /**< feedback pattern when unlock */ - FEEDBACK_PATTERN_CALLCONNECT, /**< feedback pattern when connecting call */ - FEEDBACK_PATTERN_DISCALLCONNECT, /**< feedback pattern when disconnecting call */ - FEEDBACK_PATTERN_MINUTEMINDER, /**< feedback pattern when minute minder */ - FEEDBACK_PATTERN_VIBRATION, /**< feedback pattern when vibration */ - FEEDBACK_PATTERN_SHUTTER, /**< feedback pattern when screen capture or camera shutter */ - FEEDBACK_PATTERN_LIST_REORDER, /**< feedback pattern when list reorder */ - FEEDBACK_PATTERN_SLIDER_SWEEP, /**< feedback pattern when slider sweep */ - - FEEDBACK_PATTERN_END, -}; - - -} // namespace Dali - -#endif // __DALI_FEEDBACK_IDS_H__ diff --git a/adaptors/common/file.list b/adaptors/common/file.list index c61bb7c..b30b3fe 100644 --- a/adaptors/common/file.list +++ b/adaptors/common/file.list @@ -10,7 +10,7 @@ adaptor_common_internal_src_files = \ $(adaptor_common_dir)/clipboard-event-notifier-impl.cpp \ $(adaptor_common_dir)/command-line-options.cpp \ $(adaptor_common_dir)/drag-and-drop-detector-impl.cpp \ - $(adaptor_common_dir)/haptic-player-impl.cpp \ + $(adaptor_common_dir)/feedback-player-impl.cpp \ $(adaptor_common_dir)/indicator-impl.cpp \ $(adaptor_common_dir)/indicator-buffer.cpp \ $(adaptor_common_dir)/kernel-trace.cpp \ @@ -42,7 +42,6 @@ adaptor_common_internal_src_files = \ $(adaptor_common_dir)/networking/socket-impl.cpp \ $(adaptor_common_dir)/networking/socket-factory.cpp \ \ - $(adaptor_common_dir)/feedback/feedback-controller.cpp \ $(adaptor_common_dir)/feedback/feedback-plugin-proxy.cpp \ \ $(adaptor_common_dir)/gl/egl-factory.cpp \ diff --git a/adaptors/common/haptic-player-impl.h b/adaptors/common/haptic-player-impl.h deleted file mode 100644 index 9c93e2f..0000000 --- a/adaptors/common/haptic-player-impl.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef __DALI_INTERNAL_HAPTIC_PLAYER_H__ -#define __DALI_INTERNAL_HAPTIC_PLAYER_H__ - -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ - -class FeedbackPluginProxy; - -/** - * Plays haptic effects. - */ -class HapticPlayer : public Dali::BaseObject -{ - -public: - - /** - * Create a HapticPlayer. - * This should only be called once by the Adaptor class. - * @return A newly created HapticPlayer. - */ - static Dali::HapticPlayer New(); - - /** - * Retrieve a handle to the HapticPlayer. This creates an instance if none has been created. - * @return A handle to the HapticPlayer. - */ - static Dali::HapticPlayer Get(); - - /** - * @copydoc Dali::HapticPlayer::PlayMonotone() - */ - void PlayMonotone(unsigned int duration); - - /** - * @copydoc Dali::HapticPlayer::PlayFile() - */ - void PlayFile( const std::string& filePath ); - - /** - * @copydoc Dali::HapticPlayer::Stop() - */ - void Stop(); - -private: - - /** - * Private Constructor; see also HapticPlayer::New() - */ - HapticPlayer(); - - /** - * Virtual Destructor - */ - virtual ~HapticPlayer(); - - // Undefined - HapticPlayer(const HapticPlayer&); - - // Undefined - HapticPlayer& operator=(HapticPlayer&); - -private: - - FeedbackPluginProxy mPlugin; -}; - -} // namespace Adaptor - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Internal::Adaptor::HapticPlayer& GetImplementation(Dali::HapticPlayer& player) -{ - DALI_ASSERT_ALWAYS( player && "HapticPlayer handle is empty" ); - - BaseObject& handle = player.GetBaseObject(); - - return static_cast(handle); -} - -inline const Internal::Adaptor::HapticPlayer& GetImplementation(const Dali::HapticPlayer& player) -{ - DALI_ASSERT_ALWAYS( player && "HapticPlayer handle is empty" ); - - const BaseObject& handle = player.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Dali - -#endif // __DALI_INTERNAL_HAPTIC_PLAYER_H__ diff --git a/adaptors/devel-api/adaptor-framework/feedback-player.cpp b/adaptors/devel-api/adaptor-framework/feedback-player.cpp new file mode 100644 index 0000000..a43a0c0 --- /dev/null +++ b/adaptors/devel-api/adaptor-framework/feedback-player.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +FeedbackPlayer::FeedbackPlayer() +{ +} + +FeedbackPlayer FeedbackPlayer::Get() +{ + return Internal::Adaptor::FeedbackPlayer::Get(); +} + +FeedbackPlayer::~FeedbackPlayer() +{ +} + +void FeedbackPlayer::PlayMonotone(unsigned int duration) +{ + GetImplementation(*this).PlayMonotone(duration); +} + +void FeedbackPlayer::PlayFile(const std::string filePath) +{ + GetImplementation(*this).PlayFile(filePath); +} + +void FeedbackPlayer::Stop() +{ + GetImplementation(*this).Stop(); +} + +int FeedbackPlayer::PlaySound( const std::string& fileName ) +{ + return GetImplementation(*this).PlaySound(fileName); +} + +void FeedbackPlayer::StopSound( int handle ) +{ + GetImplementation(*this).StopSound(handle); +} + +void FeedbackPlayer::PlayFeedbackPattern( int type, int pattern ) +{ + GetImplementation(*this).PlayFeedbackPattern(type, pattern); +} + +bool FeedbackPlayer::LoadFile(const std::string& filename, std::string& data) +{ + return GetImplementation(*this).LoadFile(filename, data); +} + +FeedbackPlayer::FeedbackPlayer( Internal::Adaptor::FeedbackPlayer* player ) +: BaseHandle( player ) +{ +} + +} // namespace Dali diff --git a/adaptors/devel-api/adaptor-framework/haptic-player.h b/adaptors/devel-api/adaptor-framework/feedback-player.h similarity index 52% rename from adaptors/devel-api/adaptor-framework/haptic-player.h rename to adaptors/devel-api/adaptor-framework/feedback-player.h index 5737f5e..0069df1 100644 --- a/adaptors/devel-api/adaptor-framework/haptic-player.h +++ b/adaptors/devel-api/adaptor-framework/feedback-player.h @@ -1,5 +1,5 @@ -#ifndef __DALI_HAPTIC_PLAYER_H__ -#define __DALI_HAPTIC_PLAYER_H__ +#ifndef __DALI_FEEDBACK_PLAYER_H__ +#define __DALI_FEEDBACK_PLAYER_H__ /* * Copyright (c) 2015 Samsung Electronics Co., Ltd. @@ -28,37 +28,37 @@ namespace Internal DALI_INTERNAL { namespace Adaptor { -class HapticPlayer; +class FeedbackPlayer; } } /** - * @brief Plays haptic effects. + * @brief Plays feedback effects. */ -class DALI_IMPORT_API HapticPlayer : public BaseHandle +class DALI_IMPORT_API FeedbackPlayer : public BaseHandle { public: /** * @brief Create an uninitialized handle. * - * This can be initialized by calling HapticPlayer::Get(). + * This can be initialized by calling FeedbackPlayer::Get(). */ - HapticPlayer(); + FeedbackPlayer(); /** - * @brief Create an initialized handle to the HapticPlayer. + * @brief Create an initialized handle to the FeedbackPlayer. * * @return A handle to a newly allocated Dali resource. */ - static HapticPlayer Get(); + static FeedbackPlayer Get(); /** * @brief Destructor * * This is non-virtual since derived Handle types must not contain data or virtual methods. */ - ~HapticPlayer(); + ~FeedbackPlayer(); /** * @brief Plays a monotone vibration. @@ -77,15 +77,43 @@ public: */ void Stop(); + /** + * Plays a sound file. + * @param[in] fileName Path to the sound file to play. + * @return A handle which can be used to stop the sound playback. + */ + int PlaySound( const std::string& fileName ); + + /** + * Stops a currently playing sound. + * @param[in] handle A handle to the currently playing sound. + */ + void StopSound( int handle ); + + /** + * Plays a feedback pattern. + * @param[in] type The type of feedback. + * @param[in] pattern The ID of the pattern to play. + */ + void PlayFeedbackPattern( int type, int pattern ); + + /* + * Loads a file into data + * @param[in] filename The filename. + * @param[in] data The data in the file. + * @return True if the file data could be loaded + */ + bool LoadFile(const std::string& filename, std::string& data); + public: // Not intended for application developers /** - * @brief This constructor is used by HapticPlayer::Get(). - * @param[in] hapticPlayer A pointer to the haptic player. + * @brief This constructor is used by FeedbackPlayer::Get(). + * @param[in] feedbackPlayer A pointer to the feedback player. */ - explicit DALI_INTERNAL HapticPlayer( Internal::Adaptor::HapticPlayer* hapticPlayer ); + explicit DALI_INTERNAL FeedbackPlayer( Internal::Adaptor::FeedbackPlayer* feedbackPlayer ); }; } // namespace Dali -#endif // __DALI_HAPTIC_PLAYER_H__ +#endif // __DALI_FEEDBACK_PLAYER_H__ diff --git a/adaptors/devel-api/adaptor-framework/haptic-player.cpp b/adaptors/devel-api/adaptor-framework/haptic-player.cpp deleted file mode 100644 index 7cab024..0000000 --- a/adaptors/devel-api/adaptor-framework/haptic-player.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -HapticPlayer::HapticPlayer() -{ -} - -HapticPlayer HapticPlayer::Get() -{ - return Internal::Adaptor::HapticPlayer::Get(); -} - -HapticPlayer::~HapticPlayer() -{ -} - -void HapticPlayer::PlayMonotone(unsigned int duration) -{ - GetImplementation(*this).PlayMonotone(duration); -} - -void HapticPlayer::PlayFile(const std::string filePath) -{ - GetImplementation(*this).PlayFile(filePath); -} - -void HapticPlayer::Stop() -{ - GetImplementation(*this).Stop(); -} - -HapticPlayer::HapticPlayer( Internal::Adaptor::HapticPlayer* player ) -: BaseHandle( player ) -{ -} - -} // namespace Dali diff --git a/adaptors/devel-api/file.list b/adaptors/devel-api/file.list index a34e507..77443c7 100644 --- a/adaptors/devel-api/file.list +++ b/adaptors/devel-api/file.list @@ -7,7 +7,7 @@ devel_api_src_files = \ $(adaptor_devel_api_dir)/adaptor-framework/color-controller.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/drag-and-drop-detector.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/event-feeder.cpp \ - $(adaptor_devel_api_dir)/adaptor-framework/haptic-player.cpp \ + $(adaptor_devel_api_dir)/adaptor-framework/feedback-player.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/imf-manager.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/orientation.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/performance-logger.cpp \ @@ -32,7 +32,7 @@ devel_api_adaptor_framework_header_files = \ $(adaptor_devel_api_dir)/adaptor-framework/drag-and-drop-detector.h \ $(adaptor_devel_api_dir)/adaptor-framework/event-feeder.h \ $(adaptor_devel_api_dir)/adaptor-framework/feedback-plugin.h \ - $(adaptor_devel_api_dir)/adaptor-framework/haptic-player.h \ + $(adaptor_devel_api_dir)/adaptor-framework/feedback-player.h \ $(adaptor_devel_api_dir)/adaptor-framework/imf-manager.h \ $(adaptor_devel_api_dir)/adaptor-framework/lifecycle-controller.h \ $(adaptor_devel_api_dir)/adaptor-framework/orientation.h \ diff --git a/build/tizen/adaptor/Makefile.am b/build/tizen/adaptor/Makefile.am index 85df3fc..f99e56e 100644 --- a/build/tizen/adaptor/Makefile.am +++ b/build/tizen/adaptor/Makefile.am @@ -179,14 +179,6 @@ endif pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = dali-adaptor-integration.pc -# Feedback Plugin -if USE_FEEDBACK -plugin_themes_dir = ../../../adaptors/common/feedback -dali_plugin_theme_files = $(plugin_themes_dir)/default-feedback-theme.json -dalifeedbackthemedir = ${dataReadOnlyDir}/themes/feedback-themes/ -dalifeedbacktheme_DATA = ${dali_plugin_theme_files} -endif - lib_LTLIBRARIES = libdali-adaptor.la libdali_adaptor_la_SOURCES = \ @@ -251,7 +243,6 @@ libdali_adaptor_la_CXXFLAGS = \ -DFONT_DOWNLOADED_PATH="\"${fontDownloadedPath}\"" \ -DFONT_APPLICATION_PATH="\"${fontApplicationPath}\"" \ -DFONT_CONFIGURATION_FILE_PATH="\"${fontConfigurationFilePath}\"" \ - -DDALI_FEEDBACK_THEME_DIR="\"${dalifeedbackthemedir}\"" \ -DNON_POWER_OF_TWO_TEXTURES \ -DDALI_COMPILATION -DDALI_ADAPTOR_COMPILATION \ -Werror -Wall -lgcc \ -- 2.7.4