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

Commit 809be3bf authored by Christopher Lais's avatar Christopher Lais
Browse files

input: Hack for trackball wake.

The action button is now considered a Motion event only, and not
passed through the same path as key events, so it isn't subject to
the normal interception keys are subject to.

The proper solution is probably to add a method for the policy to
intercept the correct event, instead of creating another one as I
am doing here.  However, it should probably only be called for
button presses (AMOTION_EVENT_ACTION_DOWN/UP), since movements are
fairly frequent when they're happening.

This patch simply generates a fake key event (BTN_MOUSE) for
button presses that are processed and then dropped by the phone
policy.  This patch may add latency to trackpad presses, but they
are not likely to be significant for normal use.

Change-Id: If0cd8b0ead3bf5574303c2804216690301340a3e
parent 230d77c6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -897,6 +897,9 @@ void KeyboardInputMapper::process(const RawEvent* rawEvent) {
        if (isKeyboardOrGamepadKey(scanCode)) {
            processKey(rawEvent->when, rawEvent->value != 0, rawEvent->keyCode, scanCode,
                    rawEvent->flags);
        } else if (scanCode == BTN_MOUSE) {
            processKey(rawEvent->when, rawEvent->value != 0, BTN_MOUSE, scanCode,
                    rawEvent->flags);
        }
        break;
    }
+17 −17
Original line number Diff line number Diff line
@@ -1968,16 +1968,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_RELEASED, false);
        }

        boolean isTrackballDown;
        try {
            isTrackballDown = mWindowManager.getTrackballScancodeState(BTN_MOUSE) > 0;
        } catch (RemoteException e) {
            isTrackballDown = false;
        boolean isBtnMouse = (keyCode == BTN_MOUSE);
        if (isBtnMouse) {
            // BTN_MOUSE is handled as Motion event only.
            result &= ~ACTION_PASS_TO_USER;
        }

        final boolean isWakeKey = (policyFlags
                & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0
                || (isTrackballDown && mTrackballWakeScreen);
                || (isBtnMouse && mTrackballWakeScreen);
        
        // If the key is injected, pretend that the screen is on and don't let the
        // device go to sleep.  This feature is mainly used for testing purposes.
@@ -2008,22 +2007,23 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                result &= ~ACTION_PASS_TO_USER;
                
                if (isWakeKey && down) {

                    // tell the mediator about a wake key, it may decide to
                    // turn on the screen depending on whether the key is
                    // appropriate.
                    if (!mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode)
                            && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
                    if (!mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode)) {
                        if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
                            || keyCode == KeyEvent.KEYCODE_VOLUME_UP)) {
                            handleVolumeKeyDown(keyCode);
                        }
                } else if (isWakeKey && !down) {
                    if (!mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode)
                            && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
                    }
                } else if (!down) {
                    if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
                        || keyCode == KeyEvent.KEYCODE_VOLUME_UP)) {
                        handleVolumeKeyUp(keyCode);
                    }
                } else if (isTrackballDown && isMusicActive()) {
                }

                if (isBtnMouse && down && isMusicActive()) {
                    long time = SystemClock.elapsedRealtime();
                    if (mTrackballHitTime == null) {
                        mTrackballHitTime = time;