我用的是绘王USB PEN TABLET,带了一支手写笔。 public boolean onTouchEvent(android.view.MotionEvent event) { int iDeviceId = event.getDeviceId(); int iSource = event.getSource(); /* public final int getDeviceId () Gets the id for the device that this event came from. An id of zero indicates that the event didn""t come from a physical device and maps to the default keymap. The other numbers are arbitrary and you shouldn""t depend on the values. Returns The device id. public final int getSource () Gets the source of the event. Returns The event source or SOURCE_UNKNOWN if unknown. */ 调试的结果是: |
|
40分 |
有意思,帮忙顶一下。
|
这个输入源,确实“An id of zero indicates that the event didn””t come from a physical device and maps to the default keymap. The other numbers are arbitrary and you shouldn””t depend on the values.”是可变的,那如何确认是我的手写板呢?
|
|
@Override public boolean onTouchEvent(android.view.MotionEvent event) { if (mStop) { return true; } int iSource = event.getSource(); int iCheck = iSource & InputDevice.SOURCE_STYLUS; if (iCheck != InputDevice.SOURCE_STYLUS) { return true; } 这样就可以了 |