Formatting API
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / feedback-plugin.h
1 #ifndef DALI_FEEDBACK_PLUGIN_H
2 #define DALI_FEEDBACK_PLUGIN_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26
27 namespace Dali
28 {
29 /**
30  * FeedbackPlugin is an abstract interface, used by Dali-adaptor to access haptic and audio feedback.
31  * A concrete implementation must be created for each platform and provided as a dynamic library which
32  * will be loaded at run time by the adaptor.
33  */
34 class FeedbackPlugin
35 {
36 public:
37   typedef void (*SoundStopCallBack)(void* ptr);
38
39   /**
40    * Destructor.
41    */
42   virtual ~FeedbackPlugin()
43   {
44   }
45
46   /**
47    * Plays vibration in predefined patterns.
48    * @param[in] filePath Path to the file containing the effect.
49    */
50   virtual void PlayHaptic(const std::string& filePath) = 0;
51
52   /**
53    * Plays a monotone vibration.
54    * @param[in]  duration  The duration of the vibration.
55    */
56   virtual void PlayHapticMonotone(unsigned int duration) = 0;
57
58   /**
59    * Stops the currently playing vibration effects.
60    */
61   virtual void StopHaptic() = 0;
62
63   /**
64    * Plays a sound file.
65    * @param[in] fileName Path to the sound file to play.
66    * @return A handle which can be used to stop the sound playback.
67    */
68   virtual int PlaySound(const std::string& fileName) = 0;
69
70   /**
71    * Stops a currently playing sound.
72    * @param[in] handle A handle to the currently playing sound.
73    */
74   virtual void StopSound(int handle) = 0;
75
76   /**
77    * Plays a feedback pattern.
78    * @param[in] type The type of feedback.
79    * @param[in] pattern The ID of the pattern to play.
80    */
81   virtual void PlayFeedbackPattern(int type, int pattern) = 0;
82
83   // Types for plugin factories
84
85   /**
86    * Function pointer called in adaptor to create a feedback plugin instance.
87    * @param [in] pluginName name of the plugin to load.
88    * @return Pointer to the newly created plugin object
89    */
90   typedef FeedbackPlugin* CreateFeedbackPlugin(void);
91
92 }; // class FeedbackPlugin
93
94 } // namespace Dali
95
96 #endif // DALI_FEEDBACK_PLUGIN_H