Feeds:
Posts
Comments

This blog is pretty much obsolete. You can find my newer blog at http://www.metalev.org/, my resume site at http://resume.lukehutch.com/, or you can follow me on Twitter.

Cyanogen has ported my multi-touch code to the Android 2.0 / Eclair API, enabling much simpler implementation of multi-touch apps on top of the new Eclair multi-touch api.  If you’re implementing MT apps, trust me, you don’t want to do it without this Java class 🙂  The Eclair build includes both the official Linux kernel API for multi-touch, as well as changes to the MotionEvent class to support multiple touch points.  You can use these directly to implement multi-touch apps on Android without any additional code, but dealing with the huge amount of noise in the event stream on touch up / touch down events is a hard problem.  And re-implementing the boilerplate code for pinch-zoom over and over again is pointless, because it’s not as straightforward as you might think (you have to transform back and forth between two different coordinate spaces, etc.). Anyway my code helps with those problems, and to easily implement multi-touch apps on Eclair all you need is the patched version of my MultiTouchController.java class (see update below). (This is the class used in cyanogenmod to implement multi-touch scaling in the browser and the gallery.)  This class dramatically simplifies the logic necessary to implement dual-touch scaling (pinch zoom) as well as other dual-touch operations involving the distance between the touch points and their orientation.  There is also a *lot* of finicky behavior on current capacitive touchscreens on touch up / touch down events (e.g. one axis but not the other axis will suddenly jump to an ordinate of zero while the coordinate still reflects the correct location).  This code takes care of cleaning up the event stream pretty dramatically so you get stable and useful dual-touch information, has lots of useful helper methods and classes, and has a high-speed integer sqrt for calculating the distance between the touch points.  Anyway, thanks for porting the code, cyanogen [if anyone’s paying attention, it means cyanogenmod is basically now Eclair]. I hope this Java class is useful to somebody — please drop me a line if you use it to implement multi-touch in your own projects. UPDATED [2010-06-09]: Updated code to Android-2.2, added support for 3+ touch points, and moved to hosting on Google Code, see the link below.

MT Controller: UPDATE [2010-06-09]: get it from the new Google Code project here.

MT Demos (should work out-of-the-box on an unpatched Droid or Nexus One): MTVisualizer.apkMTMapsDemo.apkMTPhotoSortrDemo.apk Note that MTVisualizer is also posted as a free app in the Android Market.

MT Demos, source code: MTDemos.zip

UPDATED [2010-06-09]: List of applications that make use of the MT Controller — see these for more examples of how to incorporate the MT Controller class into your own code:

  • Mickael Despesse’s “Face Frenzy” face deformation app (not yet on the Market)
  • Yuan Chin’s fork of ADW Launcher to support multitouch — Yuan says, “I just made use of the backported version by mmin of your MultiTouchController in my fork of ADW Launcher (to implement the pinch zoom), and I have to say it really simplified things (on top of the backwards compatibility)!  Thank you! By the way, I will let @anderwebs know about it soon so it will be included in the ADW Launcher in the Market too!”
  • David Byrne’s fractal viewing app Fractoid, available free in the Android Market and with source available under the GPL.  David is the first person who has emailed me to say he’s using my code in an actual app shipping in the Market, thanks David!  Fractoid is really nicely done, the code is clean, and the pinch-zooming works really well.  It’s probably the best example of pinch-zoom out there right now because it zooms to exactly the pinched size, unlike the browser that can only zoom in-out by certain increments and constantly re-flows when you’re zooming.  Try out Fractoid and let David know what you think!
  • mmin’s handyCalc calculator, for pinch-zooming in/out of graphs.
  • Formerly: The browser in the cyanogenmod replacement firmware (and before that, JesusFreke) — also possibly other firmwares like dwang5.  Now replaced with official pinch/zoom in the second Nexus One OTA for Android 2.1.

