public class PointerProperties
extends java.lang.Object
This class returns ToolId16 ToolType and PreferredToolColorIndex or ToolSense ToolSense for a given
MotionEvent pointer
The following code fragment illustrates a method to obtain SMART ToolSense data from Android MotionEvent#PointerProperties
//
// Class member variables for Android MotionEvent#PointerProperties and
// SMART ToolSense PointerProperties. We allocate the objects once and
// reuse it for all MotionEvent.
//
MotionEvent.PointerProperties motionEventPointerProperties = new MotionEvent.PointerProperties();
com.smarttech.boardtoolid.PointerProperties toolSensePointerProperties = new com.smarttech.boardtoolid.PointerProperties(motionEventPointerProperties);
public boolean onTouchEvent(MotionEvent event) {
int pointerCount = event.getPointerCount();
for (int idx = 0; idx < pointerCount; ++idx) {
int pointer_id = event.getPointerId(idx);
int tool_type = event.getToolType(idx);
//
// Obtain Android MotionEvent.PointerProperties for the current pointer Id
//
event.getPointerProperties(idx, motionEventPointerProperties);
//
// toolSensePointerProperties object has already been associated with
// motionEventPointerProperties. Thus, we can obtain ToolSense ToolType and
// PreferredToolColorIndex directly from toolSensePointerProperties
//
com.smarttech.boardtoolid.ToolType extended_tool_type =
toolSensePointerProperties.getExtendedToolType();
if (extended_tool_type != ToolType.ToolSense) {
com.smarttech.boardtoolid.PreferredToolColorIndex preferred_tool_color_index =
toolSensePointerProperties.getPreferredToolColorIndex();
// Application logic to process ToolId16 data...
} else {
com.smarttech.boardtoolid.ToolSense tool_sense =
toolSensePointerProperties.getToolSense();
// Application logic to process ToolSense data...
}
}
}
| Constructor and Description |
|---|
PointerProperties(android.view.MotionEvent.PointerProperties motionEventPointerProperties)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
int |
copySerialNumber(byte[] outSerialNumber)
Deprecated
|
ToolType |
getExtendedToolType()
Return ToolSense tool type for a given MotionEvent pointer
|
PreferredToolColorIndex |
getPreferredToolColorIndex()
Return preferred tool color index for a given MotionEvent pointer
|
byte[] |
getSerialNumber()
Deprecated
|
int |
getSerialNumberLength()
Deprecated
|
ToolSense |
getToolSense()
Return ToolSense record blob associated with a touch contact
|
public PointerProperties(android.view.MotionEvent.PointerProperties motionEventPointerProperties)
This class does not make a deep copy of android.view.MotionEvent.PointerProperties. Thus, it is more efficient to allocate this object and android.view.MotionEvent#PointerProperties once, and reuse it for all MotionEvents.
motionEventPointerProperties - Extract ToolSense data from a given MotionEvent.PointerPropertiesToolType,
PreferredToolColorIndexpublic ToolType getExtendedToolType()
ToolSense tool type represents additional tool types that are not defined in Android MotionEvent TOOL_TYPE_* constants
ToolType for a given MotionEvent pointerToolType.Unknown is returned insteadpublic PreferredToolColorIndex getPreferredToolColorIndex()
Preferred tool color index contains symbolic name of a color. The name is defined
in Appendix D in USB HID
HUTRR53 "Stylus Preferred ink Color"
Callers may use PreferredToolColorLookupTable to lookup color value for
a given tool color index
PreferredToolColorIndex for a given MotionEvent pointerPreferredToolColorIndex.Unknown is returned insteadpublic int getSerialNumberLength()
public byte[] getSerialNumber()
public int copySerialNumber(byte[] outSerialNumber)
public ToolSense getToolSense()