1 /* 2 * Copyright (C) 2023 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 package com.android.systemui.haptics.slider 18 19 import android.view.MotionEvent 20 import androidx.annotation.FloatRange 21 22 /** Configuration parameters of a [SliderHapticFeedbackProvider] */ 23 data class SliderHapticFeedbackConfig( 24 /** Interpolator factor for velocity-based vibration scale interpolations. Must be positive */ 25 val velocityInterpolatorFactor: Float = 1f, 26 /** Interpolator factor for progress-based vibration scale interpolations. Must be positive */ 27 val progressInterpolatorFactor: Float = 1f, 28 /** Minimum vibration scale for vibrations based on slider progress */ 29 @FloatRange(from = 0.0, to = 1.0) val progressBasedDragMinScale: Float = 0f, 30 /** Maximum vibration scale for vibrations based on slider progress */ 31 @FloatRange(from = 0.0, to = 1.0) val progressBasedDragMaxScale: Float = 0.2f, 32 /** Additional vibration scaling due to velocity */ 33 @FloatRange(from = 0.0, to = 1.0) val additionalVelocityMaxBump: Float = 0.15f, 34 /** Additional time delta to wait between drag texture vibrations */ 35 @FloatRange(from = 0.0) val deltaMillisForDragInterval: Float = 0f, 36 /** Progress threshold beyond which a new drag texture is delivered */ 37 @FloatRange(from = 0.0, to = 1.0) val deltaProgressForDragThreshold: Float = 0.015f, 38 /** Number of low ticks in a drag texture composition. This is not expected to change */ 39 val numberOfLowTicks: Int = 5, 40 /** Maximum velocity allowed for vibration scaling. This is not expected to change. */ 41 val maxVelocityToScale: Float = 2000f, /* In pixels/sec */ 42 /** Axis to use when computing velocity. Must be the same as the slider's axis of movement */ 43 val velocityAxis: Int = MotionEvent.AXIS_X, 44 /** Vibration scale at the upper bookend of the slider */ 45 @FloatRange(from = 0.0, to = 1.0) val upperBookendScale: Float = 1f, 46 /** Vibration scale at the lower bookend of the slider */ 47 @FloatRange(from = 0.0, to = 1.0) val lowerBookendScale: Float = 0.05f, 48 /** Exponent for power function compensation */ 49 @FloatRange(from = 0.0, fromInclusive = false) val exponent: Float = 1f / 0.89f, 50 ) 51