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

Commit f4b4cf5b authored by dbehr's avatar dbehr
Browse files

do not rotate keyboard dpad events for bluetooth keyboards (since they are not...

do not rotate keyboard dpad events for bluetooth keyboards (since they are not attached to the device and do not rotate when device is rotated)
parent 5dd3bd48
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -158,6 +158,8 @@ public:

    virtual String8 getDeviceName(int32_t deviceId) const = 0;

    virtual bool getDeviceBluetooth(int32_t deviceId) const = 0;

    virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
            RawAbsoluteAxisInfo* outAxisInfo) const = 0;

@@ -204,6 +206,8 @@ public:

    virtual String8 getDeviceName(int32_t deviceId) const;

    virtual bool getDeviceBluetooth(int32_t deviceId) const;

    virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
            RawAbsoluteAxisInfo* outAxisInfo) const;

@@ -245,9 +249,10 @@ private:
        KeyLayoutMap*   layoutMap;
        String8         keylayoutFilename;
        int             fd;
        bool            bluetooth;
        device_t*       next;
        
        device_t(int32_t _id, const char* _path, const char* name);
        device_t(int32_t _id, const char* _path, const char* name, bool _bluetooth);
        ~device_t();
    };

+2 −1
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@ private:
class KeyboardInputMapper : public InputMapper {
public:
    KeyboardInputMapper(InputDevice* device, int32_t associatedDisplayId, uint32_t sources,
            int32_t keyboardType);
            int32_t keyboardType, bool bluetooth = false);
    virtual ~KeyboardInputMapper();

    virtual uint32_t getSources();
@@ -432,6 +432,7 @@ private:
    int32_t mAssociatedDisplayId;
    uint32_t mSources;
    int32_t mKeyboardType;
    bool mBluetooth;

    struct LockedState {
        Vector<KeyDown> keyDowns; // keys that are down
+10 −3
Original line number Diff line number Diff line
@@ -92,9 +92,9 @@ static inline const char* toString(bool value) {
    return value ? "true" : "false";
}

EventHub::device_t::device_t(int32_t _id, const char* _path, const char* name)
EventHub::device_t::device_t(int32_t _id, const char* _path, const char* name, bool _bluetooth)
    : id(_id), path(_path), name(name), classes(0)
    , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), fd(-1), next(NULL) {
    , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), fd(-1), bluetooth(_bluetooth), next(NULL) {
}

EventHub::device_t::~device_t() {
@@ -137,6 +137,13 @@ String8 EventHub::getDeviceName(int32_t deviceId) const
    return device->name;
}

bool EventHub::getDeviceBluetooth(int32_t deviceId) const
{
    AutoMutex _l(mLock);
    device_t* device = getDeviceLocked(deviceId);
    return device->bluetooth;
}

uint32_t EventHub::getDeviceClasses(int32_t deviceId) const
{
    AutoMutex _l(mLock);
@@ -669,7 +676,7 @@ int EventHub::openDevice(const char *deviceName) {
        version >> 16, (version >> 8) & 0xff, version & 0xff);
#endif

    device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName, name);
    device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName, name, BUS_BLUETOOTH == id.bustype);
    if (device == NULL) {
        LOGE("out of memory");
        return -1;
+4 −4
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ InputDevice* InputReader::createDevice(int32_t deviceId, const String8& name, ui

    if (keyboardSources != 0) {
        device->addMapper(new KeyboardInputMapper(device,
                associatedDisplayId, keyboardSources, keyboardType));
                associatedDisplayId, keyboardSources, keyboardType, mEventHub->getDeviceBluetooth(deviceId)));
    }

    // Trackball-like devices.
@@ -870,9 +870,9 @@ int32_t SwitchInputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCod
// --- KeyboardInputMapper ---

KeyboardInputMapper::KeyboardInputMapper(InputDevice* device, int32_t associatedDisplayId,
        uint32_t sources, int32_t keyboardType) :
        uint32_t sources, int32_t keyboardType, bool bluetooth) :
        InputMapper(device), mAssociatedDisplayId(associatedDisplayId), mSources(sources),
        mKeyboardType(keyboardType) {
        mKeyboardType(keyboardType), mBluetooth(bluetooth) {
    initializeLocked();
}

@@ -962,7 +962,7 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
        if (down) {
            // Rotate key codes according to orientation if needed.
            // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
            if (mAssociatedDisplayId >= 0) {
            if (!mBluetooth && mAssociatedDisplayId >= 0) {
                int32_t orientation;
                if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) {
                    return;
+4 −0
Original line number Diff line number Diff line
@@ -486,6 +486,10 @@ private:
        return device ? device->name : String8("unknown");
    }

    virtual bool getDeviceBluetooth(int32_t deviceId) const {
        return false;
    }

    virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
            RawAbsoluteAxisInfo* outAxisInfo) const {
        Device* device = getDevice(deviceId);