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

Commit d05ae408 authored by Scott Brady's avatar Scott Brady
Browse files

Resubmit after fix for reverted merged mouse scrolling - fix build error in PWM.java

Change-Id: I373b5b164abc87d7ebe0fcf52ced1db66b4e4481
parent 4c7381ad
Loading
Loading
Loading
Loading
+1 −79
Original line number Diff line number Diff line
@@ -16,13 +16,10 @@

package com.android.internal.widget;

import android.app.Instrumentation;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.SystemClock;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;

@@ -50,7 +47,7 @@ public class MousePointerView extends View {
	if (mouseX == 0 && mouseY == 0) {
	}
	else if ((lastX == 0 && lastY == 0) || lastX - mouseX < 10.0f || lastY - mouseY < 10.0f) {
            // Draw mouse cursor
            // Draw mouse pointer
	    mPath.rewind();
            mPath.moveTo(mouseX, mouseY);
            mPath.lineTo(mouseX + 12.0f, mouseY + 12.0f);
@@ -72,54 +69,6 @@ public class MousePointerView extends View {
	}
    }
    
    private void mouseScrollUp()
    {
	long downTime = SystemClock.uptimeMillis();
	long eventTime = SystemClock.uptimeMillis();
	Instrumentation inst = new Instrumentation();
	MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, mouseX, mouseY, 0);
	inst.sendPointerSync(event);
	eventTime = SystemClock.uptimeMillis();
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY + 5.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY + 10.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY + 15.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY + 25.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY + 35.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY + 45.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, mouseX, mouseY + 60.0f, 0);
	inst.sendPointerSync(event);
    }

    private void mouseScrollDown()
    {
	long downTime = SystemClock.uptimeMillis();
	long eventTime = SystemClock.uptimeMillis();
	Instrumentation inst = new Instrumentation();
	MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, mouseX, mouseY, 0);
	inst.sendPointerSync(event);
	eventTime = SystemClock.uptimeMillis();
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY - 5.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY - 10.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY - 15.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY - 25.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY - 35.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, mouseX, mouseY - 45.0f, 0);
	inst.sendPointerSync(event);
	event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, mouseX, mouseY - 60.0f, 0);
	inst.sendPointerSync(event);
    }

    public void addTouchEvent(MotionEvent event) {
	lastX = mouseX;
	lastY = mouseY;
@@ -128,36 +77,9 @@ public class MousePointerView extends View {
	postInvalidate();
    }

    public void addKeyEvent(KeyEvent event) {
	if (event.getKeyCode() == 0x5c) {
		mouseScrollUp();
	}
	else if (event.getKeyCode() == 0x5d) {
		mouseScrollDown();
	}
	postInvalidate();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        addTouchEvent(event);
        return true;
    }

    @Override
    public boolean onTrackballEvent(MotionEvent event) {
        return super.onTrackballEvent(event);
    }
 
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        addKeyEvent(event);
        return true;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return true;
    }

}
+84 −27
Original line number Diff line number Diff line
@@ -3338,7 +3338,29 @@ void MouseInputMapper::sync(nsecs_t when) {
    { // acquire lock
        AutoMutex _l(mLock);

        if (fields & Accumulator::FIELD_BTN_RIGHT) {
       bool downChanged = fields & Accumulator::FIELD_BTN_MOUSE;
       if (downChanged) {
           if (mAccumulator.btnMouse) {
               mLocked.down = true;
               mLocked.downTime = when;
           } else {
               mLocked.down = false;
           }
           motionEventAction = mLocked.down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
        } else {
            motionEventAction = AMOTION_EVENT_ACTION_MOVE;
        }


        if (fields & Accumulator::FIELD_BTN_RIGHT && mLocked.down) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnRight ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
            AKEY_EVENT_FLAG_FROM_SYSTEM,
            0x03/*Keycode for home*/, 0x20 /*Scancode*/,
            mContext->getGlobalMetaState(), when);
        }
        else if (fields & Accumulator::FIELD_BTN_RIGHT) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnRight ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
@@ -3347,7 +3369,15 @@ void MouseInputMapper::sync(nsecs_t when) {
            mContext->getGlobalMetaState(), when);
        }

        if (fields & Accumulator::FIELD_BTN_MIDDLE) {
        if (fields & Accumulator::FIELD_BTN_MIDDLE && mLocked.down) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnMiddle ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
            AKEY_EVENT_FLAG_FROM_SYSTEM,
            0x42/*Keycode for enter key*/, 0x27 /*Scancode*/,
            mContext->getGlobalMetaState(), when);
        }
        else if (fields & Accumulator::FIELD_BTN_MIDDLE) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnMiddle ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
