Receiving DirectStylus Pen and Eraser Events

DirectStylus pen and eraser events are reported through standard Android 4.X MotionEvent APIs. You do not need any special SDKs or APIs to access the additional functionality offered by DirectStylus.

NVIDIA has extended the Android framework to set the TOOL_TYPE_STYLUS bit in the return value of MotionEvent.getToolType() when the pen tip is detected, and TOOL_TYPE_ERASER is set in the return value when the eraser tip is detected.

The API  MotionEvent.getSource() has been modified to set the SOURCE_STYLUS bit when the app is on the DirectStylus White List and the SOURCE_TOUCHSCREEN bit is also set. Only the SOURCE_TOUCHSCREEN bit is set if the app is not on the White List, to maintain compatibility with existing applications.

Calls to MotionEvent.getPressure() will return a relative value representing the tip contact area on the touch screen. Properly retrieving and handling this value will allow applications to display variable width lines on the screen, which correspond naturally to the stylus tip contact area.

  Stylus Pen Stylus Eraser
getPressure() Relative tip width measurement N/A




NVIDIA® GameWorks™ Documentation Rev. 1.0.220830 ©2014-2022. NVIDIA Corporation and affiliates. All Rights Reserved.