Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way at all that I can tell how hard the screen is being pressed

I want to find the pressure of the touch. I just don't know how to accomplish that result with out jailbreaking it and getting the raw touch data. Does anyone know How I would do this?

like image 756
Jab Avatar asked Jan 20 '10 17:01

Jab


People also ask

How to know if your phone is being monitored?

Below are a few signs that would let you know if your phone is being monitored. Further, you can take necessary measures and protect your privacy from getting vandalized. Faster battery drainage - Since the spying app runs in secret mode would be active in the background all the time.

How to know if your computer is not being monitored?

Here are 7 different ways to confirm if your computer is free from being monitored or not. 1. Monitoring processes from Windows Task Manager Press Ctrl + Alt + Del Key together to start Windows Security. Select Task Manager to open the Task Manager Window. If it is the minimal view, Click on More details to open the detailed view.

Why is my touch screen unresponsive?

In some cases, a problem with an app or program that you have downloaded can cause the touch screen to become unresponsive. The key to figuring this out is to restart in safe mode, since these apps and programs don’t load in safe mode.

How to make a laptop screen readable outdoors?

How to Make a Laptop Screen Readable Outdoors 1 Look for outdoor-optimized models. 2 Find a glossy-screened laptop that works great in the sun. 3 Buy a "rugged" or "outdoors" laptop. See More....


3 Answers

You cannot get the pressure from the SDK nor undocumented methods. However you can detect the size of touch with undocumented methods.


In the GSEvent, which is a lower-level representation of UIEvent, there is a structure known as GSPathInfo with members:

typedef struct GSPathInfo {
    unsigned char pathIndex;        // 0x0 = 0x5C
    unsigned char pathIdentity;     // 0x1 = 0x5D
    unsigned char pathProximity;    // 0x2 = 0x5E
    CGFloat pathPressure;               // 0x4 = 0x60
    CGFloat pathMajorRadius;        // 0x8 = 0x64
    CGPoint pathLocation;           // 0xC = 0x68
    GSWindowRef pathWindow;         // 0x14 = 0x70
} GSPathInfo;

We notice that there is a pathPressure and pathMajorRadius. I can assure you the pressure member is useless – it always gives 0. However pathMajorRadius does contain meaningful information – it gives the major radius of the touch in millimeters. You can therefore give an extremely rough estimation if it's a heavy touch or light touch from the radius.

  -(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
     GSEventRef gsevent = [event _gsEvent];
     GSPathInfo first_touch = GSEventGetPathInfoAtIndex(gsevent, 0);
     if (first_touch.pathMajorRadius >= 9)
        NSLog(@"huge (heavy) touch");
     else
        NSLog(@"little (light) touch");
  }

Let me warn you again this is undocumented and you should not use it in AppStore apps.


Edit: On 3.2 and above the pathMajorRadius of a GSPathInfo is also available as an undocumented property in UITouch:

@property(assign, nonatomic, setter=_setPathMajorRadius:) CGFloat _pathMajorRadius;

so the code above could be rewritten using pure Objective-C:

  -(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
     UITouch* any_touch = [touches anyObject];
     if (any_touch._pathMajorRadius >= 9)
        NSLog(@"huge (heavy) touch");
     else
        NSLog(@"little (light) touch");
  }
like image 137
kennytm Avatar answered Jan 04 '23 23:01

kennytm


As of iOS 8.0, UITouch has a public majorRadius property which tells you the approximate size of the touch.

like image 45
rob mayoff Avatar answered Jan 05 '23 01:01

rob mayoff


In iOS 3.2 and 4.0 you can get the value more directly like this:

UITouch* touch = ...// get the touch object
float radius = [[touch valueForKey:@"pathMajorRadius"] floatValue];

Still not App Store approved, but handy for custom stuff.

like image 24
jminor Avatar answered Jan 05 '23 00:01

jminor