[FIX] Enable palm rejection for spen on non stock roms

Search This thread

ghostwheel

Senior Member
Feb 5, 2008
352
82
48
As you might know, palm rejection on non stock roms has not worked for a long time. The symptoms are that when you try to draw with the s-pen in apps like squid or OneNote, often what you draw gets immediately erased.

I went back to CM13.0, where it supposedly did work, and checked what the difference is. I got lucky, and found the right files. It seems that palm rejection was removed from the file InputReader.cpp in frameworks_native/tree/p/services/inputflinger.

I'm sure there was a very good reason for that removal, probably because this is not the right place to do it. I tried to see what would happen if I put it back. I compiled XenonHD with the change, and now my s-pen works great! I tried squid, one note, gboard handwriting and others, and all works. I think this change can probably be easily incorporated into all AOSP/LOS roms.

The files are at https://github.com/ghostwheel/frameworks_native/tree/p/services/inputflinger , and you need InputReader.cpp and InputReader.h

As I said, there is probably a better way to enable palm rejection, but this works for now.

Update Actually, it seems the change was introduced between 14.1 and 15.0 . Look here: https://github.com/LineageOS/android_frameworks_native/blob/cm-14.1/services/inputflinger/InputReader.cpp. But I can't find the particular change that
caused this. Maybe it didn't have a great reason?
 
Last edited:

ghostwheel

Senior Member
Feb 5, 2008
352
82
48
You just need to take InputReader.cpp, InputReader.h and also InputDispatcher.cpp from the github above to the code, in frameworks_native/services/inputflinger/. The problem is that usually you don't have control of that dir. If you take control, it is easy.
 

Unidave199

Senior Member
Nov 18, 2013
348
62
58
Sprint Samsung Galaxy Note 4
You just need to take InputReader.cpp, InputReader.h and also InputDispatcher.cpp from the github above to the code, in frameworks_native/services/inputflinger/. The problem is that usually you don't have control of that dir. If you take control, it is easy.
Im suspecting you can use something like ES File Explorer (yes I still use an older version I have saved in TB) to just copy those files into the directory?

Dave
 

ghostwheel

Senior Member
Feb 5, 2008
352
82
48
I used to use ES file explorer...

All these are source files that need to be compiled together with the android dist.
It might be possible to just copy the result, maybe services.jar inside framework??? Not sure. The right way is to download a distribution, copy the files into the right place, and compile. XenonHD has nice instructions of how to do all that. Though, XenonHD already has all that built in, for exactly that reason....
 

Top Liked Posts

  • There are no posts matching your filters.
  • 12
    As you might know, palm rejection on non stock roms has not worked for a long time. The symptoms are that when you try to draw with the s-pen in apps like squid or OneNote, often what you draw gets immediately erased.

    I went back to CM13.0, where it supposedly did work, and checked what the difference is. I got lucky, and found the right files. It seems that palm rejection was removed from the file InputReader.cpp in frameworks_native/tree/p/services/inputflinger.

    I'm sure there was a very good reason for that removal, probably because this is not the right place to do it. I tried to see what would happen if I put it back. I compiled XenonHD with the change, and now my s-pen works great! I tried squid, one note, gboard handwriting and others, and all works. I think this change can probably be easily incorporated into all AOSP/LOS roms.

    The files are at https://github.com/ghostwheel/frameworks_native/tree/p/services/inputflinger , and you need InputReader.cpp and InputReader.h

    As I said, there is probably a better way to enable palm rejection, but this works for now.

    Update Actually, it seems the change was introduced between 14.1 and 15.0 . Look here: https://github.com/LineageOS/android_frameworks_native/blob/cm-14.1/services/inputflinger/InputReader.cpp. But I can't find the particular change that
    caused this. Maybe it didn't have a great reason?
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone