• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 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 #pragma once
18 
19 #include <cstdint>
20 #include <vector>
21 
22 namespace android {
23 
24 /**
25  * Describes a section of an acceleration curve as a function which outputs a scaling factor (gain)
26  * for the pointer movement, given the speed of the mouse or finger (in mm/s):
27  *
28  *     gain(input_speed_mm_per_s) = baseGain + reciprocal / input_speed_mm_per_s
29  */
30 struct AccelerationCurveSegment {
31     /**
32      * The maximum pointer speed at which this segment should apply, in mm/s. The last segment in a
33      * curve should always set this to infinity.
34      */
35     double maxPointerSpeedMmPerS;
36     /** The gain for this segment before the reciprocal is taken into account. */
37     double baseGain;
38     /** The reciprocal part of the formula, which should be divided by the input speed. */
39     double reciprocal;
40 };
41 
42 /**
43  * Creates an acceleration curve for the given pointer sensitivity value. The sensitivity value
44  * should be between -7 (for the lowest sensitivity) and 7, inclusive.
45  */
46 std::vector<AccelerationCurveSegment> createAccelerationCurveForPointerSensitivity(
47         int32_t sensitivity);
48 
49 } // namespace android
50