About screen pressure sensitivity

Hi there,
I want to use screen touch pressure about size or opacity.Is it possible?
I can’t reach pressure sensor or something else.

Hi @tayyarare
I enabled ‘show pointer’ in the input section of the software developer bar, acessable in the android settings.
Then you can see on the top of the screen the coordinates and also the touch screen pressure as well as the touch size. On my device I can’t read the touch pressure, but the touch size I can.
With code below however I get an NullPointerException
@akenaton Do you have any idea?

import android.view.MotionEvent; 

MotionEvent pressure;
MotionEvent touchSize;
float ts = 1;

void setup() {
  size(200, 200);
  //float press = pressure.getPressure();

void draw() {
  if (mousePressed) {
    try {
      ts = touchSize.getSize();
    catch (Exception e) {
  text(str(ts), width/2, height/2);

@noel ===
my idea is: when ever you pretend to use some sensor you have to know wether it is or its not present in your phone:: so you have to list alll sensors, which is easy… (i must add that in a lot of cases they are not present)

Thanks, good idea; I will implement it.
About the error do you also have an ldea?
Becaue the touchSize can be used.

@noel ===
Sorry, as i am travelling i cannot test but looking to the error code i suppose that the mouse event is not recognized as a touchEvent by android and touchSize is always null; if i am right you have to use gestureDetector. I ll do that asap and put the code.

1 Like