Search in sources :

Example 71 with InputDevice

use of android.view.InputDevice in project android_frameworks_base by ResurrectionRemix.

the class MLand method getGameControllers.

public ArrayList getGameControllers() {
    mGameControllers.clear();
    int[] deviceIds = InputDevice.getDeviceIds();
    for (int deviceId : deviceIds) {
        InputDevice dev = InputDevice.getDevice(deviceId);
        if (isGamePad(dev)) {
            if (!mGameControllers.contains(deviceId)) {
                mGameControllers.add(deviceId);
            }
        }
    }
    return mGameControllers;
}
Also used : InputDevice(android.view.InputDevice) Paint(android.graphics.Paint)

Example 72 with InputDevice

use of android.view.InputDevice in project android_frameworks_base by ResurrectionRemix.

the class TaskTapPointerEventListener method onPointerEvent.

@Override
public void onPointerEvent(MotionEvent motionEvent) {
    doGestureDetection(motionEvent);
    final int action = motionEvent.getAction();
    switch(action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            {
                final int x = (int) motionEvent.getX();
                final int y = (int) motionEvent.getY();
                synchronized (this) {
                    if (!mTouchExcludeRegion.contains(x, y)) {
                        mService.mH.obtainMessage(H.TAP_OUTSIDE_TASK, x, y, mDisplayContent).sendToTarget();
                    }
                }
                break;
            }
        case MotionEvent.ACTION_MOVE:
            {
                if (motionEvent.getPointerCount() != 2) {
                    stopTwoFingerScroll();
                }
                break;
            }
        case MotionEvent.ACTION_HOVER_MOVE:
            {
                final int x = (int) motionEvent.getX();
                final int y = (int) motionEvent.getY();
                final Task task;
                synchronized (mService.mWindowMap) {
                    task = mDisplayContent.findTaskForControlPoint(x, y);
                }
                InputDevice inputDevice = motionEvent.getDevice();
                if (task == null || inputDevice == null) {
                    mPointerIconType = TYPE_NOT_SPECIFIED;
                    break;
                }
                task.getDimBounds(mTmpRect);
                if (!mTmpRect.isEmpty() && !mTmpRect.contains(x, y)) {
                    int iconType = TYPE_DEFAULT;
                    if (x < mTmpRect.left) {
                        iconType = (y < mTmpRect.top) ? TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW : (y > mTmpRect.bottom) ? TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW : TYPE_HORIZONTAL_DOUBLE_ARROW;
                    } else if (x > mTmpRect.right) {
                        iconType = (y < mTmpRect.top) ? TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW : (y > mTmpRect.bottom) ? TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW : TYPE_HORIZONTAL_DOUBLE_ARROW;
                    } else if (y < mTmpRect.top || y > mTmpRect.bottom) {
                        iconType = TYPE_VERTICAL_DOUBLE_ARROW;
                    }
                    if (mPointerIconType != iconType) {
                        mPointerIconType = iconType;
                        inputDevice.setPointerType(iconType);
                    }
                } else {
                    mPointerIconType = TYPE_NOT_SPECIFIED;
                }
            }
            break;
        case MotionEvent.ACTION_HOVER_EXIT:
            mPointerIconType = TYPE_NOT_SPECIFIED;
            InputDevice inputDevice = motionEvent.getDevice();
            if (inputDevice != null) {
                inputDevice.setPointerType(TYPE_DEFAULT);
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_POINTER_UP:
            {
                stopTwoFingerScroll();
                break;
            }
    }
}
Also used : InputDevice(android.view.InputDevice)

Example 73 with InputDevice

use of android.view.InputDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class KeyboardLayoutPickerFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    mIm.registerInputDeviceListener(this, null);
    InputDevice inputDevice = mIm.getInputDeviceByDescriptor(mInputDeviceIdentifier.getDescriptor());
    if (inputDevice == null) {
        getActivity().finish();
        return;
    }
    mInputDeviceId = inputDevice.getId();
    updateCheckedState();
}
Also used : InputDevice(android.view.InputDevice)

Example 74 with InputDevice

use of android.view.InputDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class KeyboardLayoutPickerFragment2 method onResume.

@Override
public void onResume() {
    super.onResume();
    mIm.registerInputDeviceListener(this, null);
    InputDevice inputDevice = mIm.getInputDeviceByDescriptor(mInputDeviceIdentifier.getDescriptor());
    if (inputDevice == null) {
        getActivity().finish();
        return;
    }
    mInputDeviceId = inputDevice.getId();
}
Also used : InputDevice(android.view.InputDevice)

Example 75 with InputDevice

use of android.view.InputDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class KeyboardLayoutDialogFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    mIm.registerInputDeviceListener(this, null);
    InputDevice inputDevice = mIm.getInputDeviceByDescriptor(mInputDeviceIdentifier.getDescriptor());
    if (inputDevice == null) {
        dismiss();
        return;
    }
    mInputDeviceId = inputDevice.getId();
}
Also used : InputDevice(android.view.InputDevice)

Aggregations

InputDevice (android.view.InputDevice)83 Paint (android.graphics.Paint)15 RemoteException (android.os.RemoteException)12 ArrayList (java.util.ArrayList)7 Vibrator (android.os.Vibrator)6 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)6 Point (android.graphics.Point)5 InputManager (android.hardware.input.InputManager)5 PointerCoords (android.view.MotionEvent.PointerCoords)5 DisplayInfo (android.view.DisplayInfo)4 KeyboardLayout (android.hardware.input.KeyboardLayout)2 DisplayMetrics (android.util.DisplayMetrics)2 Test (org.junit.Test)2 NonNull (android.annotation.NonNull)1 PendingIntent (android.app.PendingIntent)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 InputDeviceIdentifier (android.hardware.input.InputDeviceIdentifier)1