• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_EXTERNAL_VIBRATION_UTILS_H
18 #define ANDROID_EXTERNAL_VIBRATION_UTILS_H
19 
20 namespace android::os {
21 
22 enum class HapticScale {
23     MUTE = -100,
24     VERY_LOW = -2,
25     LOW = -1,
26     NONE = 0,
27     HIGH = 1,
28     VERY_HIGH = 2,
29 };
30 
31 bool isValidHapticScale(HapticScale scale);
32 
33 /* Scales the haptic data in given buffer using the selected HapticScale and ensuring no absolute
34  * value will be larger than the absolute of given limit.
35  * The limit will be ignored if it is NaN or zero.
36  */
37 void scaleHapticData(float* buffer, size_t length, HapticScale scale, float limit);
38 
39 } // namespace android::os
40 
41 #endif // ANDROID_EXTERNAL_VIBRATION_UTILS_H
42