Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,811,145 Members 45,659 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Capture Stylus hover events before they get to apps

Tip us?
 
kibi1
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 4
Join Date: Nov 2009
Prompt [Q] Capture Stylus hover events before they get to apps

I'm trying to work with a custom build of Android based on KitKat to incorporate a stylus, copying some of the functionality (though not code) from Samsung which sells Android-with-stylus builds for e.g. the Note 3. I'm not including details of the specific device because right now I am working on a custom dev device and my aim is to write code which is generic enough to be usable from any Android (based on KitKat). The build (written by others) already incorporates drivers and sends stylus events correctly as motion events etc. Programming at the app level I can receive onHover, ontouch, onClick etc

The specific functionality I am trying to achieve is to pick up a stylus-button-click while hovering. It's perfectly possible to do this in any app, using an onGenericMotion Listener.

However, I want to make my "stylus-action" have system-wide effect - so that anywhere (in any other app, or in the launcher or whatever) I will pick up the event (prior to any other app) and bring up my custom menu. (just like AirCommand in Samsung Note 3) I guess in my custom Android this would then make that particular action somewhat protected or unusable for other users, but I'm ok with that.

In older Android (prior to ICS) you could try something by putting up a System Overlay (i.e in regular app code, without hacking the ROM at all), but this is no longer possible.

This is not an attempt to tapjack or whatever, I understand why this functionality has been removed from the domain of the regular programmer, and I don't want to regress my ROM back to pre-ICS behaviour by allowing the System Overlay hack. Now I am programming the system (if my change is good enough I'd like to submit it back to AOSP) so I would like to know the best method to address this. Since Samsung have already done this, it must be legal (using legal in the terms of "Android will allow it"), and I want to do it right.

Is it possible to write something similar to the System Overlay when you are running from a system service? Or is there a good choke-point to capture events before they are broadcast to the current running apps?

I was looking at (sorry, not allowed to post links) AndroidXRef /frameworks/base/core/java/android/view/View.java specifically in the function dispatchHoverEvent() which looks like a promising place. My naive idea is that I would place code here checking the MotionEvent to see if the button is pressed and if it is, don't call any listeners and instead call my little menu app (or broadcast a custom message, or something anyway). However, I've never written code on the ROM level before (LOTS of experience writing app code) so I don't know if this is a really bad point or a good point to add in code. Should I be putting things at a higher level or a lower one? Will this capture all events or not? Is it all just trial and error?

If this is the wrong place to ask questions like this, please tell me where on XDA I should be asking it. If it's the right place - please answer

Thanks
Kibi
 
kibi1
Old
#2  
Junior Member - OP
Thanks Meter 0
Posts: 4
Join Date: Nov 2009
Default Crickets....

Is this the wrong forum to ask? Anyone able to clue me in on where i should be asking?

Thanks
 
kibi1
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 4
Join Date: Nov 2009
Default Last try

Bumping one more time for good luck.

if this is the wrong forum, please can someone point the way to the right forum for me

Thanks

Kibi
 
Vaibhav Chauhan
Old
#4  
Vaibhav Chauhan's Avatar
Senior Member
Thanks Meter 133
Posts: 757
Join Date: Feb 2014
Location: Dahod, Gujarat
Quote:
Originally Posted by kibi1 View Post
Bumping one more time for good luck.

if this is the wrong forum, please can someone point the way to the right forum for me

Thanks

Kibi
this is not a wrong section but your post is too long so no one intrested to wasting time to read whole post.even i haven't read the post
PHONE;- Samsung galaxy s duos gt-s7562
OS:- Android ICS 4.0.4
BASEBAND VERSION:- S7562DDBMJ1
BUILD NO:- IMM76I.S7562XXBMJ1

Guides by me

...PRESS THANKS IF I HELP YOU...
.
 
sixgunmojo
Old
#5  
Senior Member
Thanks Meter 151
Posts: 193
Join Date: Jun 2013
Quote:
Originally Posted by kibi1 View Post
Bumping one more time for good luck.

if this is the wrong forum, please can someone point the way to the right forum for me

Thanks

Kibi
The guy above me is a dick. I stumbled across this post looking for something completely unrelated (title interested me). Five words in I knew this was something completely out of my league, but I still read the entire post. If I may offer you some probably useless advice, I would talk to the devs in the note forums. The only problem I could see is that the AOSP guys don't have this function in their roms because it's locked up Samsung code and the guys modding the stock roms leave it alone for the same reason. I could also be completely wrong. Like I said completely out of my league.
The Following User Says Thank You to sixgunmojo For This Useful Post: [ Click to Expand ]
Tags
aosp, custom, help !, stylus input
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes