OSDN Git Service

Reverse the default orientation of accelerometer nougat-x86 android-x86-7.1-r2 android-x86-7.1-r3 android-x86-7.1-r4 android-x86-7.1-r5 android-x86-8.1-r1 android-x86-8.1-r2
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 14 Feb 2018 13:34:38 +0000 (21:34 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 14 Feb 2018 13:34:38 +0000 (21:34 +0800)
More people reported the orientation of accelerometer is reversed.
Though we can adjust that by properties, it's easier to just change
the default orientation.

enumeration.c

index f4f2afe..359fa90 100644 (file)
@@ -651,10 +651,10 @@ static int add_sensor (int dev_num, int catalog_index, int mode)
 
         /* Set default scaling - if num_channels is zero, we have one channel */
 
-       sensor[s].channel[0].opt_scale = 1;
+       sensor[s].channel[0].opt_scale = (sensor_type == SENSOR_TYPE_ACCELEROMETER) ? -1 : 1;
 
        for (c = 1; c < num_channels; c++)
-               sensor[s].channel[c].opt_scale = 1;
+               sensor[s].channel[c].opt_scale = sensor[s].channel[0].opt_scale;
 
        for (c = 0; c < num_channels; c++) {
                /* Check the presence of the channel's input_path */
@@ -689,7 +689,7 @@ static int add_sensor (int dev_num, int catalog_index, int mode)
                        ch_name = sensor_catalog[catalog_index].channel[c].name;
                        sprintf(suffix, "%s.opt_scale", ch_name);
                        if (!sensor_get_fl_prop(s, suffix, &opt_scale))
-                               sensor[s].channel[c].opt_scale = opt_scale;
+                               sensor[s].channel[c].opt_scale *= opt_scale;
                }
         } else {
                if (!sensor_get_fl_prop(s, "opt_scale", &opt_scale))