1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef I_VIBRATOR_HDI_CONNECTION_H
17 #define I_VIBRATOR_HDI_CONNECTION_H
18 
19 #include <optional>
20 #include <stdint.h>
21 #include <string>
22 
23 #include <nocopyable.h>
24 #include "v1_2/vibrator_types.h"
25 #include "v1_3/ivibrator_interface.h"
26 #include "vibrator_infos.h"
27 
28 namespace OHOS {
29 namespace Sensors {
30 using OHOS::HDI::Vibrator::V1_2::HdfVibratorModeV1_2;
31 using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_ONCE;
32 using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_PRESET;
33 using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_HDHAPTIC;
34 using OHOS::HDI::Vibrator::V1_2::HDF_VIBRATOR_MODE_BUTT;
35 using OHOS::HDI::Vibrator::V1_2::CurvePoint;
36 using OHOS::HDI::Vibrator::V1_2::EVENT_TYPE;
37 using OHOS::HDI::Vibrator::V1_2::HapticCapacity;
38 using OHOS::HDI::Vibrator::V1_2::HapticPaket;
39 using OHOS::HDI::Vibrator::V1_2::HapticEvent;
40 using OHOS::HDI::Vibrator::V1_1::HdfEffectInfo;
41 using OHOS::HDI::Vibrator::V1_3::HdfWaveInformation;
42 #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
43 using OHOS::HDI::Vibrator::V1_1::HdfEffectType;
44 using OHOS::HDI::Vibrator::V1_1::HDF_EFFECT_TYPE_TIME;
45 using OHOS::HDI::Vibrator::V1_1::HDF_EFFECT_TYPE_PRIMITIVE;
46 using OHOS::HDI::Vibrator::V1_1::HDF_EFFECT_TYPE_BUTT;
47 using OHOS::HDI::Vibrator::V1_1::TimeEffect;
48 using OHOS::HDI::Vibrator::V1_1::PrimitiveEffect;
49 using OHOS::HDI::Vibrator::V1_1::CompositeEffect;
50 using OHOS::HDI::Vibrator::V1_1::HdfCompositeEffect;
51 #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
52 class IVibratorHdiConnection {
53 public:
54     IVibratorHdiConnection() = default;
55     virtual ~IVibratorHdiConnection() = default;
56     virtual int32_t ConnectHdi() = 0;
57     virtual int32_t StartOnce(uint32_t duration) = 0;
58     virtual int32_t Start(const std::string &effectType) = 0;
59 #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
60     virtual int32_t EnableCompositeEffect(const HdfCompositeEffect &hdfCompositeEffect) = 0;
61     virtual bool IsVibratorRunning() = 0;
62 #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
63     virtual std::optional<HdfEffectInfo> GetEffectInfo(const std::string &effect) = 0;
64     virtual int32_t Stop(HdfVibratorModeV1_2 mode) = 0;
65     virtual int32_t DestroyHdiConnection() = 0;
66     virtual int32_t GetDelayTime(int32_t mode, int32_t &delayTime) = 0;
67     virtual int32_t GetVibratorCapacity(VibratorCapacity &capacity) = 0;
68     virtual int32_t PlayPattern(const VibratePattern &pattern) = 0;
69     virtual int32_t StartByIntensity(const std::string &effect, int32_t intensity) = 0;
70     virtual int32_t GetAllWaveInfo(std::vector<HdfWaveInformation> &waveInfos) = 0;
71 
72 private:
73     DISALLOW_COPY_AND_MOVE(IVibratorHdiConnection);
74 };
75 }  // namespace Sensors
76 }  // namespace OHOS
77 #endif  // I_VIBRATOR_HDI_CONNECTION_H