Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sample code to get pen position and pressure (generic touch event which can distinguish pen vs touch)
- mCanvasView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- String osVer = Build.VERSION.RELEASE;
- boolean penActiveOn = false;
- int metaPenActiveOn = 0;
- float penPressure = 0.0f; // Pressure.
- float penX = 0.0f;
- float penY = 0.0f;
- // Gingerbread
- metaPenActiveOn = 0x200;
- if((event.getMetaState() & metaPenActiveOn) != 0)
- {
- penActiveOn = true;
- }
- if ( penActiveOn )
- {
- penPressure = event.getPressure(); // S Pen's Pressure
- penX = event.getX();
- penY = event.getY();
- System.out.format("**** pressure:", penPressure);
- System.out.format("**** X:", penX);
- System.out.format("**** Y:", penY);
- }
- return true;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement