From ac72bbf4e46d6689070df09a25db2960a9036eb2 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Tue, 11 Aug 2015 18:29:28 -0700 Subject: inputflinger: Initial support for rotary encoders. This change introduces support for rotary encoder input devices. We also define a new input source (namely, AINPUT_SOURCE_ROTARY_ENCODER) and a new axis of input (namely, AXIS_SCROLL), since the rotary encoder motion doesn't necessarily tie to a horizontal or vertical scroll motion. A ROTARY_ENCODER input device class is also introduced, corresponding to the new input source. A new input source can be defined as producing rotary encoder motion events, if its corresponding .idc file contains the following declaration: device.type = rotaryEncoder Bug: 18707397 Change-Id: I8ccd540908311d1ff44fdfeba81b691895413641 Signed-off-by: Prashant Malani --- services/inputflinger/EventHub.cpp | 9 ++++ services/inputflinger/EventHub.h | 3 ++ services/inputflinger/InputReader.cpp | 91 +++++++++++++++++++++++++++++++++++ services/inputflinger/InputReader.h | 20 ++++++++ 4 files changed, 123 insertions(+) (limited to 'services') diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp index 6b60c7c..98cfe2b 100644 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -1177,6 +1177,15 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { device->classes |= INPUT_DEVICE_CLASS_CURSOR; } + // See if this is a rotary encoder type device. + String8 deviceType = String8(); + if (device->configuration && + device->configuration->tryGetProperty(String8("device.type"), deviceType)) { + if (!deviceType.compare(String8("rotaryEncoder"))) { + device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; + } + } + // See if this is a touch pad. // Is this a new modern multi-touch driver? if (test_bit(ABS_MT_POSITION_X, device->absBitmask) diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h index 3ec4910..7c3e11e 100644 --- a/services/inputflinger/EventHub.h +++ b/services/inputflinger/EventHub.h @@ -137,6 +137,9 @@ enum { /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, + /* The input device has a rotary encoder */ + INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, + /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 36095bf..d7329d9 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -450,6 +450,11 @@ InputDevice* InputReader::createDeviceLocked(int32_t deviceId, int32_t controlle device->addMapper(new SwitchInputMapper(device)); } + // Scroll wheel-like devices. + if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { + device->addMapper(new RotaryEncoderInputMapper(device)); + } + // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { device->addMapper(new VibratorInputMapper(device)); @@ -2718,6 +2723,92 @@ void CursorInputMapper::fadePointer() { } } +// --- RotaryEncoderInputMapper --- + +RotaryEncoderInputMapper::RotaryEncoderInputMapper(InputDevice* device) : + InputMapper(device) { + mSource = AINPUT_SOURCE_ROTARY_ENCODER; +} + +RotaryEncoderInputMapper::~RotaryEncoderInputMapper() { +} + +uint32_t RotaryEncoderInputMapper::getSources() { + return mSource; +} + +void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { + InputMapper::populateDeviceInfo(info); + + if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { + info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); + } +} + +void RotaryEncoderInputMapper::dump(String8& dump) { + dump.append(INDENT2 "Rotary Encoder Input Mapper:\n"); + dump.appendFormat(INDENT3 "HaveWheel: %s\n", + toString(mRotaryEncoderScrollAccumulator.haveRelativeVWheel())); +} + +void RotaryEncoderInputMapper::configure(nsecs_t when, + const InputReaderConfiguration* config, uint32_t changes) { + InputMapper::configure(when, config, changes); + if (!changes) { + mRotaryEncoderScrollAccumulator.configure(getDevice()); + } +} + +void RotaryEncoderInputMapper::reset(nsecs_t when) { + mRotaryEncoderScrollAccumulator.reset(getDevice()); + + InputMapper::reset(when); +} + +void RotaryEncoderInputMapper::process(const RawEvent* rawEvent) { + mRotaryEncoderScrollAccumulator.process(rawEvent); + + if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) { + sync(rawEvent->when); + } +} + +void RotaryEncoderInputMapper::sync(nsecs_t when) { + PointerCoords pointerCoords; + pointerCoords.clear(); + + PointerProperties pointerProperties; + pointerProperties.clear(); + pointerProperties.id = 0; + pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN; + + float scroll = mRotaryEncoderScrollAccumulator.getRelativeVWheel(); + bool scrolled = scroll != 0; + + // This is not a pointer, so it's not associated with a display. + int32_t displayId = ADISPLAY_ID_NONE; + + // Moving the rotary encoder should wake the device (if specified). + uint32_t policyFlags = 0; + if (scrolled && getDevice()->isExternal()) { + policyFlags |= POLICY_FLAG_WAKE; + } + + // Send motion event. + if (scrolled) { + int32_t metaState = mContext->getGlobalMetaState(); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); + + NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, + AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, + AMOTION_EVENT_EDGE_FLAG_NONE, + displayId, 1, &pointerProperties, &pointerCoords, + 0, 0, 0); + getListener()->notifyMotion(&scrollArgs); + } + + mRotaryEncoderScrollAccumulator.finishSync(); +} // --- TouchInputMapper --- diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 7cb4680..58db3dc 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1232,6 +1232,26 @@ private: }; +class RotaryEncoderInputMapper : public InputMapper { +public: + RotaryEncoderInputMapper(InputDevice* device); + virtual ~RotaryEncoderInputMapper(); + + virtual uint32_t getSources(); + virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); + virtual void dump(String8& dump); + virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); + virtual void reset(nsecs_t when); + virtual void process(const RawEvent* rawEvent); + +private: + CursorScrollAccumulator mRotaryEncoderScrollAccumulator; + + int32_t mSource; + + void sync(nsecs_t when); +}; + class TouchInputMapper : public InputMapper { public: TouchInputMapper(InputDevice* device); -- cgit v1.1 From 392db573b35d6fe09c4da094ed81c54ed528a511 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Tue, 10 Nov 2015 14:29:45 -0800 Subject: Set cpuset from surfaceflinger. SurfaceFlinger shouldn't be limited to little cores exclusively, as the binder threads should be placed on big cores when they are in the critical path for a RenderThread. bug 25745866 Change-Id: I9fb65f6d951733f91b4735ff27018411b58b2bfb --- services/surfaceflinger/Android.mk | 4 ++++ services/surfaceflinger/main_surfaceflinger.cpp | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'services') diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 1eb2361..1901ef9 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -122,6 +122,10 @@ LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--e LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" LOCAL_CPPFLAGS := -std=c++11 +ifneq ($(ENABLE_CPUSETS),) + LOCAL_CFLAGS += -DENABLE_CPUSETS +endif + LOCAL_SRC_FILES := \ main_surfaceflinger.cpp diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp index a74bc4c..6fa8b53 100644 --- a/services/surfaceflinger/main_surfaceflinger.cpp +++ b/services/surfaceflinger/main_surfaceflinger.cpp @@ -41,6 +41,13 @@ int main(int, char**) { set_sched_policy(0, SP_FOREGROUND); +#ifdef ENABLE_CPUSETS + // Put most SurfaceFlinger threads in the system-background cpuset + // Keeps us from unnecessarily using big cores + // Do this after the binder thread pool init + set_cpuset_policy(0, SP_SYSTEM); +#endif + // initialize before clients can connect flinger->init(); -- cgit v1.1 From d4db70a7b8b2d136c46c50f89b276f8150be5fc2 Mon Sep 17 00:00:00 2001 From: Jani Suonpera Date: Fri, 9 Oct 2015 11:45:57 +0300 Subject: DO NOT MERGE ANYWHERE Add new interface for sensor physical data This is special solution only for emerald branch. Changes including new const char* value/interface for sensor physical data. Sensor service and manager does not take care of content, structure or other details of string. Sensor HAL is taking care of parsing data from string and setting values to Sensor HW. Change-Id: I3abc3ddc7c6adc4b32a40b9a43f2a94c5af7b2b0 Signed-off-by: Ben Fennema --- services/sensorservice/SensorDevice.cpp | 15 +++++++++++++++ services/sensorservice/SensorDevice.h | 1 + services/sensorservice/SensorService.cpp | 8 ++++++++ services/sensorservice/SensorService.h | 1 + 4 files changed, 25 insertions(+) (limited to 'services') diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index dd1bccf..48ae2fb 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -407,6 +407,21 @@ status_t SensorDevice::setMode(uint32_t mode) { return mSensorModule->set_operation_mode(mode); } +status_t SensorDevice::setSensorPhysicalData(const char* physicaldata) +{ + //ALOGD("SensorDevice::setSensorPhysicalData(%s)",physicaldata); + Mutex::Autolock _l(mLock); + if((mSensorModule->set_sensor_physical_data == NULL) || (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_3_5)) + { + return NO_INIT; + } + else + { + return mSensorModule->set_sensor_physical_data(physicaldata); + } +} + + // --------------------------------------------------------------------------- int SensorDevice::Info::numActiveClients() { diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h index c484849..f658497 100644 --- a/services/sensorservice/SensorDevice.h +++ b/services/sensorservice/SensorDevice.h @@ -104,6 +104,7 @@ public: void autoDisable(void *ident, int handle); status_t injectSensorData(const sensors_event_t *event); void dump(String8& result); + status_t setSensorPhysicalData(const char* physicaldata); }; // --------------------------------------------------------------------------- diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index fd72b23..2548a3e 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -735,6 +735,14 @@ Vector SensorService::getSensorList(const String16& opPackageName) return accessibleSensorList; } +status_t SensorService::setSensorPhysicalData(const char* physicaldata) +{ + SensorDevice& dev(SensorDevice::getInstance()); + + //ALOGD("SensorService::setSensorPhysicalData(%s)",physicaldata); + return dev.setSensorPhysicalData(physicaldata); +} + sp SensorService::createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName) { // Only 2 modes supported for a SensorEventConnection ... NORMAL and DATA_INJECTION. diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 9a573ae..3a1ffb2 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -130,6 +130,7 @@ class SensorService : virtual sp createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName); virtual int isDataInjectionEnabled(); + virtual status_t setSensorPhysicalData(const char* physicaldata); virtual status_t dump(int fd, const Vector& args); class SensorEventConnection : public BnSensorEventConnection, public LooperCallback { -- cgit v1.1 From 8c3e55f4149deda3ec7c7a67fda81216d5f9af25 Mon Sep 17 00:00:00 2001 From: Ben Fennema Date: Wed, 2 Dec 2015 01:04:40 +0000 Subject: Revert "DO NOT MERGE ANYWHERE Add new interface for sensor physical data" This reverts commit d4db70a7b8b2d136c46c50f89b276f8150be5fc2. Change-Id: Ifb52d5595970a5178e12c2a90da4aac0e38f5942 --- services/sensorservice/SensorDevice.cpp | 15 --------------- services/sensorservice/SensorDevice.h | 1 - services/sensorservice/SensorService.cpp | 8 -------- services/sensorservice/SensorService.h | 1 - 4 files changed, 25 deletions(-) (limited to 'services') diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index 48ae2fb..dd1bccf 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -407,21 +407,6 @@ status_t SensorDevice::setMode(uint32_t mode) { return mSensorModule->set_operation_mode(mode); } -status_t SensorDevice::setSensorPhysicalData(const char* physicaldata) -{ - //ALOGD("SensorDevice::setSensorPhysicalData(%s)",physicaldata); - Mutex::Autolock _l(mLock); - if((mSensorModule->set_sensor_physical_data == NULL) || (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_3_5)) - { - return NO_INIT; - } - else - { - return mSensorModule->set_sensor_physical_data(physicaldata); - } -} - - // --------------------------------------------------------------------------- int SensorDevice::Info::numActiveClients() { diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h index f658497..c484849 100644 --- a/services/sensorservice/SensorDevice.h +++ b/services/sensorservice/SensorDevice.h @@ -104,7 +104,6 @@ public: void autoDisable(void *ident, int handle); status_t injectSensorData(const sensors_event_t *event); void dump(String8& result); - status_t setSensorPhysicalData(const char* physicaldata); }; // --------------------------------------------------------------------------- diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 2548a3e..fd72b23 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -735,14 +735,6 @@ Vector SensorService::getSensorList(const String16& opPackageName) return accessibleSensorList; } -status_t SensorService::setSensorPhysicalData(const char* physicaldata) -{ - SensorDevice& dev(SensorDevice::getInstance()); - - //ALOGD("SensorService::setSensorPhysicalData(%s)",physicaldata); - return dev.setSensorPhysicalData(physicaldata); -} - sp SensorService::createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName) { // Only 2 modes supported for a SensorEventConnection ... NORMAL and DATA_INJECTION. diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 3a1ffb2..9a573ae 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -130,7 +130,6 @@ class SensorService : virtual sp createSensorEventConnection(const String8& packageName, int requestedMode, const String16& opPackageName); virtual int isDataInjectionEnabled(); - virtual status_t setSensorPhysicalData(const char* physicaldata); virtual status_t dump(int fd, const Vector& args); class SensorEventConnection : public BnSensorEventConnection, public LooperCallback { -- cgit v1.1 From ee03865fe5fc6ffe9deda0e0870a18206027cfaf Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Mon, 11 Jan 2016 17:08:18 -0800 Subject: inputflinger: Add support for scaling and true value reporting -1/+1 somewhat simplifies the values that can be generated by rotary encoders, and rules out the possibility of batching and more nuanced movement reporting. So, we modify the device configuration to allow values other than -1 and 1 to be supported. In order to give the developer a sense of what these values map to in terms of angular displacement, we also parse a resolution configuration from the devices IDC file. This will be specified as: device.res = xxxx of type float. If a value is not provided, a default res value of 0.0f is used. This patch also adds a per device scaling factor, which is used to suitably modify the values reported (as well as the resolution) to tune the input events generated and resulting UI according to the hardware. This can be specified in the IDC file as: device.scalingFactor = xxxx of type float. If a scaling factor is not provided, a default of 1.0f is used. Bug: 22836852 Bug: 18707397 Change-Id: I13686f64de1b52d3f6c97b2587ae41e52d1db6e2 --- services/inputflinger/InputReader.cpp | 15 +++++++++++++-- services/inputflinger/InputReader.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 3ba38b5..8063a75 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -2751,7 +2751,18 @@ void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { - info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); + float res = 0.0f; + if (!mDevice->getConfiguration().tryGetProperty(String8("device.res"), res)) { + ALOGW("Rotary Encoder device configuration file didn't specify resolution!\n"); + } + if (!mDevice->getConfiguration().tryGetProperty(String8("device.scalingFactor"), + mScalingFactor)) { + ALOGW("Rotary Encoder device configuration file didn't specify scaling factor," + "default to 1.0!\n"); + mScalingFactor = 1.0f; + } + info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, + res * mScalingFactor); } } @@ -2807,7 +2818,7 @@ void RotaryEncoderInputMapper::sync(nsecs_t when) { // Send motion event. if (scrolled) { int32_t metaState = mContext->getGlobalMetaState(); - pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll * mScalingFactor); NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 3e931fe..46d45d8 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1247,6 +1247,7 @@ private: CursorScrollAccumulator mRotaryEncoderScrollAccumulator; int32_t mSource; + float mScalingFactor; void sync(nsecs_t when); }; -- cgit v1.1 From 2c09b78656dd97727f94fada81845b133cf142f3 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Wed, 13 Jan 2016 01:00:08 -0800 Subject: Revert "inputflinger: Add support for scaling and true value reporting" This reverts commit ee03865fe5fc6ffe9deda0e0870a18206027cfaf. --- services/inputflinger/InputReader.cpp | 15 ++------------- services/inputflinger/InputReader.h | 1 - 2 files changed, 2 insertions(+), 14 deletions(-) (limited to 'services') diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 8063a75..3ba38b5 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -2751,18 +2751,7 @@ void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { InputMapper::populateDeviceInfo(info); if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { - float res = 0.0f; - if (!mDevice->getConfiguration().tryGetProperty(String8("device.res"), res)) { - ALOGW("Rotary Encoder device configuration file didn't specify resolution!\n"); - } - if (!mDevice->getConfiguration().tryGetProperty(String8("device.scalingFactor"), - mScalingFactor)) { - ALOGW("Rotary Encoder device configuration file didn't specify scaling factor," - "default to 1.0!\n"); - mScalingFactor = 1.0f; - } - info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, - res * mScalingFactor); + info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); } } @@ -2818,7 +2807,7 @@ void RotaryEncoderInputMapper::sync(nsecs_t when) { // Send motion event. if (scrolled) { int32_t metaState = mContext->getGlobalMetaState(); - pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll * mScalingFactor); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 46d45d8..3e931fe 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1247,7 +1247,6 @@ private: CursorScrollAccumulator mRotaryEncoderScrollAccumulator; int32_t mSource; - float mScalingFactor; void sync(nsecs_t when); }; -- cgit v1.1 From d983fd11d4a00b03f92d09f32c08840e66d90777 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Wed, 13 Jan 2016 01:00:25 -0800 Subject: Revert "inputflinger: Initial support for rotary encoders." This reverts commit ac72bbf4e46d6689070df09a25db2960a9036eb2. --- services/inputflinger/EventHub.cpp | 9 ---- services/inputflinger/EventHub.h | 3 -- services/inputflinger/InputReader.cpp | 91 ----------------------------------- services/inputflinger/InputReader.h | 20 -------- 4 files changed, 123 deletions(-) (limited to 'services') diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp index 2a53dec..5859606 100644 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -1191,15 +1191,6 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { device->classes |= INPUT_DEVICE_CLASS_CURSOR; } - // See if this is a rotary encoder type device. - String8 deviceType = String8(); - if (device->configuration && - device->configuration->tryGetProperty(String8("device.type"), deviceType)) { - if (!deviceType.compare(String8("rotaryEncoder"))) { - device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; - } - } - // See if this is a touch pad. // Is this a new modern multi-touch driver? if (test_bit(ABS_MT_POSITION_X, device->absBitmask) diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h index 6869253..0f94c77 100644 --- a/services/inputflinger/EventHub.h +++ b/services/inputflinger/EventHub.h @@ -137,9 +137,6 @@ enum { /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, - /* The input device has a rotary encoder */ - INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, - /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 3ba38b5..b2cbfe8 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -450,11 +450,6 @@ InputDevice* InputReader::createDeviceLocked(int32_t deviceId, int32_t controlle device->addMapper(new SwitchInputMapper(device)); } - // Scroll wheel-like devices. - if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { - device->addMapper(new RotaryEncoderInputMapper(device)); - } - // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { device->addMapper(new VibratorInputMapper(device)); @@ -2733,92 +2728,6 @@ void CursorInputMapper::fadePointer() { } } -// --- RotaryEncoderInputMapper --- - -RotaryEncoderInputMapper::RotaryEncoderInputMapper(InputDevice* device) : - InputMapper(device) { - mSource = AINPUT_SOURCE_ROTARY_ENCODER; -} - -RotaryEncoderInputMapper::~RotaryEncoderInputMapper() { -} - -uint32_t RotaryEncoderInputMapper::getSources() { - return mSource; -} - -void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) { - InputMapper::populateDeviceInfo(info); - - if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) { - info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f); - } -} - -void RotaryEncoderInputMapper::dump(String8& dump) { - dump.append(INDENT2 "Rotary Encoder Input Mapper:\n"); - dump.appendFormat(INDENT3 "HaveWheel: %s\n", - toString(mRotaryEncoderScrollAccumulator.haveRelativeVWheel())); -} - -void RotaryEncoderInputMapper::configure(nsecs_t when, - const InputReaderConfiguration* config, uint32_t changes) { - InputMapper::configure(when, config, changes); - if (!changes) { - mRotaryEncoderScrollAccumulator.configure(getDevice()); - } -} - -void RotaryEncoderInputMapper::reset(nsecs_t when) { - mRotaryEncoderScrollAccumulator.reset(getDevice()); - - InputMapper::reset(when); -} - -void RotaryEncoderInputMapper::process(const RawEvent* rawEvent) { - mRotaryEncoderScrollAccumulator.process(rawEvent); - - if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) { - sync(rawEvent->when); - } -} - -void RotaryEncoderInputMapper::sync(nsecs_t when) { - PointerCoords pointerCoords; - pointerCoords.clear(); - - PointerProperties pointerProperties; - pointerProperties.clear(); - pointerProperties.id = 0; - pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN; - - float scroll = mRotaryEncoderScrollAccumulator.getRelativeVWheel(); - bool scrolled = scroll != 0; - - // This is not a pointer, so it's not associated with a display. - int32_t displayId = ADISPLAY_ID_NONE; - - // Moving the rotary encoder should wake the device (if specified). - uint32_t policyFlags = 0; - if (scrolled && getDevice()->isExternal()) { - policyFlags |= POLICY_FLAG_WAKE; - } - - // Send motion event. - if (scrolled) { - int32_t metaState = mContext->getGlobalMetaState(); - pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll); - - NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, - AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0, - AMOTION_EVENT_EDGE_FLAG_NONE, - displayId, 1, &pointerProperties, &pointerCoords, - 0, 0, 0); - getListener()->notifyMotion(&scrollArgs); - } - - mRotaryEncoderScrollAccumulator.finishSync(); -} // --- TouchInputMapper --- diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index 3e931fe..30c84b1 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -1231,26 +1231,6 @@ private: }; -class RotaryEncoderInputMapper : public InputMapper { -public: - RotaryEncoderInputMapper(InputDevice* device); - virtual ~RotaryEncoderInputMapper(); - - virtual uint32_t getSources(); - virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); - virtual void dump(String8& dump); - virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); - virtual void reset(nsecs_t when); - virtual void process(const RawEvent* rawEvent); - -private: - CursorScrollAccumulator mRotaryEncoderScrollAccumulator; - - int32_t mSource; - - void sync(nsecs_t when); -}; - class TouchInputMapper : public InputMapper { public: TouchInputMapper(InputDevice* device); -- cgit v1.1