Example usage for android.view InputDevice SOURCE_CLASS_POINTER

List of usage examples for android.view InputDevice SOURCE_CLASS_POINTER

Introduction

In this page you can find the example usage for android.view InputDevice SOURCE_CLASS_POINTER.

Prototype

int SOURCE_CLASS_POINTER

To view the source code for android.view InputDevice SOURCE_CLASS_POINTER.

Click Source Link

Document

The input source is a pointing device associated with a display.

Usage

From source file:org.connectbot.TerminalView.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((MotionEventCompat.getSource(event) & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL:
            // Process scroll wheel movement:
            float yDistance = MotionEventCompat.getAxisValue(event, MotionEvent.AXIS_VSCROLL);
            if (yDistance != 0) {
                int base = bridge.buffer.getWindowBase();
                bridge.buffer.setWindowBase(base - Math.round(yDistance));
                return true;
            }/*from   ww w . j  a  v a 2  s.  c o m*/
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.hippo.widget.BothScrollView.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            if (!mIsBeingDragged) {
                if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                    final float hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                    if (hscroll != 0) {
                        final int delta = (int) (hscroll * getHorizontalScrollFactor());
                        final int range = getHorizontalScrollRange();
                        int oldScrollX = getScrollX();
                        int newScrollX = oldScrollX + delta;
                        if (newScrollX < 0) {
                            newScrollX = 0;
                        } else if (newScrollX > range) {
                            newScrollX = range;
                        }//  w w  w  .  j  a v  a  2  s  .  com
                        if (newScrollX != oldScrollX) {
                            super.scrollTo(newScrollX, getScrollY());
                            return true;
                        }
                    }
                } else {
                    final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                    if (vscroll != 0) {
                        final int delta = (int) (vscroll * getVerticalScrollFactor());
                        final int range = getVerticalScrollRange();
                        int oldScrollY = getScrollY();
                        int newScrollY = oldScrollY - delta;
                        if (newScrollY < 0) {
                            newScrollY = 0;
                        } else if (newScrollY > range) {
                            newScrollY = range;
                        }
                        if (newScrollY != oldScrollY) {
                            super.scrollTo(getScrollX(), newScrollY);
                            return true;
                        }
                    }
                }
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.android.launcher2.PagedView.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            // Handle mouse (or ext. device) by shifting the page depending on the scroll
            final float vscroll;
            final float hscroll;
            if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                vscroll = 0;/*from ww  w  .  jav a  2s .c  o m*/
                hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
            } else {
                vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
            }
            if (hscroll != 0 || vscroll != 0) {
                if (hscroll > 0 || vscroll > 0) {
                    scrollRight();
                } else {
                    scrollLeft();
                }
                return true;
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:cc.flydev.launcher.Page.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            // Handle mouse (or ext. device) by shifting the page depending on the scroll
            final float vscroll;
            final float hscroll;
            if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                vscroll = 0;/*w  w w. j ava 2 s . c o  m*/
                hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
            } else {
                vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
            }
            if (hscroll != 0 || vscroll != 0) {
                boolean isForwardScroll = isLayoutRtl() ? (hscroll < 0 || vscroll < 0)
                        : (hscroll > 0 || vscroll > 0);
                if (isForwardScroll) {
                    scrollRight();
                } else {
                    scrollLeft();
                }
                return true;
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.n2hsu.launcher.Page.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            // Handle mouse (or ext. device) by shifting the page depending
            // on the scroll
            final float vscroll;
            final float hscroll;
            if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                vscroll = 0;//from w  ww.j  a va2  s  .c o  m
                hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
            } else {
                vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
            }
            if (hscroll != 0 || vscroll != 0) {
                boolean isForwardScroll = isLayoutRtl() ? (hscroll < 0 || vscroll < 0)
                        : (hscroll > 0 || vscroll > 0);
                if (isForwardScroll) {
                    scrollRight();
                } else {
                    scrollLeft();
                }
                return true;
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.glview.widget.AbsListView.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            if (mTouchMode == TOUCH_MODE_REST) {
                final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                if (vscroll != 0) {
                    final int delta = (int) (vscroll * getVerticalScrollFactor());
                    if (!trackMotionScroll(delta, delta)) {
                        return true;
                    }/*from   w  w w .j  a v  a2  s.  co  m*/
                }
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.example.libwidgettv.bak.AbsListView.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            if (mTouchMode == TOUCH_MODE_REST) {
                final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                if (vscroll != 0) {
                    final int delta = (int) (vscroll * 0.3);
                    if (!trackMotionScroll(delta, delta)) {
                        return true;
                    }/*ww w  .ja  v  a 2s. co m*/
                }
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.appunite.list.AbsHorizontalListView.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
@Override/*from   w  ww. j  ava2s .com*/
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            if (mTouchMode == TOUCH_MODE_REST) {
                final float hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
                if (hscroll != 0) {
                    final int delta = (int) (hscroll * getHorizontalScrollFactorUnhide());
                    if (!trackMotionScroll(delta, delta)) {
                        return true;
                    }
                }
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.appunite.list.AbsListView.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
@Override//from  ww w  .ja  v  a  2  s  . c om
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            if (mTouchMode == TOUCH_MODE_REST) {
                final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                if (vscroll != 0) {
                    final int delta = (int) (vscroll * getVerticalScrollFactorUnhide());
                    if (!trackMotionScroll(delta, delta)) {
                        return true;
                    }
                }
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}