IRMotionRecognizer is a project mainly written in OBJECTIVE-C and C, it's free.
Like how you work with gestures.
Motion recognition. This collection of classes help you recognize device motion events sanely and conceptually. The project is under the new BSD license.