Loading services/vr/virtual_touchpad/Android.bp +0 −4 Original line number Original line Diff line number Diff line Loading @@ -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", Loading @@ -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", Loading services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp +6 −13 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); Loading Loading @@ -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); } } Loading services/vr/virtual_touchpad/idc/vr-virtual-touchpad-0.idc 0 → 100644 +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 services/vr/virtual_touchpad/idc/vr-virtual-touchpad-1.idc +7 −0 Original line number Original line Diff line number Diff line Loading @@ -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. Loading services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading
services/vr/virtual_touchpad/Android.bp +0 −4 Original line number Original line Diff line number Diff line Loading @@ -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", Loading @@ -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", Loading
services/vr/virtual_touchpad/VirtualTouchpadEvdev.cpp +6 −13 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); Loading Loading @@ -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); } } Loading
services/vr/virtual_touchpad/idc/vr-virtual-touchpad-0.idc 0 → 100644 +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
services/vr/virtual_touchpad/idc/vr-virtual-touchpad-1.idc +7 −0 Original line number Original line Diff line number Diff line Loading @@ -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. Loading
services/vr/virtual_touchpad/tests/VirtualTouchpad_test.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -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); Loading