[APP]CM/AOKP/AOSP S Pen detection

Search This thread

tushar9989

Senior Member
Apr 22, 2011
266
316
Mumbai
https://play.google.com/store/apps/details?id=com.tushar.cmspen2
This is an application which allows detection of the S Pen detachment even on AOSP/AOKP/CM based ROMs.
It has only been tested on the Note 2 by me. If it works on your note device please let me know so that I can add it to the list of compatible note devices.

Explanation of how it works:

The android system automatically adds event files for each input device it detects when being installed. These event files are located in /dev/input/eventX where X denotes a particular device. These event files can be read using native C code for which I use an API provided by Radu Motisan which can be found here and also a bit more information about the event files can be found there. So now using this interface I find the event file for the S Pen and then continously read it to see if the value of the S Pen sensor has been changed. Whenever it changes I broadcast the corresponding Intent which was broadcasted by Samsung so that any applications which work based on that Intent can work even on these ROMs without having to change any of their code.

An interesting thing is that this feature is already present in CyanogenMod i.e S-Pen Power saving mode which disables the s pen touch decoder when the s pen is inserted. I fail to understand why they are not doing the same thing that I am doing through my application and save all of us the trouble.
 
Last edited:

jnr21

Senior Member
Aug 17, 2007
2,907
991
Helsinki
Phone vibrates when i inserted/detached s-pen, so it works? I have note2 lte (n7105) with latest rootbox nightly.

Sent from my GT-N7105 using Tapatalk 4 Beta
 

bungknees

Senior Member
Jun 11, 2010
910
276
https://www.dropbox.com/s/eebkzugsm7ek12s/CM S-Pen Addon.apk

Guys this is the beta version of my application which can detect S Pen detection even on CyanogenMod(works for me on JellyBeer Rom).
Please test it out and tell me if it works on your ROM, it mimics the Intent which is broadcast-ed by Samsung when the S Pen is inserted/detached so any applications which use that intent should work fine.

You can use it in conjunction with my application S Pen Helper to mimic page-buddy on CM 10. Here is the playstore link https://play.google.com/store/apps/details?id=com.tushar.spen_helper

It works well, also Using jellybeer rom. Very good, one thing, how to auto launch a note app? There is the option to launch something, but can't choose what to launch, unless I'm blind.(which could easily be the case)
 

tushar9989

Senior Member
Apr 22, 2011
266
316
Mumbai
Phone vibrates when i inserted/detached s-pen, so it works? I have note2 lte (n7105) with latest rootbox nightly.

Sent from my GT-N7105 using Tapatalk 4 Beta

If it's vibrating means it's working :)

It works well, also Using jellybeer rom. Very good, one thing, how to auto launch a note app? There is the option to launch something, but can't choose what to launch, unless I'm blind.(which could easily be the case)

I had made spen-helper keeping Samsung based ROMs in mind so it selects s note by default but since it's not there on cm10 so it's blank just click below the enable launch toggle will pop up a dialog to change it. I'll fix it in the next version. Also I suggest not to keep the event monitor running in the background as it drains the battery a lot. I'm looking for a method to fix the battery drain currently.
 

bungknees

Senior Member
Jun 11, 2010
910
276
If it's vibrating means it's working :)



I had made spen-helper keeping Samsung based ROMs in mind so it selects s note by default but since it's not there on cm10 so it's blank just click below the enable launch toggle will pop up a dialog to change it. I'll fix it in the next version. Also I suggest not to keep the event monitor running in the background as it drains the battery a lot. I'm looking for a method to fix the battery drain currently.

Ok, thanks for the tip. Great work

Edit: just looked at battery now, and holy crap, yes it does drain it. But good start.
 
Last edited:

leonard.pitzu

Senior Member
Feb 19, 2012
76
19
app lauch settings

v0.2.1 out
-Bug fixes and optimizations
-Changed app version to reflect beta status

Can't see the "app launch settings" you've mentioned. Did you remove it? The batery drain is visible but i think it's not catastrophic. I wonder why the CM team never got around implementing this because they already have the building blocks...
 

tushar9989

Senior Member
Apr 22, 2011
266
316
Mumbai
Can't see the "app launch settings" you've mentioned. Did you remove it? The batery drain is visible but i think it's not catastrophic. I wonder why the CM team never got around implementing this because they already have the building blocks...

The app launch settings are not there in this application. If you want those features you will have to use this application in conjunction with this.
Regarding the battery drain I fixed it in the last version if you are still having battery drain I would suggest increasing the polling value to 1000 which is responsive enough and not at all taxing on the battery
 

leonard.pitzu