@@ -3356,7 +3386,15 @@ void MouseInputMapper::sync(nsecs_t when) {
            mContext->getGlobalMetaState(), when);
        }

       if (fields & Accumulator::FIELD_BTN_SIDE) {
       if (fields & Accumulator::FIELD_BTN_SIDE && mLocked.down) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnSide ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
            AKEY_EVENT_FLAG_FROM_SYSTEM,
            0x16 /*Keycode for right key*/, 0x30 /*Scancode*/,
            mContext->getGlobalMetaState(), when);
       }
       else if (fields & Accumulator::FIELD_BTN_SIDE) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnSide ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
@@ -3365,12 +3403,20 @@ void MouseInputMapper::sync(nsecs_t when) {
            mContext->getGlobalMetaState(), when);
        }

        if (fields & Accumulator::FIELD_BTN_EXTRA) {
        if (fields & Accumulator::FIELD_BTN_EXTRA && mLocked.down) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnExtra ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
            AKEY_EVENT_FLAG_FROM_SYSTEM,
            0x54/*Keycode for search key*/, 0x21 /*Scancode*/,
            0x15 /*Keycode for left key*/, 0x31 /*Scancode*/,
            mContext->getGlobalMetaState(), when);
        }
        else if (fields & Accumulator::FIELD_BTN_EXTRA) {
            getDispatcher()->notifyKey(when, getDeviceId(),
            AINPUT_SOURCE_DPAD, 0, mAccumulator.btnExtra ?
            AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
            AKEY_EVENT_FLAG_FROM_SYSTEM,
            0x42/*Keycode for enter key*/, 0x27 /*Scancode*/,
            mContext->getGlobalMetaState(), when);
        }

@@ -3392,43 +3438,54 @@ void MouseInputMapper::sync(nsecs_t when) {
            mContext->getGlobalMetaState(), when);
        }

       bool downChanged = fields & Accumulator::FIELD_BTN_MOUSE;
       if (downChanged) {
           if (mAccumulator.btnMouse) {
               mLocked.down = true;
               mLocked.downTime = when;
           } else {
               mLocked.down = false;
	bool scrollChanged = fields & Accumulator::FIELD_REL_WHEEL;
        if (mAccumulator.btnScrollUp && scrollChanged && mLocked.down) {
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_DOWN,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x57/*Keycode for next key*/, 0x28 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_UP,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x57/*Keycode for next key*/, 0x28 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
        }
           motionEventAction = mLocked.down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
        } else {
            motionEventAction = AMOTION_EVENT_ACTION_MOVE;
        else if (mAccumulator.btnScrollUp && scrollChanged) {
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_DOWN,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x13/*Keycode for up key*/, 0x24 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_UP,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x13/*Keycode for up key*/, 0x24 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
        }

	bool scrollChanged = fields & Accumulator::FIELD_REL_WHEEL;
        if (mAccumulator.btnScrollUp && scrollChanged) {
        else if (mAccumulator.btnScrollDown && scrollChanged && mLocked.down) {
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_DOWN,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x5c/*Keycode for page up key*/, 0x24 /*Scancode*/,
                0x58/*Keycode for previous key*/, 0x29 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
            getDispatcher()->notifyKey(when + (10 * 1000000LL), getDeviceId(),
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_UP,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x5c/*Keycode for page up key*/, 0x24 /*Scancode*/,
                mContext->getGlobalMetaState(), when + (10 * 1000000LL));
                0x58/*Keycode for previous key*/, 0x29 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
        }
        else if (mAccumulator.btnScrollDown && scrollChanged) {
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_DOWN,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x5d/*Keycode for page down key*/, 0x25 /*Scancode*/,
                0x14/*Keycode for down key*/, 0x25 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
            getDispatcher()->notifyKey(when + (10 * 1000000LL), getDeviceId(),
            getDispatcher()->notifyKey(when, getDeviceId(),
                AINPUT_SOURCE_DPAD, 0, AKEY_EVENT_ACTION_UP,
                AKEY_EVENT_FLAG_FROM_SYSTEM,
                0x5d/*Keycode for page down key*/, 0x25 /*Scancode*/,
                mContext->getGlobalMetaState(), when + (10 * 1000000LL));
                0x14/*Keycode for down key*/, 0x25 /*Scancode*/,
                mContext->getGlobalMetaState(), when);
        }

        downTime = mLocked.downTime;
+0 −10
Original line number Diff line number Diff line
@@ -259,16 +259,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
            }
        }
        @Override
        public void handleKey(KeyEvent event, Runnable finishedCallback) {
            finishedCallback.run();
            
            synchronized (mLock) {
                if (mousePointerView != null && (event.getKeyCode() == 0x5c || event.getKeyCode() == 0x5d)) {
                    mousePointerView.addKeyEvent(event);
                }
            }
        }
    };

    int mPointerLocationMode = 0;