Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 587778f4 authored by Kevin Schoedel's avatar Kevin Schoedel Committed by android-build-merger
Browse files

Merge "Fix virtual touchpad scroll events." into oc-dr1-dev

am: 23970309

Change-Id: I89257f0a2b434016601aac06a9ed8cbbf5be1bd1
parents b9b48ae8 23970309
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -33,9 +33,6 @@ cc_library {
test_static_libs = [
test_static_libs = [
    "libcutils",
    "libcutils",
    "libvirtualtouchpad",
    "libvirtualtouchpad",
]

test_shared_libs = [
    "libbase",
    "libbase",
    "liblog",
    "liblog",
    "libutils",
    "libutils",
@@ -46,7 +43,6 @@ test_src_files = ["tests/VirtualTouchpad_test.cpp"]
cc_test {
cc_test {
    srcs: test_src_files,
    srcs: test_src_files,
    static_libs: test_static_libs,
    static_libs: test_static_libs,
    shared_libs: test_shared_libs,
    header_libs: header_libraries,
    header_libs: header_libraries,
    cppflags = [
    cppflags = [
        "-std=c++11",
        "-std=c++11",
+6 −13
Original line number Original line Diff line number Diff line
@@ -28,20 +28,10 @@ static constexpr int32_t kWidth = 0x10000;
static constexpr int32_t kHeight = 0x10000;
static constexpr int32_t kHeight = 0x10000;
static constexpr int32_t kSlots = 2;
static constexpr int32_t kSlots = 2;


static constexpr float kScrollScale = 100.0f;

int32_t scale_relative_scroll(float x) {
int32_t scale_relative_scroll(float x) {
  // Guilty with an explanation, your honor.
  return kScrollScale * x;
  // Ideally we should be able to communicate the full incoming precision
  // to InputFlinger, through the evdev int32_t value, by scaling by a
  // large factor, i.e. 2²³ for IEEE single precision floating point.
  // However, although InputFlinger has |wheelVelocityControlParameters|,
  // those parameters are currently hard coded, with a scale factor of 1.0.
  // The observed evdev value for a physical mouse scroll wheel is usually
  // ±1, with higher values up to ±4 for a very fast spin. So we imitate
  // that. If the incoming value is not actually 0, the resulting magnitude
  // should be at least 1, so that small movements are not lost.
  // Adding IDC configurability of |VelocityControlParameters| may be
  // desirable in the future.
  return copysignf(ceilf(fabs(4.0f * x)), x);
}
}


}  // anonymous namespace
}  // anonymous namespace
@@ -82,6 +72,8 @@ status_t VirtualTouchpadEvdev::Attach() {
    touchpad.injector->ConfigureInputProperty(INPUT_PROP_DIRECT);
    touchpad.injector->ConfigureInputProperty(INPUT_PROP_DIRECT);
    touchpad.injector->ConfigureMultiTouchXY(0, 0, kWidth - 1, kHeight - 1);
    touchpad.injector->ConfigureMultiTouchXY(0, 0, kWidth - 1, kHeight - 1);
    touchpad.injector->ConfigureAbsSlots(kSlots);
    touchpad.injector->ConfigureAbsSlots(kSlots);
    touchpad.injector->ConfigureRel(REL_WHEEL);
    touchpad.injector->ConfigureRel(REL_HWHEEL);
    touchpad.injector->ConfigureKey(BTN_TOUCH);
    touchpad.injector->ConfigureKey(BTN_TOUCH);
    touchpad.injector->ConfigureKey(BTN_BACK);
    touchpad.injector->ConfigureKey(BTN_BACK);
    touchpad.injector->ConfigureEnd();
    touchpad.injector->ConfigureEnd();
@@ -192,6 +184,7 @@ int VirtualTouchpadEvdev::Scroll(int touchpad_id, float x, float y) {
  touchpad.injector->ResetError();
  touchpad.injector->ResetError();
  const int32_t scaled_x = scale_relative_scroll(x);
  const int32_t scaled_x = scale_relative_scroll(x);
  const int32_t scaled_y = scale_relative_scroll(y);
  const int32_t scaled_y = scale_relative_scroll(y);
  ALOGV("(%f,%f) -> (%" PRId32 ",%" PRId32 ")", x, y, scaled_x, scaled_y);
  if (scaled_x) {
  if (scaled_x) {
    touchpad.injector->SendRel(REL_HWHEEL, scaled_x);
    touchpad.injector->SendRel(REL_HWHEEL, scaled_x);
  }
  }
+26 −0
Original line number Original line Diff line number Diff line
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Virtual touchpad for the primary display
device.internal = 1

touch.deviceType = touchScreen

# Have input flinger treat injected scroll events like a G1 ball
# rather than the default mouse wheel, because the latter requires
# a visible pointer for targeting.
device.type = rotaryEncoder
device.res = 1.0e+2
device.scalingFactor = 1.0e-2
+7 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,13 @@ device.internal = 1


touch.deviceType = touchScreen
touch.deviceType = touchScreen


# Have input flinger treat injected scroll events like a G1 ball
# rather than the default mouse wheel, because the latter requires
# a visible pointer for targeting.
device.type = rotaryEncoder
device.res = 1.0e+2
device.scalingFactor = 1.0e-2

# This displayID matches the unique ID of the virtual display created for VR.
# This displayID matches the unique ID of the virtual display created for VR.
# This will indicate to input flinger than it should link this input device
# This will indicate to input flinger than it should link this input device
# with the virtual display.
# with the virtual display.
+5 −0
Original line number Original line Diff line number Diff line
@@ -169,6 +169,11 @@ TEST_F(VirtualTouchpadTest, Goodness) {
    expect.IoctlSetInt(UI_SET_ABSBIT, ABS_MT_POSITION_Y);
    expect.IoctlSetInt(UI_SET_ABSBIT, ABS_MT_POSITION_Y);
    // From ConfigureAbsSlots(kSlots):
    // From ConfigureAbsSlots(kSlots):
    expect.IoctlSetInt(UI_SET_ABSBIT, ABS_MT_SLOT);
    expect.IoctlSetInt(UI_SET_ABSBIT, ABS_MT_SLOT);
    // From ConfigureRel(REL_WHEEL):
    expect.IoctlSetInt(UI_SET_EVBIT, EV_REL);
    expect.IoctlSetInt(UI_SET_RELBIT, REL_WHEEL);
    // From ConfigureRel(REL_HWHEEL):
    expect.IoctlSetInt(UI_SET_RELBIT, REL_HWHEEL);
    // From ConfigureKey(BTN_TOUCH):
    // From ConfigureKey(BTN_TOUCH):
    expect.IoctlSetInt(UI_SET_EVBIT, EV_KEY);
    expect.IoctlSetInt(UI_SET_EVBIT, EV_KEY);
    expect.IoctlSetInt(UI_SET_KEYBIT, BTN_TOUCH);
    expect.IoctlSetInt(UI_SET_KEYBIT, BTN_TOUCH);