Senior Member
Feb 19, 2012
76
19
The app launch settings are not there in this application. If you want those features you will have to use this application in conjunction with this.
Regarding the battery drain I fixed it in the last version if you are still having battery drain I would suggest increasing the polling value to 1000 which is responsive enough and not at all taxing on the battery

Thanks for the update. I already use the app you've pointed at - just thought your app could do the same (my bad...). On the battery side i disabled you app and the s pen helper leaving me with "stock" CM10.1 + a bunch of play store downloaded apps. The battery drain is still there so the good news is that your app works as expected - that is not causing any dramatic power consumption. The the bad side... the battery drain is caused by something else. I've installed wakelock doctor and am waiting to see which is the app causing the mentioned battery drain (~4%/hour - roughly 4 times more than usual).
Thanks for your quick support!
 

tushar9989

Senior Member
Apr 22, 2011
266
316
Mumbai
Thanks for the update. I already use the app you've pointed at - just thought your app could do the same (my bad...). On the battery side i disabled you app and the s pen helper leaving me with "stock" CM10.1 + a bunch of play store downloaded apps. The battery drain is still there so the good news is that your app works as expected - that is not causing any dramatic power consumption. The the bad side... the battery drain is caused by something else. I've installed wakelock doctor and am waiting to see which is the app causing the mentioned battery drain (~4%/hour - roughly 4 times more than usual).
Thanks for your quick support!

The battery drain is a problem in most of the CM based ROMs. I use Sentinel ROM which gives much better battery life than any of the other ROMs I tried. Link is in my signature in case you want to try it out.
 

leonard.pitzu

Senior Member
Feb 19, 2012
76
19
The battery drain is a problem in most of the CM based ROMs. I use Sentinel ROM which gives much better battery life than any of the other ROMs I tried. Link is in my signature in case you want to try it out.


Thanks for pointing out that CM causes battery drain. I've previousely used CM on all my devices (HTC Desire, Nexus S, Galaxy Nexus, Note I & II and Nexus 7) and it turned out to being great. I'll test a bit more and then jump over to Sentinel ROM.
 

AllGamer

Retired Forum Moderator
May 24, 2008
11,917
1,657
SGH-T989
AT&T Samsung Galaxy Note I717
The battery drain is a problem in most of the CM based ROMs. I use Sentinel ROM which gives much better battery life than any of the other ROMs I tried. Link is in my signature in case you want to try it out.

I'm using Notes 1, Google Play will not let me download it.

Could you remove the Google Play restrictions?

or maybe just attach the .APK file here in XDA?

Thanks
 

bigjl99

Member
Sep 7, 2012
6
3
Issue with the app working reliably on an ASOP ROM

This is an application which allows detection of the S Pen detachment even on AOSP/AOKP/CM based ROMs.
It has only been tested on the Note 2 by me. If it works on your note device please let me know so that I can add it to the list of compatible note devices.
The source code can be found here



The android system automatically adds event files for each input device it detects when being installed. These event files are located in /dev/input/eventX where X denotes a particular device. These event files can be read using native C code for which I use an API provided by Radu Motisan which can be found and also a bit more information about the event files can be found there. So now using this interface I find the event file for the S Pen and then continously read it to see if the value of the S Pen sensor has been changed. Whenever it changes I broadcast the corresponding Intent which was broadcasted by Samsung so that any applications which work based on that Intent can work even on these ROMs without having to change any of their code.

An interesting thing is that this feature is already present in CyanogenMod i.e S-Pen Power saving mode which disables the s pen touch decoder when the s pen is inserted. I fail to understand why they are not doing the same thing that I am doing through my application and save all of us the trouble.

I want to thank you for your hard work on this application, and the level to which you've gone to enable s-pen support in non-touchwiz ROMs. I just made the jump to Carbon ROM (4.3) this weekend after using my Sprint Note 2 (SPH-L900) with rooted, stock 4.1 since I got it at launch last year. I am totally fed-up with touch-wiz and I am really amazed at the difference the ASOP ROM is making for me.

I installed your app and it seemed to work perfectly for about 20 mins or so, then the next time I pulled out my s-pen it didn't recognize the event. Rebooting didn't make a difference, the only thing that made it work again was uninstalling, and then reinstalling the app. I am really confused as to why it stops working. I've checked, and both background services are still active, not cached, and the main program shows as running in my application manager. Do you have any thoughts or suggestions?

I can't paste links into XDA as I don't contribute all that often, but if you want to check out more on Carbon ROM I read about it on galaxynote2root, listed under the recent posts. The ROM is extremely stable and I'm very baffled as to why it isn't cooperating with your app! Thanks!
 

tushar9989