UPDATE [2010-02-02]: Google releases an OTA update for the Nexus One that includes pinch-zoom in the three apps that make sense (Browser, Maps, Gallery3D).  Unfortunately however, I looked at the multitouch code used in these apps with baksmali — and it appears that all three MT controller implementations are different.  Also they don’t zoom around the correct point (the center of the pinch).  My multitouch controller does the correct transformation between screen coordinates and object coordinates to get the center of the zoom correct, and makes writing apps like this much easier — they could have saved themselves some time and work 🙂

—-

— Please donate if you use and like multi-touch on cyanogenmod (or previously on the JesusFreke ROMs) — it will encourage me to keep working on cool stuff!

Please donate to support continued development of awesome features for Android!

I just discovered a really simple way to create a workqueue on Linux that someone else might find useful.  If you have a bunch of jobs to run that all require different parameters and that potentially take different amounts of time to complete, it’s difficult to schedule them in a way that makes maximum use of the available cores short of using some sort of batch scheduling system, which is overly complicated for a lot of prototyping purposes.  It turns out that the xargs command has builtin workqueue scheduling that is really easy to use.

basic syntax (assuming you want to run the program ‘command’ with one parameter, and that you want to have four processes running at any one time):

echo param1 param2 param3 param4 param5 param6 | xargs -n1 -P4 command

will run

command param1 &      # & => background
command param2 &
command param3 &
command param4 &

then when the first command of those four completes, it will run

command param5 &

then command param6 &, etc.

If your command requires two parameters, do:

echo param1a param1b param2a param2b [etc.] | xargs -n2 -P4 command

If you have a quad-core processor with hyperthreading, you could do -P8, etc.

You can also obviously store the params in a file and do cat file | xargs … .

The nice thing about this approach over batch scheduling for prototyping is that if you hit Ctrl-C, it kills all the child processes.

I haven’t experimented yet to find the optimal way to generate a separate logfile for each child process, but I also just discovered PPSS which is a more powerful system for achieving the same thing as xargs, and supports separate logfiles: http://code.google.com/p/ppss/

I hope this is as useful to someone else as it is going to be to me!!

UPDATE 2010-06-07: Ole Tange left me a message in response to this post alerting me to the existence of the project he maintains, GNU Parallel.  Looks like an awesome tool.

SU article

A fairly decent short piece on Singularity University on CNET.

South Park meets Harvard Buliness School, article in FT.

“Secondly, even a cursory glance reveals the astounding regularity of Moore’s line. From the earliest points its progress has been eerily mechanical.  Without interruption for 50 years, chips improve exponentially at the same speed of acceleration, neither more nor less. It could not be more straight if it had been engineered by a technological tyrant. Yet, we are to believe that this strict nonwavering trajectory came about via the chaos of the global marketplace and uncoordinated ruthless scientific competition. The line is so straight and unambiguous that it seems curious anyone would need convincing by Moore and Mead to “believe” in it. The question of faith lies in whether one believes the force of this “law” lies within the technology itself, or in a self-fulfilling social prophecy. Is Moore’s law inevitable, a direction pushed forward by the nature of matter and computation, and independent of the society it was born into, or is it an artifact of self-organized scientific and economic ambition?” — The Technium

“You have to learn to make the parachute on the way down” — Peter Diamandis at Singularity University describing the need to extrapolate the current trends and start building something that requires a piece of technology that won’t exist for 5 years, but that you absolutely count on existing at that point in time.

(My new favorite quote.)

Great Singularity University-themed quote: “It is possible to believe that all the past is but the beginning of a beginning, and that all that is and has been is but the twilight of the dawn. It is possible to believe that all that the human mind has accomplished is but the dream before the awakening; out of our lineage, minds will spring that will reach back to us in our littleness to know us better than we know ourselves. A day will come, one day in the unending succession of days, when beings, beings who are now latent in our thoughts and hidden in our loins, shall stand upon this earth as one stands upon a footstool, and shall laugh and reach out their hands amidst the stars.”  –H.G. Wells

(Thanks, Michael!)

Singularity University is finally moving out of stealth mode — the list of students of the Graduate Studies Program Inaugural Class (GSP-09) has just been announced.  The media will be invited in to come meet the students over the next few weeks.

Keith Kleiner posted some photos and description of the first three weeks of SU.