1 /*
2  * Copyright (c) 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 OHOS_VIBRATOR_FFI_H
17 #define OHOS_VIBRATOR_FFI_H
18 
19 #include <cstdint>
20 
21 #include "cj_common_ffi.h"
22 #include "ffi_remote_data.h"
23 
24 extern "C" {
25     struct RetVibrateTime {
26         char* timeType;
27         int32_t duration;
28     };
29 
30     struct RetVibratePreset {
31         char* presetType;
32         char* effectId;
33         int32_t count;
34         int32_t intensity;
35     };
36 
37     struct RetHapticFileDescriptor {
38         int32_t fd;
39         int64_t offSet;
40         int64_t length;
41     };
42 
43     struct RetVibrateFromFile {
44         char* fileType;
45         RetHapticFileDescriptor hapticFd;
46     };
47 
48     struct RetVibrateAttribute {
49         int32_t id;
50         char* usage;
51     };
52 
53     FFI_EXPORT void FfiVibratorStartVibration(
54         RetVibrateTime effect, RetVibrateAttribute attribute, int32_t &code);
55     FFI_EXPORT void FfiVibratorStartVibrationPreset(
56         RetVibratePreset effect, RetVibrateAttribute attribute, int32_t &code);
57     FFI_EXPORT void FfiVibratorStartVibrationFile(
58         RetVibrateFromFile effect, RetVibrateAttribute attribute, int32_t &code);
59     FFI_EXPORT void FfiVibratorStopVibration(int32_t &code);
60     FFI_EXPORT void FfiVibratorStopVibrationMode(
61         char* vibMode, int32_t &code);
62     FFI_EXPORT bool FfiVibratorSupportEffect(
63         char* id, int32_t &code);
64     FFI_EXPORT bool FfiVibratorIsHdHapticSupported();
65 }
66 
67 #endif // OHOS_VIBRATOR_FFI_H