Senior Member
Apr 22, 2011
266
316
Mumbai
I want to thank you for your hard work on this application, and the level to which you've gone to enable s-pen support in non-touchwiz ROMs. I just made the jump to Carbon ROM (4.3) this weekend after using my Sprint Note 2 (SPH-L900) with rooted, stock 4.1 since I got it at launch last year. I am totally fed-up with touch-wiz and I am really amazed at the difference the ASOP ROM is making for me.

I installed your app and it seemed to work perfectly for about 20 mins or so, then the next time I pulled out my s-pen it didn't recognize the event. Rebooting didn't make a difference, the only thing that made it work again was uninstalling, and then reinstalling the app. I am really confused as to why it stops working. I've checked, and both background services are still active, not cached, and the main program shows as running in my application manager. Do you have any thoughts or suggestions?

I can't paste links into XDA as I don't contribute all that often, but if you want to check out more on Carbon ROM I read about it on galaxynote2root, listed under the recent posts. The ROM is extremely stable and I'm very baffled as to why it isn't cooperating with your app! Thanks!

I think that is happening because you have screen off detection disabled and you are locking the phone before re inserting the s pen. If that happens again you can try inserting the pen then enabling and disabling the detection from the application's settings.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    https://play.google.com/store/apps/details?id=com.tushar.cmspen2
    This is an application which allows detection of the S Pen detachment even on AOSP/AOKP/CM based ROMs.
    It has only been tested on the Note 2 by me. If it works on your note device please let me know so that I can add it to the list of compatible note devices.

    Explanation of how it works:

    The android system automatically adds event files for each input device it detects when being installed. These event files are located in /dev/input/eventX where X denotes a particular device. These event files can be read using native C code for which I use an API provided by Radu Motisan which can be found here and also a bit more information about the event files can be found there. So now using this interface I find the event file for the S Pen and then continously read it to see if the value of the S Pen sensor has been changed. Whenever it changes I broadcast the corresponding Intent which was broadcasted by Samsung so that any applications which work based on that Intent can work even on these ROMs without having to change any of their code.

    An interesting thing is that this feature is already present in CyanogenMod i.e S-Pen Power saving mode which disables the s pen touch decoder when the s pen is inserted. I fail to understand why they are not doing the same thing that I am doing through my application and save all of us the trouble.
    3
    I'm at 70% of development an S-Pen App for our Galaxy Note devices.

    Please refers to this XDA thread if you are interested: http://xdaforums.com/android/software/app-app-samsung-devices-provided-stylus-t3000448
    2
    Phone vibrates when i inserted/detached s-pen, so it works? I have note2 lte (n7105) with latest rootbox nightly.

    Sent from my GT-N7105 using Tapatalk 4 Beta

    If it's vibrating means it's working :)

    It works well, also Using jellybeer rom. Very good, one thing, how to auto launch a note app? There is the option to launch something, but can't choose what to launch, unless I'm blind.(which could easily be the case)

    I had made spen-helper keeping Samsung based ROMs in mind so it selects s note by default but since it's not there on cm10 so it's blank just click below the enable launch toggle will pop up a dialog to change it. I'll fix it in the next version. Also I suggest not to keep the event monitor running in the background as it drains the battery a lot. I'm looking for a method to fix the battery drain currently.
    2
    That is good to know.

    I have no idea about the most popular applications but this is a good guide to get most of the S Pen functionality back http://xdaforums.com/showthread.php?t=2611415 . You could attach the screenshot shortcut to the S Pen button long press if you have bought it on the add-on.

    You should not need any justification to buy something. If the features offered by the Pro version are needed by you then buy it.
    2
    Please email me we can try looking for a solution. tushar 9989 at gmail[/email]

    Does this occur only on these ROMs or on all the ROMs. Also do you have any task killer/memory master etc installed which is probably killing the service.

    This is working on my personal build of SlimKat v2.2beta on the i605; I think I had to open the app and enable it, and maybe reboot a time or two, but the vibration when removing the pen assured me it was working.

    I tried getting one spen launcher app to work with it, and it would not work, but it works great with Note Buddy once I figured out how to use it.

    (It would be nice if the "enable" option for Note Buddy's auto-launch actualy said "enable auto-launch", as I missed the very small type heading above it; It would also be nice if the auto-launch window would open above the any currently opened app, and not go to the homescreen before opening)
    ;)

    In case any one is interested, here is my current list of favorite s-pen apps for non-touchwiz users:

    GfxTablet (..for linux users; also try KDE Connect)
    MyScript Calculator & MyScript Stylus Keyboard
    Note Buddy / S-Pen Helper (+ Pro Key)
    Write