tag:blogger.com,1999:blog-89878749563391212.post2999219483134686295..comments2024-03-25T17:53:11.127-07:00Comments on Android-er: Detect multi-touch (for 10 pointers)Unknownnoreply@blogger.comBlogger6125tag:blogger.com,1999:blog-89878749563391212.post-27399139877861217192013-09-07T16:55:22.567-07:002013-09-07T16:55:22.567-07:00hello Ollie SP,
What is your device?hello Ollie SP,<br /><br />What is your device?Erikhttps://www.blogger.com/profile/04983894331825656853noreply@blogger.comtag:blogger.com,1999:blog-89878749563391212.post-29092785963176038482013-09-06T13:43:06.211-07:002013-09-06T13:43:06.211-07:00This is great, but in my device only detect 4 poin...This is great, but in my device only detect 4 pointers, i downloaded the project and tested and this ocurrs... any idea??<br /><br />ThanksAnonymoushttps://www.blogger.com/profile/12109489878905966311noreply@blogger.comtag:blogger.com,1999:blog-89878749563391212.post-37345846325056228362013-04-04T10:28:36.329-07:002013-04-04T10:28:36.329-07:00This is a great post.
The examples in NVidia Devel...This is a great post.<br />The examples in NVidia Development Kit implement similar approach.<br /><br />To fix the false positives whenever a pointer goes up, I've created additional boolean right after "touching" to distinguish false positives. <br /><br />When a pointer goes down, if both bools are false the pointer is registered as a new touch. In case the "if((action == MotionEvent.ACTION_DOWN)<br /> ||(action == MotionEvent.ACTION_POINTER_DOWN)<br /> ||(action == MotionEvent.ACTION_MOVE))" is positive, both bools are set to "true". <br /><br />When a pointer goes up, only the false positive bool is set to false. If there is a single pointer, both bools are set to false.<br /><br />After the loop but before "invalidate(); return true;", a new loop goes through all IDs with event.findPointerIndex(). If the ID does not exist and the false_positive is false, then the pointer is invalidated.<br /><br />Here is the actual touch implementation in my project:<br />final int MAX_NUMBER_OF_POINT = 20;<br /> float[] x = new float[MAX_NUMBER_OF_POINT];<br /> float[] y = new float[MAX_NUMBER_OF_POINT];<br /> boolean[] touching = new boolean[MAX_NUMBER_OF_POINT];<br /> boolean[] false_positive = new boolean[MAX_NUMBER_OF_POINT];<br /> int lastPointercounter;<br /><br /> public boolean onTouchEvent(MotionEvent event) <br /> {<br /><br /> int action = (event.getAction() & MotionEvent.ACTION_MASK);<br /><br /> int pointCount = event.getPointerCount();<br /><br /> for (int i = 0; i < pointCount; i++) <br /> {<br /> int id = event.getPointerId(i);<br /><br /> //Ignore pointer higher than our max.<br /> if(id < MAX_NUMBER_OF_POINT)<br /> {<br /> x[id] = (int)event.getX(i);<br /> y[id] = (int)event.getY(i);<br /><br /> if((action == MotionEvent.ACTION_DOWN)<br /> ||(action == MotionEvent.ACTION_POINTER_DOWN)<br /> ||(action == MotionEvent.ACTION_MOVE))<br /> {<br /> if(touching[id]!=true&&false_positive[id]!=true)<br /> {<br /><br /><br /> ToucheBegan2( x[id], y[id], tap_count, id );<br /> }<br /><br /> else<br /> {<br /> ToucheMoved2( x[id], y[id], tap_count , id);<br /> }<br /><br /> touching[id] = true;<br /> false_positive[id]=true;<br /> <br /> }<br /> else<br /> {<br /> false_positive[id]=false;<br /> if(pointCount==1)<br /> {<br /> touching[id]=false;<br /> ToucheEnded2( tap_count, id);<br /> }<br /> }<br /> } <br /> }<br /> for( int i=0; i < MAX_NUMBER_OF_POINT; i++)<br /> {<br /> if(event.findPointerIndex(i)==-1&&false_positive[i]!=true)<br /> {<br /><br /> touching[i]=false;<br /> ToucheEnded2( tap_count, i);<br /> }<br /> }<br /> invalidate(); <br /> return true;<br /><br /> }<br /><br />PS: I will add comments later.<br /><br />Anonymoushttps://www.blogger.com/profile/09476472334019180407noreply@blogger.comtag:blogger.com,1999:blog-89878749563391212.post-21128724920617553972012-08-11T05:23:51.160-07:002012-08-11T05:23:51.160-07:00Great stuff! The only problem here though is whene...Great stuff! The only problem here though is whenever a pointer goes up all the other pointers will become false for a short time. Do you have any solutions how to get rid of that?Anonymoushttps://www.blogger.com/profile/11948349535203372649noreply@blogger.comtag:blogger.com,1999:blog-89878749563391212.post-61265988865054617222012-01-02T20:52:03.435-08:002012-01-02T20:52:03.435-08:00hello Ben Reddicliffe,
depends on your code, you ...hello Ben Reddicliffe,<br /><br />depends on your code, you can modify your view to implement it.Erikhttps://www.blogger.com/profile/04983894331825656853noreply@blogger.comtag:blogger.com,1999:blog-89878749563391212.post-89872235990769560572012-01-02T08:39:36.932-08:002012-01-02T08:39:36.932-08:00Hi how can i get this code to work as an activity,...Hi how can i get this code to work as an activity, launched from another activity using an Intent ?Ben Reddicliffehttps://www.blogger.com/profile/05030526342400196959noreply@blogger.com