Loading services/inputflinger/reader/EventHub.cpp +46 −41 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ #define INDENT3 " " using android::base::StringPrintf; using namespace android::flag_operators; namespace android { Loading Loading @@ -127,9 +128,9 @@ static nsecs_t processEventTimestamp(const struct input_event& event) { // --- Global Functions --- uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses) { Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses) { // Touch devices get dibs on touch-related axes. if (deviceClasses & INPUT_DEVICE_CLASS_TOUCH) { if (deviceClasses.test(InputDeviceClass::TOUCH)) { switch (axis) { case ABS_X: case ABS_Y: Loading @@ -151,19 +152,19 @@ uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses) { case ABS_MT_TRACKING_ID: case ABS_MT_PRESSURE: case ABS_MT_DISTANCE: return INPUT_DEVICE_CLASS_TOUCH; return InputDeviceClass::TOUCH; } } // External stylus gets the pressure axis if (deviceClasses & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (deviceClasses.test(InputDeviceClass::EXTERNAL_STYLUS)) { if (axis == ABS_PRESSURE) { return INPUT_DEVICE_CLASS_EXTERNAL_STYLUS; return InputDeviceClass::EXTERNAL_STYLUS; } } // Joystick devices get the rest. return deviceClasses & INPUT_DEVICE_CLASS_JOYSTICK; return deviceClasses & InputDeviceClass::JOYSTICK; } // --- EventHub::Device --- Loading Loading @@ -340,10 +341,12 @@ InputDeviceIdentifier EventHub::getDeviceIdentifier(int32_t deviceId) const { return device->identifier; } uint32_t EventHub::getDeviceClasses(int32_t deviceId) const { Flags<InputDeviceClass> EventHub::getDeviceClasses(int32_t deviceId) const { AutoMutex _l(mLock); Device* device = getDeviceLocked(deviceId); if (device == nullptr) return 0; if (device == nullptr) { return Flags<InputDeviceClass>(0); } return device->classes; } Loading Loading @@ -1278,13 +1281,13 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { bool haveGamepadButtons = device->keyBitmask.any(BTN_MISC, BTN_MOUSE) || device->keyBitmask.any(BTN_JOYSTICK, BTN_DIGI); if (haveKeyboardKeys || haveGamepadButtons) { device->classes |= INPUT_DEVICE_CLASS_KEYBOARD; device->classes |= InputDeviceClass::KEYBOARD; } // See if this is a cursor device such as a trackball or mouse. if (device->keyBitmask.test(BTN_MOUSE) && device->relBitmask.test(REL_X) && device->relBitmask.test(REL_Y)) { device->classes |= INPUT_DEVICE_CLASS_CURSOR; device->classes |= InputDeviceClass::CURSOR; } // See if this is a rotary encoder type device. Loading @@ -1292,7 +1295,7 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { if (device->configuration && device->configuration->tryGetProperty(String8("device.type"), deviceType)) { if (!deviceType.compare(String8("rotaryEncoder"))) { device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; device->classes |= InputDeviceClass::ROTARY_ENCODER; } } Loading @@ -1303,30 +1306,30 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // with the ABS_MT range. Try to confirm that the device really is // a touch screen. if (device->keyBitmask.test(BTN_TOUCH) || !haveGamepadButtons) { device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT; device->classes |= (InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT); } // Is this an old style single-touch driver? } else if (device->keyBitmask.test(BTN_TOUCH) && device->absBitmask.test(ABS_X) && device->absBitmask.test(ABS_Y)) { device->classes |= INPUT_DEVICE_CLASS_TOUCH; device->classes |= InputDeviceClass::TOUCH; // Is this a BT stylus? } else if ((device->absBitmask.test(ABS_PRESSURE) || device->keyBitmask.test(BTN_TOUCH)) && !device->absBitmask.test(ABS_X) && !device->absBitmask.test(ABS_Y)) { device->classes |= INPUT_DEVICE_CLASS_EXTERNAL_STYLUS; device->classes |= InputDeviceClass::EXTERNAL_STYLUS; // Keyboard will try to claim some of the buttons but we really want to reserve those so we // can fuse it with the touch screen data, so just take them back. Note this means an // external stylus cannot also be a keyboard device. device->classes &= ~INPUT_DEVICE_CLASS_KEYBOARD; device->classes &= ~InputDeviceClass::KEYBOARD; } // See if this device is a joystick. // Assumes that joysticks always have gamepad buttons in order to distinguish them // from other devices such as accelerometers that also have absolute axes. if (haveGamepadButtons) { uint32_t assumedClasses = device->classes | INPUT_DEVICE_CLASS_JOYSTICK; auto assumedClasses = device->classes | InputDeviceClass::JOYSTICK; for (int i = 0; i <= ABS_MAX; i++) { if (device->absBitmask.test(i) && (getAbsAxisUsage(i, assumedClasses) & INPUT_DEVICE_CLASS_JOYSTICK)) { (getAbsAxisUsage(i, assumedClasses).test(InputDeviceClass::JOYSTICK))) { device->classes = assumedClasses; break; } Loading @@ -1336,36 +1339,36 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // Check whether this device has switches. for (int i = 0; i <= SW_MAX; i++) { if (device->swBitmask.test(i)) { device->classes |= INPUT_DEVICE_CLASS_SWITCH; device->classes |= InputDeviceClass::SWITCH; break; } } // Check whether this device supports the vibrator. if (device->ffBitmask.test(FF_RUMBLE)) { device->classes |= INPUT_DEVICE_CLASS_VIBRATOR; device->classes |= InputDeviceClass::VIBRATOR; } // Configure virtual keys. if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) { if ((device->classes.test(InputDeviceClass::TOUCH))) { // Load the virtual keys for the touch screen, if any. // We do this now so that we can make sure to load the keymap if necessary. bool success = loadVirtualKeyMapLocked(device); if (success) { device->classes |= INPUT_DEVICE_CLASS_KEYBOARD; device->classes |= InputDeviceClass::KEYBOARD; } } // Load the key map. // We need to do this for joysticks too because the key layout may specify axes. status_t keyMapStatus = NAME_NOT_FOUND; if (device->classes & (INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_JOYSTICK)) { if (device->classes.any(InputDeviceClass::KEYBOARD | InputDeviceClass::JOYSTICK)) { // Load the keymap for the device. keyMapStatus = loadKeyMapLocked(device); } // Configure the keyboard, gamepad or virtual keyboard. if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) { if (device->classes.test(InputDeviceClass::KEYBOARD)) { // Register the keyboard as a built-in keyboard if it is eligible. if (!keyMapStatus && mBuiltInKeyboardId == NO_BUILT_IN_KEYBOARD && isEligibleBuiltInKeyboard(device->identifier, device->configuration, &device->keyMap)) { Loading @@ -1374,7 +1377,7 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // 'Q' key support = cheap test of whether this is an alpha-capable kbd if (hasKeycodeLocked(device, AKEYCODE_Q)) { device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY; device->classes |= InputDeviceClass::ALPHAKEY; } // See if this device has a DPAD. Loading @@ -1383,20 +1386,20 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { hasKeycodeLocked(device, AKEYCODE_DPAD_LEFT) && hasKeycodeLocked(device, AKEYCODE_DPAD_RIGHT) && hasKeycodeLocked(device, AKEYCODE_DPAD_CENTER)) { device->classes |= INPUT_DEVICE_CLASS_DPAD; device->classes |= InputDeviceClass::DPAD; } // See if this device has a gamepad. for (size_t i = 0; i < sizeof(GAMEPAD_KEYCODES) / sizeof(GAMEPAD_KEYCODES[0]); i++) { if (hasKeycodeLocked(device, GAMEPAD_KEYCODES[i])) { device->classes |= INPUT_DEVICE_CLASS_GAMEPAD; device->classes |= InputDeviceClass::GAMEPAD; break; } } } // If the device isn't recognized as something we handle, don't monitor it. if (device->classes == 0) { if (device->classes == Flags<InputDeviceClass>(0)) { ALOGV("Dropping device: id=%d, path='%s', name='%s'", deviceId, devicePath.c_str(), device->identifier.name.c_str()); delete device; Loading @@ -1405,16 +1408,16 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // Determine whether the device has a mic. if (deviceHasMicLocked(device)) { device->classes |= INPUT_DEVICE_CLASS_MIC; device->classes |= InputDeviceClass::MIC; } // Determine whether the device is external or internal. if (isExternalDeviceLocked(device)) { device->classes |= INPUT_DEVICE_CLASS_EXTERNAL; device->classes |= InputDeviceClass::EXTERNAL; } if (device->classes & (INPUT_DEVICE_CLASS_JOYSTICK | INPUT_DEVICE_CLASS_DPAD) && device->classes & INPUT_DEVICE_CLASS_GAMEPAD) { if (device->classes.any(InputDeviceClass::JOYSTICK | InputDeviceClass::DPAD) && device->classes.test(InputDeviceClass::GAMEPAD)) { device->controllerNumber = getNextControllerNumberLocked(device); setLedForControllerLocked(device); } Loading @@ -1441,11 +1444,12 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { configureFd(device); ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=0x%x, " ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=%s, " "configuration='%s', keyLayout='%s', keyCharacterMap='%s', builtinKeyboard=%s, ", deviceId, fd, devicePath.c_str(), device->identifier.name.c_str(), device->classes, device->configurationFile.c_str(), device->keyMap.keyLayoutFile.c_str(), device->keyMap.keyCharacterMapFile.c_str(), toString(mBuiltInKeyboardId == deviceId)); deviceId, fd, devicePath.c_str(), device->identifier.name.c_str(), device->classes.string().c_str(), device->configurationFile.c_str(), device->keyMap.keyLayoutFile.c_str(), device->keyMap.keyCharacterMapFile.c_str(), toString(mBuiltInKeyboardId == deviceId)); addDeviceLocked(device); return OK; Loading @@ -1453,7 +1457,7 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { void EventHub::configureFd(Device* device) { // Set fd parameters with ioctl, such as key repeat, suspend block, and clock type if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) { if (device->classes.test(InputDeviceClass::KEYBOARD)) { // Disable kernel key repeat since we handle it ourselves unsigned int repeatRate[] = {0, 0}; if (ioctl(device->fd, EVIOCSREP, repeatRate)) { Loading Loading @@ -1551,8 +1555,8 @@ void EventHub::createVirtualKeyboardLocked() { Device* device = new Device(-1, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, "<virtual>", identifier); device->classes = INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_ALPHAKEY | INPUT_DEVICE_CLASS_DPAD | INPUT_DEVICE_CLASS_VIRTUAL; device->classes = InputDeviceClass::KEYBOARD | InputDeviceClass::ALPHAKEY | InputDeviceClass::DPAD | InputDeviceClass::VIRTUAL; loadKeyMapLocked(device); addDeviceLocked(device); } Loading Loading @@ -1719,8 +1723,9 @@ void EventHub::closeAllDevicesLocked() { } void EventHub::closeDeviceLocked(Device* device) { ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=0x%x", device->path.c_str(), device->identifier.name.c_str(), device->id, device->fd, device->classes); ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=%s", device->path.c_str(), device->identifier.name.c_str(), device->id, device->fd, device->classes.string().c_str()); if (device->id == mBuiltInKeyboardId) { ALOGW("built-in keyboard device %s (id=%d) is closing! the apps will not like this", Loading Loading @@ -1862,7 +1867,7 @@ void EventHub::dump(std::string& dump) { dump += StringPrintf(INDENT2 "%d: %s\n", device->id, device->identifier.name.c_str()); } dump += StringPrintf(INDENT3 "Classes: 0x%08x\n", device->classes); dump += StringPrintf(INDENT3 "Classes: %s\n", device->classes.string().c_str()); dump += StringPrintf(INDENT3 "Path: %s\n", device->path.c_str()); dump += StringPrintf(INDENT3 "Enabled: %s\n", toString(device->enabled)); dump += StringPrintf(INDENT3 "Descriptor: %s\n", device->identifier.descriptor.c_str()); Loading services/inputflinger/reader/InputDevice.cpp +19 −18 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "InputDevice.h" #include <input/Flags.h> #include <algorithm> #include "CursorInputMapper.h" Loading Loading @@ -131,7 +132,7 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) { return; } std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId)); uint32_t classes = contextPtr->getDeviceClasses(); Flags<InputDeviceClass> classes = contextPtr->getDeviceClasses(); std::vector<std::unique_ptr<InputMapper>> mappers; // Check if we should skip population Loading @@ -141,33 +142,33 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) { } // Switch-like devices. if (classes & INPUT_DEVICE_CLASS_SWITCH) { if (classes.test(InputDeviceClass::SWITCH)) { mappers.push_back(std::make_unique<SwitchInputMapper>(*contextPtr)); } // Scroll wheel-like devices. if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { if (classes.test(InputDeviceClass::ROTARY_ENCODER)) { mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(*contextPtr)); } // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { if (classes.test(InputDeviceClass::VIBRATOR)) { mappers.push_back(std::make_unique<VibratorInputMapper>(*contextPtr)); } // Keyboard-like devices. uint32_t keyboardSource = 0; int32_t keyboardType = AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC; if (classes & INPUT_DEVICE_CLASS_KEYBOARD) { if (classes.test(InputDeviceClass::KEYBOARD)) { keyboardSource |= AINPUT_SOURCE_KEYBOARD; } if (classes & INPUT_DEVICE_CLASS_ALPHAKEY) { if (classes.test(InputDeviceClass::ALPHAKEY)) { keyboardType = AINPUT_KEYBOARD_TYPE_ALPHABETIC; } if (classes & INPUT_DEVICE_CLASS_DPAD) { if (classes.test(InputDeviceClass::DPAD)) { keyboardSource |= AINPUT_SOURCE_DPAD; } if (classes & INPUT_DEVICE_CLASS_GAMEPAD) { if (classes.test(InputDeviceClass::GAMEPAD)) { keyboardSource |= AINPUT_SOURCE_GAMEPAD; } Loading @@ -177,24 +178,24 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) { } // Cursor-like devices. if (classes & INPUT_DEVICE_CLASS_CURSOR) { if (classes.test(InputDeviceClass::CURSOR)) { mappers.push_back(std::make_unique<CursorInputMapper>(*contextPtr)); } // Touchscreens and touchpad devices. if (classes & INPUT_DEVICE_CLASS_TOUCH_MT) { if (classes.test(InputDeviceClass::TOUCH_MT)) { mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr)); } else if (classes & INPUT_DEVICE_CLASS_TOUCH) { } else if (classes.test(InputDeviceClass::TOUCH)) { mappers.push_back(std::make_unique<SingleTouchInputMapper>(*contextPtr)); } // Joystick-like devices. if (classes & INPUT_DEVICE_CLASS_JOYSTICK) { if (classes.test(InputDeviceClass::JOYSTICK)) { mappers.push_back(std::make_unique<JoystickInputMapper>(*contextPtr)); } // External stylus-like devices. if (classes & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (classes.test(InputDeviceClass::EXTERNAL_STYLUS)) { mappers.push_back(std::make_unique<ExternalStylusInputMapper>(*contextPtr)); } Loading @@ -209,7 +210,7 @@ void InputDevice::removeEventHubDevice(int32_t eventHubId) { void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) { mSources = 0; mClasses = 0; mClasses = Flags<InputDeviceClass>(0); mControllerNumber = 0; for_each_subdevice([this](InputDeviceContext& context) { Loading @@ -224,8 +225,8 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config } }); mIsExternal = !!(mClasses & INPUT_DEVICE_CLASS_EXTERNAL); mHasMic = !!(mClasses & INPUT_DEVICE_CLASS_MIC); mIsExternal = mClasses.test(InputDeviceClass::EXTERNAL); mHasMic = mClasses.test(InputDeviceClass::MIC); if (!isIgnored()) { if (!changes) { // first time only Loading @@ -238,7 +239,7 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config } if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS)) { if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) { if (!mClasses.test(InputDeviceClass::VIRTUAL)) { sp<KeyCharacterMap> keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); bool shouldBumpGeneration = false; Loading @@ -255,7 +256,7 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config } if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_ALIAS)) { if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); if (mAlias != alias) { mAlias = alias; Loading services/inputflinger/reader/InputReader.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ void InputReader::addDeviceLocked(nsecs_t when, int32_t eventHubId) { mDevices.emplace(eventHubId, device); bumpGenerationLocked(); if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS)) { notifyExternalStylusPresenceChanged(); } } Loading Loading @@ -237,7 +237,7 @@ void InputReader::removeDeviceLocked(nsecs_t when, int32_t eventHubId) { device->removeEventHubDevice(eventHubId); if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS)) { notifyExternalStylusPresenceChanged(); } Loading Loading @@ -360,7 +360,7 @@ void InputReader::notifyExternalStylusPresenceChanged() { void InputReader::getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& outDevices) { for (auto& devicePair : mDevices) { std::shared_ptr<InputDevice>& device = devicePair.second; if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS && !device->isIgnored()) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) { InputDeviceInfo info; device->getDeviceInfo(&info); outDevices.push_back(info); Loading services/inputflinger/reader/include/EventHub.h +21 −20 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <climits> #include <vector> #include <input/Flags.h> #include <input/Input.h> #include <input/InputDevice.h> #include <input/KeyCharacterMap.h> Loading Loading @@ -76,58 +77,58 @@ struct RawAbsoluteAxisInfo { /* * Input device classes. */ enum { enum class InputDeviceClass : uint32_t { /* The input device is a keyboard or has buttons. */ INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001, KEYBOARD = 0x00000001, /* The input device is an alpha-numeric keyboard (not just a dial pad). */ INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002, ALPHAKEY = 0x00000002, /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */ INPUT_DEVICE_CLASS_TOUCH = 0x00000004, TOUCH = 0x00000004, /* The input device is a cursor device such as a trackball or mouse. */ INPUT_DEVICE_CLASS_CURSOR = 0x00000008, CURSOR = 0x00000008, /* The input device is a multi-touch touchscreen. */ INPUT_DEVICE_CLASS_TOUCH_MT = 0x00000010, TOUCH_MT = 0x00000010, /* The input device is a directional pad (implies keyboard, has DPAD keys). */ INPUT_DEVICE_CLASS_DPAD = 0x00000020, DPAD = 0x00000020, /* The input device is a gamepad (implies keyboard, has BUTTON keys). */ INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040, GAMEPAD = 0x00000040, /* The input device has switches. */ INPUT_DEVICE_CLASS_SWITCH = 0x00000080, SWITCH = 0x00000080, /* The input device is a joystick (implies gamepad, has joystick absolute axes). */ INPUT_DEVICE_CLASS_JOYSTICK = 0x00000100, JOYSTICK = 0x00000100, /* The input device has a vibrator (supports FF_RUMBLE). */ INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200, VIBRATOR = 0x00000200, /* The input device has a microphone. */ INPUT_DEVICE_CLASS_MIC = 0x00000400, MIC = 0x00000400, /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, EXTERNAL_STYLUS = 0x00000800, /* The input device has a rotary encoder */ INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, ROTARY_ENCODER = 0x00001000, /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, VIRTUAL = 0x40000000, /* The input device is external (not built-in). */ INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000, EXTERNAL = 0x80000000, }; /* * Gets the class that owns an axis, in cases where multiple classes might claim * the same axis for different purposes. */ extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses); extern Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses); /* * Grand Central Station for events. Loading Loading @@ -160,7 +161,7 @@ public: FIRST_SYNTHETIC_EVENT = DEVICE_ADDED, }; virtual uint32_t getDeviceClasses(int32_t deviceId) const = 0; virtual Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const = 0; virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0; Loading Loading @@ -327,7 +328,7 @@ class EventHub : public EventHubInterface { public: EventHub(); virtual uint32_t getDeviceClasses(int32_t deviceId) const override; virtual Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override; virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const override; Loading Loading @@ -397,7 +398,7 @@ private: std::unique_ptr<TouchVideoDevice> videoDevice; uint32_t classes; Flags<InputDeviceClass> classes; BitArray<KEY_MAX> keyBitmask; BitArray<KEY_MAX> keyState; Loading services/inputflinger/reader/include/InputDevice.h +6 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define _UI_INPUTREADER_INPUT_DEVICE_H #include <input/DisplayViewport.h> #include <input/Flags.h> #include <input/InputDevice.h> #include <stdint.h> #include <utils/PropertyMap.h> Loading Loading @@ -48,7 +49,7 @@ public: inline int32_t getGeneration() const { return mGeneration; } inline const std::string getName() const { return mIdentifier.name; } inline const std::string getDescriptor() { return mIdentifier.descriptor; } inline uint32_t getClasses() const { return mClasses; } inline Flags<InputDeviceClass> getClasses() const { return mClasses; } inline uint32_t getSources() const { return mSources; } inline bool hasEventHubDevices() const { return !mDevices.empty(); } Loading Loading @@ -121,7 +122,7 @@ private: int32_t mControllerNumber; InputDeviceIdentifier mIdentifier; std::string mAlias; uint32_t mClasses; Flags<InputDeviceClass> mClasses; // map from eventHubId to device context and mappers using MapperVector = std::vector<std::unique_ptr<InputMapper>>; Loading Loading @@ -206,7 +207,9 @@ public: inline int32_t getId() { return mDeviceId; } inline int32_t getEventHubId() { return mId; } inline uint32_t getDeviceClasses() const { return mEventHub->getDeviceClasses(mId); } inline Flags<InputDeviceClass> getDeviceClasses() const { return mEventHub->getDeviceClasses(mId); } inline InputDeviceIdentifier getDeviceIdentifier() const { return mEventHub->getDeviceIdentifier(mId); } Loading Loading
services/inputflinger/reader/EventHub.cpp +46 −41 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ #define INDENT3 " " using android::base::StringPrintf; using namespace android::flag_operators; namespace android { Loading Loading @@ -127,9 +128,9 @@ static nsecs_t processEventTimestamp(const struct input_event& event) { // --- Global Functions --- uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses) { Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses) { // Touch devices get dibs on touch-related axes. if (deviceClasses & INPUT_DEVICE_CLASS_TOUCH) { if (deviceClasses.test(InputDeviceClass::TOUCH)) { switch (axis) { case ABS_X: case ABS_Y: Loading @@ -151,19 +152,19 @@ uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses) { case ABS_MT_TRACKING_ID: case ABS_MT_PRESSURE: case ABS_MT_DISTANCE: return INPUT_DEVICE_CLASS_TOUCH; return InputDeviceClass::TOUCH; } } // External stylus gets the pressure axis if (deviceClasses & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (deviceClasses.test(InputDeviceClass::EXTERNAL_STYLUS)) { if (axis == ABS_PRESSURE) { return INPUT_DEVICE_CLASS_EXTERNAL_STYLUS; return InputDeviceClass::EXTERNAL_STYLUS; } } // Joystick devices get the rest. return deviceClasses & INPUT_DEVICE_CLASS_JOYSTICK; return deviceClasses & InputDeviceClass::JOYSTICK; } // --- EventHub::Device --- Loading Loading @@ -340,10 +341,12 @@ InputDeviceIdentifier EventHub::getDeviceIdentifier(int32_t deviceId) const { return device->identifier; } uint32_t EventHub::getDeviceClasses(int32_t deviceId) const { Flags<InputDeviceClass> EventHub::getDeviceClasses(int32_t deviceId) const { AutoMutex _l(mLock); Device* device = getDeviceLocked(deviceId); if (device == nullptr) return 0; if (device == nullptr) { return Flags<InputDeviceClass>(0); } return device->classes; } Loading Loading @@ -1278,13 +1281,13 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { bool haveGamepadButtons = device->keyBitmask.any(BTN_MISC, BTN_MOUSE) || device->keyBitmask.any(BTN_JOYSTICK, BTN_DIGI); if (haveKeyboardKeys || haveGamepadButtons) { device->classes |= INPUT_DEVICE_CLASS_KEYBOARD; device->classes |= InputDeviceClass::KEYBOARD; } // See if this is a cursor device such as a trackball or mouse. if (device->keyBitmask.test(BTN_MOUSE) && device->relBitmask.test(REL_X) && device->relBitmask.test(REL_Y)) { device->classes |= INPUT_DEVICE_CLASS_CURSOR; device->classes |= InputDeviceClass::CURSOR; } // See if this is a rotary encoder type device. Loading @@ -1292,7 +1295,7 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { if (device->configuration && device->configuration->tryGetProperty(String8("device.type"), deviceType)) { if (!deviceType.compare(String8("rotaryEncoder"))) { device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER; device->classes |= InputDeviceClass::ROTARY_ENCODER; } } Loading @@ -1303,30 +1306,30 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // with the ABS_MT range. Try to confirm that the device really is // a touch screen. if (device->keyBitmask.test(BTN_TOUCH) || !haveGamepadButtons) { device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT; device->classes |= (InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT); } // Is this an old style single-touch driver? } else if (device->keyBitmask.test(BTN_TOUCH) && device->absBitmask.test(ABS_X) && device->absBitmask.test(ABS_Y)) { device->classes |= INPUT_DEVICE_CLASS_TOUCH; device->classes |= InputDeviceClass::TOUCH; // Is this a BT stylus? } else if ((device->absBitmask.test(ABS_PRESSURE) || device->keyBitmask.test(BTN_TOUCH)) && !device->absBitmask.test(ABS_X) && !device->absBitmask.test(ABS_Y)) { device->classes |= INPUT_DEVICE_CLASS_EXTERNAL_STYLUS; device->classes |= InputDeviceClass::EXTERNAL_STYLUS; // Keyboard will try to claim some of the buttons but we really want to reserve those so we // can fuse it with the touch screen data, so just take them back. Note this means an // external stylus cannot also be a keyboard device. device->classes &= ~INPUT_DEVICE_CLASS_KEYBOARD; device->classes &= ~InputDeviceClass::KEYBOARD; } // See if this device is a joystick. // Assumes that joysticks always have gamepad buttons in order to distinguish them // from other devices such as accelerometers that also have absolute axes. if (haveGamepadButtons) { uint32_t assumedClasses = device->classes | INPUT_DEVICE_CLASS_JOYSTICK; auto assumedClasses = device->classes | InputDeviceClass::JOYSTICK; for (int i = 0; i <= ABS_MAX; i++) { if (device->absBitmask.test(i) && (getAbsAxisUsage(i, assumedClasses) & INPUT_DEVICE_CLASS_JOYSTICK)) { (getAbsAxisUsage(i, assumedClasses).test(InputDeviceClass::JOYSTICK))) { device->classes = assumedClasses; break; } Loading @@ -1336,36 +1339,36 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // Check whether this device has switches. for (int i = 0; i <= SW_MAX; i++) { if (device->swBitmask.test(i)) { device->classes |= INPUT_DEVICE_CLASS_SWITCH; device->classes |= InputDeviceClass::SWITCH; break; } } // Check whether this device supports the vibrator. if (device->ffBitmask.test(FF_RUMBLE)) { device->classes |= INPUT_DEVICE_CLASS_VIBRATOR; device->classes |= InputDeviceClass::VIBRATOR; } // Configure virtual keys. if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) { if ((device->classes.test(InputDeviceClass::TOUCH))) { // Load the virtual keys for the touch screen, if any. // We do this now so that we can make sure to load the keymap if necessary. bool success = loadVirtualKeyMapLocked(device); if (success) { device->classes |= INPUT_DEVICE_CLASS_KEYBOARD; device->classes |= InputDeviceClass::KEYBOARD; } } // Load the key map. // We need to do this for joysticks too because the key layout may specify axes. status_t keyMapStatus = NAME_NOT_FOUND; if (device->classes & (INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_JOYSTICK)) { if (device->classes.any(InputDeviceClass::KEYBOARD | InputDeviceClass::JOYSTICK)) { // Load the keymap for the device. keyMapStatus = loadKeyMapLocked(device); } // Configure the keyboard, gamepad or virtual keyboard. if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) { if (device->classes.test(InputDeviceClass::KEYBOARD)) { // Register the keyboard as a built-in keyboard if it is eligible. if (!keyMapStatus && mBuiltInKeyboardId == NO_BUILT_IN_KEYBOARD && isEligibleBuiltInKeyboard(device->identifier, device->configuration, &device->keyMap)) { Loading @@ -1374,7 +1377,7 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // 'Q' key support = cheap test of whether this is an alpha-capable kbd if (hasKeycodeLocked(device, AKEYCODE_Q)) { device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY; device->classes |= InputDeviceClass::ALPHAKEY; } // See if this device has a DPAD. Loading @@ -1383,20 +1386,20 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { hasKeycodeLocked(device, AKEYCODE_DPAD_LEFT) && hasKeycodeLocked(device, AKEYCODE_DPAD_RIGHT) && hasKeycodeLocked(device, AKEYCODE_DPAD_CENTER)) { device->classes |= INPUT_DEVICE_CLASS_DPAD; device->classes |= InputDeviceClass::DPAD; } // See if this device has a gamepad. for (size_t i = 0; i < sizeof(GAMEPAD_KEYCODES) / sizeof(GAMEPAD_KEYCODES[0]); i++) { if (hasKeycodeLocked(device, GAMEPAD_KEYCODES[i])) { device->classes |= INPUT_DEVICE_CLASS_GAMEPAD; device->classes |= InputDeviceClass::GAMEPAD; break; } } } // If the device isn't recognized as something we handle, don't monitor it. if (device->classes == 0) { if (device->classes == Flags<InputDeviceClass>(0)) { ALOGV("Dropping device: id=%d, path='%s', name='%s'", deviceId, devicePath.c_str(), device->identifier.name.c_str()); delete device; Loading @@ -1405,16 +1408,16 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { // Determine whether the device has a mic. if (deviceHasMicLocked(device)) { device->classes |= INPUT_DEVICE_CLASS_MIC; device->classes |= InputDeviceClass::MIC; } // Determine whether the device is external or internal. if (isExternalDeviceLocked(device)) { device->classes |= INPUT_DEVICE_CLASS_EXTERNAL; device->classes |= InputDeviceClass::EXTERNAL; } if (device->classes & (INPUT_DEVICE_CLASS_JOYSTICK | INPUT_DEVICE_CLASS_DPAD) && device->classes & INPUT_DEVICE_CLASS_GAMEPAD) { if (device->classes.any(InputDeviceClass::JOYSTICK | InputDeviceClass::DPAD) && device->classes.test(InputDeviceClass::GAMEPAD)) { device->controllerNumber = getNextControllerNumberLocked(device); setLedForControllerLocked(device); } Loading @@ -1441,11 +1444,12 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { configureFd(device); ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=0x%x, " ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=%s, " "configuration='%s', keyLayout='%s', keyCharacterMap='%s', builtinKeyboard=%s, ", deviceId, fd, devicePath.c_str(), device->identifier.name.c_str(), device->classes, device->configurationFile.c_str(), device->keyMap.keyLayoutFile.c_str(), device->keyMap.keyCharacterMapFile.c_str(), toString(mBuiltInKeyboardId == deviceId)); deviceId, fd, devicePath.c_str(), device->identifier.name.c_str(), device->classes.string().c_str(), device->configurationFile.c_str(), device->keyMap.keyLayoutFile.c_str(), device->keyMap.keyCharacterMapFile.c_str(), toString(mBuiltInKeyboardId == deviceId)); addDeviceLocked(device); return OK; Loading @@ -1453,7 +1457,7 @@ status_t EventHub::openDeviceLocked(const std::string& devicePath) { void EventHub::configureFd(Device* device) { // Set fd parameters with ioctl, such as key repeat, suspend block, and clock type if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) { if (device->classes.test(InputDeviceClass::KEYBOARD)) { // Disable kernel key repeat since we handle it ourselves unsigned int repeatRate[] = {0, 0}; if (ioctl(device->fd, EVIOCSREP, repeatRate)) { Loading Loading @@ -1551,8 +1555,8 @@ void EventHub::createVirtualKeyboardLocked() { Device* device = new Device(-1, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, "<virtual>", identifier); device->classes = INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_ALPHAKEY | INPUT_DEVICE_CLASS_DPAD | INPUT_DEVICE_CLASS_VIRTUAL; device->classes = InputDeviceClass::KEYBOARD | InputDeviceClass::ALPHAKEY | InputDeviceClass::DPAD | InputDeviceClass::VIRTUAL; loadKeyMapLocked(device); addDeviceLocked(device); } Loading Loading @@ -1719,8 +1723,9 @@ void EventHub::closeAllDevicesLocked() { } void EventHub::closeDeviceLocked(Device* device) { ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=0x%x", device->path.c_str(), device->identifier.name.c_str(), device->id, device->fd, device->classes); ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=%s", device->path.c_str(), device->identifier.name.c_str(), device->id, device->fd, device->classes.string().c_str()); if (device->id == mBuiltInKeyboardId) { ALOGW("built-in keyboard device %s (id=%d) is closing! the apps will not like this", Loading Loading @@ -1862,7 +1867,7 @@ void EventHub::dump(std::string& dump) { dump += StringPrintf(INDENT2 "%d: %s\n", device->id, device->identifier.name.c_str()); } dump += StringPrintf(INDENT3 "Classes: 0x%08x\n", device->classes); dump += StringPrintf(INDENT3 "Classes: %s\n", device->classes.string().c_str()); dump += StringPrintf(INDENT3 "Path: %s\n", device->path.c_str()); dump += StringPrintf(INDENT3 "Enabled: %s\n", toString(device->enabled)); dump += StringPrintf(INDENT3 "Descriptor: %s\n", device->identifier.descriptor.c_str()); Loading
services/inputflinger/reader/InputDevice.cpp +19 −18 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "InputDevice.h" #include <input/Flags.h> #include <algorithm> #include "CursorInputMapper.h" Loading Loading @@ -131,7 +132,7 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) { return; } std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId)); uint32_t classes = contextPtr->getDeviceClasses(); Flags<InputDeviceClass> classes = contextPtr->getDeviceClasses(); std::vector<std::unique_ptr<InputMapper>> mappers; // Check if we should skip population Loading @@ -141,33 +142,33 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) { } // Switch-like devices. if (classes & INPUT_DEVICE_CLASS_SWITCH) { if (classes.test(InputDeviceClass::SWITCH)) { mappers.push_back(std::make_unique<SwitchInputMapper>(*contextPtr)); } // Scroll wheel-like devices. if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { if (classes.test(InputDeviceClass::ROTARY_ENCODER)) { mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(*contextPtr)); } // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { if (classes.test(InputDeviceClass::VIBRATOR)) { mappers.push_back(std::make_unique<VibratorInputMapper>(*contextPtr)); } // Keyboard-like devices. uint32_t keyboardSource = 0; int32_t keyboardType = AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC; if (classes & INPUT_DEVICE_CLASS_KEYBOARD) { if (classes.test(InputDeviceClass::KEYBOARD)) { keyboardSource |= AINPUT_SOURCE_KEYBOARD; } if (classes & INPUT_DEVICE_CLASS_ALPHAKEY) { if (classes.test(InputDeviceClass::ALPHAKEY)) { keyboardType = AINPUT_KEYBOARD_TYPE_ALPHABETIC; } if (classes & INPUT_DEVICE_CLASS_DPAD) { if (classes.test(InputDeviceClass::DPAD)) { keyboardSource |= AINPUT_SOURCE_DPAD; } if (classes & INPUT_DEVICE_CLASS_GAMEPAD) { if (classes.test(InputDeviceClass::GAMEPAD)) { keyboardSource |= AINPUT_SOURCE_GAMEPAD; } Loading @@ -177,24 +178,24 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) { } // Cursor-like devices. if (classes & INPUT_DEVICE_CLASS_CURSOR) { if (classes.test(InputDeviceClass::CURSOR)) { mappers.push_back(std::make_unique<CursorInputMapper>(*contextPtr)); } // Touchscreens and touchpad devices. if (classes & INPUT_DEVICE_CLASS_TOUCH_MT) { if (classes.test(InputDeviceClass::TOUCH_MT)) { mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr)); } else if (classes & INPUT_DEVICE_CLASS_TOUCH) { } else if (classes.test(InputDeviceClass::TOUCH)) { mappers.push_back(std::make_unique<SingleTouchInputMapper>(*contextPtr)); } // Joystick-like devices. if (classes & INPUT_DEVICE_CLASS_JOYSTICK) { if (classes.test(InputDeviceClass::JOYSTICK)) { mappers.push_back(std::make_unique<JoystickInputMapper>(*contextPtr)); } // External stylus-like devices. if (classes & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (classes.test(InputDeviceClass::EXTERNAL_STYLUS)) { mappers.push_back(std::make_unique<ExternalStylusInputMapper>(*contextPtr)); } Loading @@ -209,7 +210,7 @@ void InputDevice::removeEventHubDevice(int32_t eventHubId) { void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) { mSources = 0; mClasses = 0; mClasses = Flags<InputDeviceClass>(0); mControllerNumber = 0; for_each_subdevice([this](InputDeviceContext& context) { Loading @@ -224,8 +225,8 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config } }); mIsExternal = !!(mClasses & INPUT_DEVICE_CLASS_EXTERNAL); mHasMic = !!(mClasses & INPUT_DEVICE_CLASS_MIC); mIsExternal = mClasses.test(InputDeviceClass::EXTERNAL); mHasMic = mClasses.test(InputDeviceClass::MIC); if (!isIgnored()) { if (!changes) { // first time only Loading @@ -238,7 +239,7 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config } if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS)) { if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) { if (!mClasses.test(InputDeviceClass::VIRTUAL)) { sp<KeyCharacterMap> keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); bool shouldBumpGeneration = false; Loading @@ -255,7 +256,7 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config } if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_ALIAS)) { if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); if (mAlias != alias) { mAlias = alias; Loading
services/inputflinger/reader/InputReader.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ void InputReader::addDeviceLocked(nsecs_t when, int32_t eventHubId) { mDevices.emplace(eventHubId, device); bumpGenerationLocked(); if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS)) { notifyExternalStylusPresenceChanged(); } } Loading Loading @@ -237,7 +237,7 @@ void InputReader::removeDeviceLocked(nsecs_t when, int32_t eventHubId) { device->removeEventHubDevice(eventHubId); if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS)) { notifyExternalStylusPresenceChanged(); } Loading Loading @@ -360,7 +360,7 @@ void InputReader::notifyExternalStylusPresenceChanged() { void InputReader::getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& outDevices) { for (auto& devicePair : mDevices) { std::shared_ptr<InputDevice>& device = devicePair.second; if (device->getClasses() & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS && !device->isIgnored()) { if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) { InputDeviceInfo info; device->getDeviceInfo(&info); outDevices.push_back(info); Loading
services/inputflinger/reader/include/EventHub.h +21 −20 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <climits> #include <vector> #include <input/Flags.h> #include <input/Input.h> #include <input/InputDevice.h> #include <input/KeyCharacterMap.h> Loading Loading @@ -76,58 +77,58 @@ struct RawAbsoluteAxisInfo { /* * Input device classes. */ enum { enum class InputDeviceClass : uint32_t { /* The input device is a keyboard or has buttons. */ INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001, KEYBOARD = 0x00000001, /* The input device is an alpha-numeric keyboard (not just a dial pad). */ INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002, ALPHAKEY = 0x00000002, /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */ INPUT_DEVICE_CLASS_TOUCH = 0x00000004, TOUCH = 0x00000004, /* The input device is a cursor device such as a trackball or mouse. */ INPUT_DEVICE_CLASS_CURSOR = 0x00000008, CURSOR = 0x00000008, /* The input device is a multi-touch touchscreen. */ INPUT_DEVICE_CLASS_TOUCH_MT = 0x00000010, TOUCH_MT = 0x00000010, /* The input device is a directional pad (implies keyboard, has DPAD keys). */ INPUT_DEVICE_CLASS_DPAD = 0x00000020, DPAD = 0x00000020, /* The input device is a gamepad (implies keyboard, has BUTTON keys). */ INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040, GAMEPAD = 0x00000040, /* The input device has switches. */ INPUT_DEVICE_CLASS_SWITCH = 0x00000080, SWITCH = 0x00000080, /* The input device is a joystick (implies gamepad, has joystick absolute axes). */ INPUT_DEVICE_CLASS_JOYSTICK = 0x00000100, JOYSTICK = 0x00000100, /* The input device has a vibrator (supports FF_RUMBLE). */ INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200, VIBRATOR = 0x00000200, /* The input device has a microphone. */ INPUT_DEVICE_CLASS_MIC = 0x00000400, MIC = 0x00000400, /* The input device is an external stylus (has data we want to fuse with touch data). */ INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800, EXTERNAL_STYLUS = 0x00000800, /* The input device has a rotary encoder */ INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000, ROTARY_ENCODER = 0x00001000, /* The input device is virtual (not a real device, not part of UI configuration). */ INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000, VIRTUAL = 0x40000000, /* The input device is external (not built-in). */ INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000, EXTERNAL = 0x80000000, }; /* * Gets the class that owns an axis, in cases where multiple classes might claim * the same axis for different purposes. */ extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses); extern Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses); /* * Grand Central Station for events. Loading Loading @@ -160,7 +161,7 @@ public: FIRST_SYNTHETIC_EVENT = DEVICE_ADDED, }; virtual uint32_t getDeviceClasses(int32_t deviceId) const = 0; virtual Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const = 0; virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0; Loading Loading @@ -327,7 +328,7 @@ class EventHub : public EventHubInterface { public: EventHub(); virtual uint32_t getDeviceClasses(int32_t deviceId) const override; virtual Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override; virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const override; Loading Loading @@ -397,7 +398,7 @@ private: std::unique_ptr<TouchVideoDevice> videoDevice; uint32_t classes; Flags<InputDeviceClass> classes; BitArray<KEY_MAX> keyBitmask; BitArray<KEY_MAX> keyState; Loading
services/inputflinger/reader/include/InputDevice.h +6 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define _UI_INPUTREADER_INPUT_DEVICE_H #include <input/DisplayViewport.h> #include <input/Flags.h> #include <input/InputDevice.h> #include <stdint.h> #include <utils/PropertyMap.h> Loading Loading @@ -48,7 +49,7 @@ public: inline int32_t getGeneration() const { return mGeneration; } inline const std::string getName() const { return mIdentifier.name; } inline const std::string getDescriptor() { return mIdentifier.descriptor; } inline uint32_t getClasses() const { return mClasses; } inline Flags<InputDeviceClass> getClasses() const { return mClasses; } inline uint32_t getSources() const { return mSources; } inline bool hasEventHubDevices() const { return !mDevices.empty(); } Loading Loading @@ -121,7 +122,7 @@ private: int32_t mControllerNumber; InputDeviceIdentifier mIdentifier; std::string mAlias; uint32_t mClasses; Flags<InputDeviceClass> mClasses; // map from eventHubId to device context and mappers using MapperVector = std::vector<std::unique_ptr<InputMapper>>; Loading Loading @@ -206,7 +207,9 @@ public: inline int32_t getId() { return mDeviceId; } inline int32_t getEventHubId() { return mId; } inline uint32_t getDeviceClasses() const { return mEventHub->getDeviceClasses(mId); } inline Flags<InputDeviceClass> getDeviceClasses() const { return mEventHub->getDeviceClasses(mId); } inline InputDeviceIdentifier getDeviceIdentifier() const { return mEventHub->getDeviceIdentifier(mId); } Loading