X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-feedback.cpp;h=f4c79b6dd07c3415313f21d5533918828bb5ac2a;hb=a4839616da3ddeada6d8f17cbd6883b6cdf87626;hp=1be858997bdd3d913e39c41decd171313ce37e61;hpb=817a7a2d725de64026fe2efcf7b39eaf93446e7c;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/plugins/dali-feedback.cpp b/plugins/dali-feedback.cpp index 1be8589..f4c79b6 100644 --- a/plugins/dali-feedback.cpp +++ b/plugins/dali-feedback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -21,149 +21,85 @@ #include "dali-feedback.h" // EXTERNAL INCLUDES -#include -#include #include #include #include +#include +#include #include -#define DEBUG_PRINTF(fmt, arg...) LOGD(" "fmt, ##arg) +#define DEBUG_PRINTF(fmt, arg...) LOGD(" " fmt, ##arg) using std::string; using namespace Dali; // The plugin factories -extern "C" DALI_EXPORT_API Dali::FeedbackPlugin* CreateFeedbackPlugin(void) +extern "C" DALI_ADAPTOR_API Dali::FeedbackPlugin* CreateFeedbackPlugin(void) { return new Dali::Plugin::DaliFeedback; } namespace Dali { - namespace Plugin { - DaliFeedback::DaliFeedback() -: mHapticInitialized( false ) { feedback_initialize(); - - if( 0 == haptic_open( HAPTIC_DEVICE_0, &mDeviceHandle ) ) - { - mHapticInitialized = true; - } - else - { - DEBUG_PRINTF( "Haptic feedback controller failed to initialize\n" ); - } } DaliFeedback::~DaliFeedback() { - if( mHapticInitialized ) - { - int errorCode = haptic_close( mDeviceHandle ); - if( errorCode < 0 ) - { - DEBUG_PRINTF( "device_haptic_close() failed with error code: %d\n", errorCode ); - } - } - feedback_deinitialize(); } -void DaliFeedback::PlayHaptic( const std::string& filePath ) +void DaliFeedback::PlayHaptic(const std::string& filePath) { - if( mHapticInitialized ) - { - if ( filePath.size() == 0 ) - { - DEBUG_PRINTF( "File Path can't be NULL!\n" ); - return; - } - - int errorCode = haptic_vibrate_file_with_detail( mDeviceHandle, filePath.c_str(), HAPTIC_ITERATION_ONCE, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, NULL ); - if( errorCode != 0 ) - { - DEBUG_PRINTF( "PlayHaptic() failed with error code: %d\n", errorCode ); - } - } - else - { - DEBUG_PRINTF( "HapticPlayer is not Initialized\n" ); - } } -void DaliFeedback::PlayHapticMonotone( unsigned int duration ) +void DaliFeedback::PlayHapticMonotone(unsigned int duration) { - if( mHapticInitialized ) - { - int errorCode = haptic_vibrate_monotone_with_detail( mDeviceHandle, duration, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, NULL ); - if( errorCode != 0 ) - { - DEBUG_PRINTF( "PlayHapticMonotone() failed with error code: %d\n", errorCode ); - } - } - else - { - DEBUG_PRINTF( "HapticPlayer is not Initialized\n" ); - } } void DaliFeedback::StopHaptic() { - if( mHapticInitialized ) - { - int errorCode = haptic_stop_all_effects( mDeviceHandle ); - if( errorCode != 0 ) - { - DEBUG_PRINTF( "StopHaptic() failed with error code: %d\n", errorCode ); - } - } - else - { - DEBUG_PRINTF( "HapticPlayer is not Initialized\n" ); - } } -int DaliFeedback::PlaySound( const std::string& fileName ) +int DaliFeedback::PlaySound(const std::string& fileName) { - int handle = -1; - int errorCode = mm_sound_play_keysound( fileName.c_str(), VOLUME_TYPE_SYSTEM & VOLUME_GAIN_TOUCH ); - if( errorCode < 0 ) + int handle = -1; + int errorCode = mm_sound_play_keysound(fileName.c_str(), VOLUME_TYPE_SYSTEM & VOLUME_GAIN_TOUCH); + if(errorCode < 0) { - DEBUG_PRINTF( "PlaySound() %s failed with error code = %d\n", fileName.c_str(), errorCode ); + DEBUG_PRINTF("PlaySound() %s failed with error code = %d\n", fileName.c_str(), errorCode); } return handle; } -void DaliFeedback::StopSound( int handle ) +void DaliFeedback::StopSound(int handle) { - int errorCode = mm_sound_stop_sound( handle ); - if( errorCode < 0 ) + int errorCode = mm_sound_stop_keysound(NULL); + if(errorCode < 0) { - DEBUG_PRINTF( "StopSound() handle = %d failed with error code = %d\n", handle, errorCode); + DEBUG_PRINTF("StopSound() handle = %d failed with error code = %d\n", handle, errorCode); } else { - DEBUG_PRINTF( "stop handle %d success\n", handle ); + DEBUG_PRINTF("stop handle %d success\n", handle); } } -void DaliFeedback::PlayFeedbackPattern( int type, int pattern ) +void DaliFeedback::PlayFeedbackPattern(int type, int pattern) { - int errorCode = feedback_play_type( static_cast(type), static_cast(pattern) ); - if( errorCode != 0 ) + int errorCode = feedback_play_type(static_cast(type), static_cast(pattern)); + if(errorCode != 0) { - DEBUG_PRINTF( "DaliFeedback::PlayFeedbackPattern() with type = %d, pattern = %d returned with error = %d\n", (int)type, (int)pattern, errorCode ); + DEBUG_PRINTF("DaliFeedback::PlayFeedbackPattern() with type = %d, pattern = %d returned with error = %d\n", (int)type, (int)pattern, errorCode); } } } // namespace Plugin } // namespace Dali -