本文整理匯總了Java中android.view.MotionEvent.TOOL_TYPE_STYLUS屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.TOOL_TYPE_STYLUS屬性的具體用法?Java MotionEvent.TOOL_TYPE_STYLUS怎麽用?Java MotionEvent.TOOL_TYPE_STYLUS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.TOOL_TYPE_STYLUS屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: plot
@Override
public void plot(Spot s) {
final float pressureNorm;
if (ASSUME_STYLUS_CALIBRATED && s.tool == MotionEvent.TOOL_TYPE_STYLUS) {
pressureNorm = s.pressure;
} else {
pressureNorm = mPressureCooker.getAdjustedPressure(s.pressure);
}
final float radius = lerp(mRadiusMin, mRadiusMax,
(float) Math.pow(pressureNorm, mPressureExponent));
mTmpPoint[0] = s.x - mPanX;
mTmpPoint[1] = s.y - mPanY;
mZoomMatrixInv.mapPoints(mTmpPoint);
final RectF dirtyF = mRenderer.strokeTo(mTiledCanvas,
mTmpPoint[0],
mTmpPoint[1], radius);
dirty(dirtyF);
// dirtyF.roundOut(tmpDirtyRect);
// tmpDirtyRect.inset((int)-INVALIDATE_PADDING,(int)-INVALIDATE_PADDING);
// invalidate(tmpDirtyRect);
}
示例2: getToolTypeCompat
@SuppressLint("NewApi")
final static int getToolTypeCompat(MotionEvent me, int index) {
if (hasToolType()) {
return me.getToolType(index);
}
// dirty hack for the HTC Flyer
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
if ("flyer".equals(Build.HARDWARE)) {
if (me.getSize(index) <= 0.1f) {
// with very high probability this is the stylus
return MotionEvent.TOOL_TYPE_STYLUS;
}
}
}
return MotionEvent.TOOL_TYPE_FINGER;
}
示例3: filteredOutput
public Spot filteredOutput(Spot out) {
if (out == null) out = new Spot();
float wi = 1, w = 0;
float wi_press = 1, w_press = 0;
float x = 0, y = 0, pressure = 0, size = 0;
long time = 0;
for (Spot pi : mSpots) {
x += pi.x * wi;
y += pi.y * wi;
time += pi.time * wi;
pressure += pi.pressure * wi_press;
size += pi.size * wi_press;
w += wi;
wi *= mPosDecay; // exponential backoff
w_press += wi_press;
wi_press *= mPressureDecay;
if (PRECISE_STYLUS_INPUT && pi.tool == MotionEvent.TOOL_TYPE_STYLUS) {
// just take the top one, no need to average
break;
}
}
out.x = x / w;
out.y = y / w;
out.pressure = pressure / w_press;
out.size = size / w_press;
out.time = time;
out.tool = mSpots.get(0).tool;
return out;
}
示例4: isStylusButtonPressed
/**
* Identifies if the provided {@link MotionEvent} is a stylus with the primary stylus button
* pressed.
*
* @param event The event to check.
* @return Whether a stylus button press occurred.
*/
private static boolean isStylusButtonPressed(MotionEvent event) {
return event.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
&& ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY)
== MotionEvent.BUTTON_SECONDARY);
}